Skip to content

Commit

Permalink
Merge branch 'master' into reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jan 31, 2020
2 parents 5aa5ab5 + 38c7d3a commit e96c2f8
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 118 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
"murmurhash3js": "3.0.1",
"mutation-observer": "^1.0.3",
"nock": "10.0.6",
"node-sass": "^4.9.4",
"node-sass": "^4.13.1",
"normalize-path": "^3.0.0",
"nyc": "^14.1.1",
"pixelmatch": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-plugin-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"gulp-zip": "5.0.1",
"inquirer": "^1.2.2",
"minimatch": "^3.0.4",
"node-sass": "^4.9.4",
"node-sass": "^4.13.1",
"through2": "^2.0.3",
"through2-map": "^3.0.0",
"vinyl-fs": "^3.0.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"jquery": "^3.4.1",
"keymirror": "0.1.1",
"moment": "^2.24.0",
"node-sass": "^4.9.4",
"node-sass": "^4.13.1",
"postcss": "^7.0.5",
"postcss-loader": "^3.0.0",
"raw-loader": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,8 @@ export { showSaveModal, SaveResult } from 'ui/saved_objects/show_saved_object_sa
export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
export { KbnUrl } from 'ui/url/kbn_url';
// @ts-ignore
export { GlobalStateProvider } from 'ui/state_management/global_state';
// @ts-ignore
export { StateManagementConfigProvider } from 'ui/state_management/config_provider';
// @ts-ignore
export { PrivateProvider } from 'ui/private/private';
// @ts-ignore
export { EventsProvider } from 'ui/events';
export { PersistedState } from 'ui/persisted_state';
// @ts-ignore
export { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_top_nav';
// @ts-ignore
export { PromiseServiceCreator } from 'ui/promises/promises';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,12 @@ import {
confirmModalFactory,
createTopNavDirective,
createTopNavHelper,
EventsProvider,
IPrivate,
KbnUrlProvider,
PersistedState,
PrivateProvider,
PromiseServiceCreator,
RedirectWhenMissingProvider,
SavedObjectLoader,
StateManagementConfigProvider,
} from '../legacy_imports';
// @ts-ignore
import { initDashboardApp } from './legacy_app';
Expand Down Expand Up @@ -112,8 +109,6 @@ function createLocalAngularModule(core: AppMountContext['core'], navigation: Nav
createLocalPromiseModule();
createLocalConfigModule(core);
createLocalKbnUrlModule();
createLocalStateModule();
createLocalPersistedStateModule();
createLocalTopNavModule(navigation);
createLocalConfirmModalModule();
createLocalIconModule();
Expand All @@ -123,9 +118,9 @@ function createLocalAngularModule(core: AppMountContext['core'], navigation: Nav
'app/dashboard/Config',
'app/dashboard/I18n',
'app/dashboard/Private',
'app/dashboard/PersistedState',
'app/dashboard/TopNav',
'app/dashboard/State',
'app/dashboard/KbnUrl',
'app/dashboard/Promise',
'app/dashboard/ConfirmModal',
'app/dashboard/icon',
]);
Expand All @@ -145,29 +140,6 @@ function createLocalConfirmModalModule() {
.directive('confirmModal', reactDirective => reactDirective(EuiConfirmModal));
}

function createLocalStateModule() {
angular.module('app/dashboard/State', [
'app/dashboard/Private',
'app/dashboard/Config',
'app/dashboard/KbnUrl',
'app/dashboard/Promise',
'app/dashboard/PersistedState',
]);
}

function createLocalPersistedStateModule() {
angular
.module('app/dashboard/PersistedState', ['app/dashboard/Private', 'app/dashboard/Promise'])
.factory('PersistedState', (Private: IPrivate) => {
const Events = Private(EventsProvider);
return class AngularPersistedState extends PersistedState {
constructor(value: any, path: any) {
super(value, path, Events);
}
};
});
}

function createLocalKbnUrlModule() {
angular
.module('app/dashboard/KbnUrl', ['app/dashboard/Private', 'ngRoute'])
Expand All @@ -176,16 +148,13 @@ function createLocalKbnUrlModule() {
}

function createLocalConfigModule(core: AppMountContext['core']) {
angular
.module('app/dashboard/Config', ['app/dashboard/Private'])
.provider('stateManagementConfig', StateManagementConfigProvider)
.provider('config', () => {
return {
$get: () => ({
get: core.uiSettings.get.bind(core.uiSettings),
}),
};
});
angular.module('app/dashboard/Config', ['app/dashboard/Private']).provider('config', () => {
return {
$get: () => ({
get: core.uiSettings.get.bind(core.uiSettings),
}),
};
});
}

function createLocalPromiseModule() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ export function initDashboardApp(app, deps) {
addHelpMenuToAppChrome(deps.chrome, deps.core.docLinks);
}

app.config(stateManagementConfigProvider => {
// Dashboard state management is handled by state containers and state_sync utilities
stateManagementConfigProvider.disable();
});

app.factory('history', () => createHashHistory());
app.factory('kbnUrlStateStorage', history =>
createKbnUrlStateStorage({
Expand Down Expand Up @@ -141,7 +136,7 @@ export function initDashboardApp(app, deps) {
});
},
resolve: {
dash: function($rootScope, $route, redirectWhenMissing, kbnUrl) {
dash: function($rootScope, $route, redirectWhenMissing, kbnUrl, history) {
return ensureDefaultIndexPattern(deps.core, deps.npDataStart, $rootScope, kbnUrl).then(
() => {
const savedObjectsClient = deps.savedObjectsClient;
Expand All @@ -160,13 +155,13 @@ export function initDashboardApp(app, deps) {
dashboard.attributes.title.toLowerCase() === title.toLowerCase()
);
if (matchingDashboards.length === 1) {
kbnUrl.redirect(createDashboardEditUrl(matchingDashboards[0].id));
history.replace(createDashboardEditUrl(matchingDashboards[0].id));
} else {
kbnUrl.redirect(
history.replace(
`${DashboardConstants.LANDING_PAGE_PATH}?filter="${title}"`
);
$route.reload();
}
$rootScope.$digest();
return new Promise(() => {});
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import './components/color_gradient';
@import './vector/components/static_dynamic_style_row';
@import './vector/components/style_prop_editor';
@import './vector/components/color/color_stops';
@import './vector/components/symbol/icon_select';

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.mapStyleFormDisabledTooltip {
width: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import { i18n } from '@kbn/i18n';

import { VECTOR_STYLES } from '../vector_style_defaults';

export function getDisabledByMessage(styleName) {
return i18n.translate('xpack.maps.styles.vector.disabledByMessage', {
defaultMessage: `Set '{styleLabel}' to enable`,
values: { styleLabel: getVectorStyleLabel(styleName) },
});
}

export function getVectorStyleLabel(styleName) {
switch (styleName) {
case VECTOR_STYLES.FILL_COLOR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import React from 'react';

import { EuiFormRow, EuiSelect } from '@elastic/eui';
import { EuiFormRow, EuiSelect, EuiToolTip } from '@elastic/eui';
import { LABEL_BORDER_SIZES, VECTOR_STYLES } from '../../vector_style_defaults';
import { getVectorStyleLabel } from '../get_vector_style_label';
import { getVectorStyleLabel, getDisabledByMessage } from '../get_vector_style_label';
import { i18n } from '@kbn/i18n';

const options = [
Expand Down Expand Up @@ -38,20 +38,26 @@ const options = [
},
];

export function VectorStyleLabelBorderSizeEditor({ handlePropertyChange, styleProperty }) {
export function VectorStyleLabelBorderSizeEditor({
disabled,
disabledBy,
handlePropertyChange,
styleProperty,
}) {
function onChange(e) {
const styleDescriptor = {
options: { size: e.target.value },
};
handlePropertyChange(styleProperty.getStyleName(), styleDescriptor);
}

return (
const labelBorderSizeForm = (
<EuiFormRow
label={getVectorStyleLabel(VECTOR_STYLES.LABEL_BORDER_SIZE)}
display="columnCompressed"
>
<EuiSelect
disabled={disabled}
options={options}
value={styleProperty.getOptions().size}
onChange={onChange}
Expand All @@ -62,4 +68,17 @@ export function VectorStyleLabelBorderSizeEditor({ handlePropertyChange, stylePr
/>
</EuiFormRow>
);

if (!disabled) {
return labelBorderSizeForm;
}

return (
<EuiToolTip
anchorClassName="mapStyleFormDisabledTooltip"
content={getDisabledByMessage(disabledBy)}
>
{labelBorderSizeForm}
</EuiToolTip>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
*/

import React, { Component, Fragment } from 'react';
import { getVectorStyleLabel } from './get_vector_style_label';
import { EuiFormRow, EuiSelect } from '@elastic/eui';
import { getVectorStyleLabel, getDisabledByMessage } from './get_vector_style_label';
import {
EuiFormRow,
EuiSelect,
EuiFlexGroup,
EuiFlexItem,
EuiFieldText,
EuiToolTip,
} from '@elastic/eui';
import { VectorStyle } from '../vector_style';
import { i18n } from '@kbn/i18n';

Expand Down Expand Up @@ -69,7 +76,7 @@ export class StylePropEditor extends Component {
: VectorStyle.STYLE_TYPE.STATIC
}
onChange={this._onTypeToggle}
disabled={this.props.fields.length === 0}
disabled={this.props.disabled || this.props.fields.length === 0}
aria-label={i18n.translate('xpack.maps.styles.staticDynamicSelect.ariaLabel', {
defaultMessage: 'Select to style by fixed value or by data value',
})}
Expand All @@ -83,17 +90,35 @@ export class StylePropEditor extends Component {
this._onFieldMetaOptionsChange
);

const staticDynamicSelect = this.renderStaticDynamicSelect();

const stylePropertyForm = this.props.disabled ? (
<EuiToolTip
anchorClassName="mapStyleFormDisabledTooltip"
content={getDisabledByMessage(this.props.disabledBy)}
>
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
<EuiFlexItem grow={false}>{staticDynamicSelect}</EuiFlexItem>
<EuiFlexItem>
<EuiFieldText compressed disabled />
</EuiFlexItem>
</EuiFlexGroup>
</EuiToolTip>
) : (
<Fragment>
{React.cloneElement(this.props.children, {
staticDynamicSelect,
})}
{fieldMetaOptionsPopover}
</Fragment>
);

return (
<EuiFormRow
label={getVectorStyleLabel(this.props.styleProperty.getStyleName())}
display="rowCompressed"
>
<Fragment>
{React.cloneElement(this.props.children, {
staticDynamicSelect: this.renderStaticDynamicSelect(),
})}
{fieldMetaOptionsPopover}
</Fragment>
{stylePropertyForm}
</EuiFormRow>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

import React from 'react';

import { EuiFormRow, EuiButtonGroup } from '@elastic/eui';
import { EuiFormRow, EuiButtonGroup, EuiToolTip } from '@elastic/eui';

import { i18n } from '@kbn/i18n';
import { SYMBOLIZE_AS_TYPES } from '../../../../../../common/constants';
import { VECTOR_STYLES } from '../../vector_style_defaults';
import { getDisabledByMessage } from '../get_vector_style_label';

const SYMBOLIZE_AS_OPTIONS = [
{
Expand All @@ -27,7 +28,12 @@ const SYMBOLIZE_AS_OPTIONS = [
},
];

export function VectorStyleSymbolizeAsEditor({ styleProperty, handlePropertyChange }) {
export function VectorStyleSymbolizeAsEditor({
disabled,
disabledBy,
styleProperty,
handlePropertyChange,
}) {
const styleOptions = styleProperty.getOptions();
const selectedOption = SYMBOLIZE_AS_OPTIONS.find(({ id }) => {
return id === styleOptions.value;
Expand All @@ -42,14 +48,15 @@ export function VectorStyleSymbolizeAsEditor({ styleProperty, handlePropertyChan
handlePropertyChange(VECTOR_STYLES.SYMBOLIZE_AS, styleDescriptor);
};

return (
const symbolizeAsForm = (
<EuiFormRow
label={i18n.translate('xpack.maps.vector.symbolLabel', {
defaultMessage: 'Symbol type',
})}
display="columnCompressed"
>
<EuiButtonGroup
isDisabled={disabled}
buttonSize="compressed"
options={SYMBOLIZE_AS_OPTIONS}
idSelected={selectedOption ? selectedOption.id : undefined}
Expand All @@ -58,4 +65,17 @@ export function VectorStyleSymbolizeAsEditor({ styleProperty, handlePropertyChan
/>
</EuiFormRow>
);

if (!disabled) {
return symbolizeAsForm;
}

return (
<EuiToolTip
anchorClassName="mapStyleFormDisabledTooltip"
content={getDisabledByMessage(disabledBy)}
>
{symbolizeAsForm}
</EuiToolTip>
);
}
Loading

0 comments on commit e96c2f8

Please sign in to comment.