Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vega] Shim new platform - renaming vega -> vis_type_vega #41565

Merged
merged 2 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"kbnVislibVisTypes": "src/legacy/core_plugins/kbn_vislib_vis_types",
"visTypeMarkdown": "src/legacy/core_plugins/vis_type_markdown",
"metricVis": "src/legacy/core_plugins/metric_vis",
"vega": "src/legacy/core_plugins/vega",
"visTypeVega": "src/legacy/core_plugins/vis_type_vega",
"tableVis": "src/legacy/core_plugins/table_vis",
"regionMap": "src/legacy/core_plugins/region_map",
"statusPage": "src/legacy/core_plugins/status_page",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy

const vegaPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
// TODO: ID property should be changed from 'vega' to 'vis_type_vega'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukeelmers what should we do with it?
Not sure that we can rename vega.enableExternalUrls

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it as-is for now to prevent breaking things -- we need to figure out a bigger-picture strategy for how we want to deal with changes to configs & saved objects. But this is something that's easy enough to revisit later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe "easy" wasn't the best word to use... 😛 It's something we can wait on though

// It is required to change the configuration property
// vega.enableExternalUrls -> vis_type_vega.enableExternalUrls
id: 'vega',
require: ['kibana', 'elasticsearch', 'visualizations', 'interpreter', 'data'],
publicDir: resolve(__dirname, 'public'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class EmsFileParser {
*/
parseUrl(obj, url) {
if (typeof url.name !== 'string') {
throw new Error(i18n.translate('vega.emsFileParser.missingNameOfFileErrorMessage', {
throw new Error(i18n.translate('visTypeVega.emsFileParser.missingNameOfFileErrorMessage', {
defaultMessage: '{dataUrlParam} with {dataUrlParamValue} requires {nameParam} parameter (name of the file)',
values: {
dataUrlParam: '"data.url"',
Expand Down Expand Up @@ -65,7 +65,7 @@ export class EmsFileParser {
for (const { obj, name } of requests) {
const foundLayer = layers.find(v => v.name === name);
if (!foundLayer) {
throw new Error(i18n.translate('vega.emsFileParser.emsFileNameDoesNotExistErrorMessage', {
throw new Error(i18n.translate('visTypeVega.emsFileParser.emsFileNameDoesNotExistErrorMessage', {
defaultMessage: '{emsfile} {emsfileName} does not exist',
values: { emsfileName: JSON.stringify(name), emsfile: 'emsfile' },
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class EsQueryParser {
if (body === undefined) {
url.body = body = {};
} else if (!_.isPlainObject(body)) {
throw new Error(i18n.translate('vega.esQueryParser.urlBodyValueTypeErrorMessage', {
throw new Error(i18n.translate('visTypeVega.esQueryParser.urlBodyValueTypeErrorMessage', {
defaultMessage: '{configName} must be an object',
values: { configName: 'url.body' },
}));
Expand All @@ -72,7 +72,7 @@ export class EsQueryParser {
delete url[LEGACY_CONTEXT];
if (legacyContext !== undefined) {
if (body.query !== undefined) {
throw new Error(i18n.translate('vega.esQueryParser.dataUrlMustNotHaveLegacyAndBodyQueryValuesAtTheSameTimeErrorMessage', {
throw new Error(i18n.translate('visTypeVega.esQueryParser.dataUrlMustNotHaveLegacyAndBodyQueryValuesAtTheSameTimeErrorMessage', {
defaultMessage: '{dataUrlParam} must not have legacy {legacyContext} and {bodyQueryConfigName} values at the same time',
values: {
legacyContext: `"${LEGACY_CONTEXT}"`,
Expand All @@ -81,17 +81,18 @@ export class EsQueryParser {
},
}));
} else if (usesContext) {
throw new Error(i18n.translate('vega.esQueryParser.dataUrlMustNotHaveLegacyContextTogetherWithContextOrTimefieldErrorMessage', {
defaultMessage: '{dataUrlParam} must not have {legacyContext} together with {context} or {timefield}',
values: {
legacyContext: `"${LEGACY_CONTEXT}"`,
context: `"${CONTEXT}"`,
timefield: `"${TIMEFIELD}"`,
dataUrlParam: '"data.url"',
},
}));
throw new Error(
i18n.translate('visTypeVega.esQueryParser.dataUrlMustNotHaveLegacyContextTogetherWithContextOrTimefieldErrorMessage', {
defaultMessage: '{dataUrlParam} must not have {legacyContext} together with {context} or {timefield}',
values: {
legacyContext: `"${LEGACY_CONTEXT}"`,
context: `"${CONTEXT}"`,
timefield: `"${TIMEFIELD}"`,
dataUrlParam: '"data.url"',
},
}));
} else if (legacyContext !== true && (typeof legacyContext !== 'string' || legacyContext.length === 0)) {
throw new Error(i18n.translate('vega.esQueryParser.legacyContextCanBeTrueErrorMessage', {
throw new Error(i18n.translate('visTypeVega.esQueryParser.legacyContextCanBeTrueErrorMessage', {
// eslint-disable-next-line max-len
defaultMessage: 'Legacy {legacyContext} can either be {trueValue} (ignores time range picker), or it can be the name of the time field, e.g. {timestampParam}',
values: { legacyContext: `"${LEGACY_CONTEXT}"`, trueValue: 'true', timestampParam: '"@timestamp"' },
Expand All @@ -107,7 +108,7 @@ export class EsQueryParser {
}
result += '}';

this._onWarning(i18n.translate('vega.esQueryParser.legacyUrlShouldChangeToWarningMessage', {
this._onWarning(i18n.translate('visTypeVega.esQueryParser.legacyUrlShouldChangeToWarningMessage', {
defaultMessage: 'Legacy {urlParam}: {legacyUrl} should change to {result}',
values: {
legacyUrl: `"${LEGACY_CONTEXT}": ${JSON.stringify(legacyContext)}`,
Expand All @@ -119,7 +120,7 @@ export class EsQueryParser {

if (body.query !== undefined) {
if (usesContext) {
throw new Error(i18n.translate('vega.esQueryParser.urlContextAndUrlTimefieldMustNotBeUsedErrorMessage', {
throw new Error(i18n.translate('visTypeVega.esQueryParser.urlContextAndUrlTimefieldMustNotBeUsedErrorMessage', {
defaultMessage: '{urlContext} and {timefield} must not be used when {queryParam} is set',
values: {
timefield: `url.${TIMEFIELD}`,
Expand Down Expand Up @@ -222,7 +223,7 @@ export class EsQueryParser {
if (size === true) {
size = 50; // by default, try to get ~80 values
} else if (typeof size !== 'number') {
throw new Error(i18n.translate('vega.esQueryParser.autointervalValueTypeErrorMessage', {
throw new Error(i18n.translate('visTypeVega.esQueryParser.autointervalValueTypeErrorMessage', {
defaultMessage: '{autointerval} must be either {trueValue} or a number',
values: {
autointerval: `"${AUTOINTERVAL}"`,
Expand Down Expand Up @@ -250,7 +251,7 @@ export class EsQueryParser {
this._injectContextVars(subObj, isQuery);
continue;
default:
throw new Error(i18n.translate('vega.esQueryParser.timefilterValueErrorMessage', {
throw new Error(i18n.translate('visTypeVega.esQueryParser.timefilterValueErrorMessage', {
defaultMessage: '{timefilter} property must be set to {trueValue}, {minValue}, or {maxValue}',
values: {
timefilter: `"${TIMEFILTER}"`,
Expand Down Expand Up @@ -295,7 +296,7 @@ export class EsQueryParser {
if (opts.shift) {
const shift = opts.shift;
if (typeof shift !== 'number') {
throw new Error(i18n.translate('vega.esQueryParser.shiftMustValueTypeErrorMessage', {
throw new Error(i18n.translate('visTypeVega.esQueryParser.shiftMustValueTypeErrorMessage', {
defaultMessage: '{shiftParam} must be a numeric value',
values: {
shiftParam: '"shift"',
Expand Down Expand Up @@ -325,7 +326,7 @@ export class EsQueryParser {
multiplier = 1000;
break;
default:
throw new Error(i18n.translate('vega.esQueryParser.unknownUnitValueErrorMessage', {
throw new Error(i18n.translate('visTypeVega.esQueryParser.unknownUnitValueErrorMessage', {
defaultMessage: 'Unknown {unitParamName} value. Must be one of: [{unitParamValues}]',
values: {
unitParamName: '"unit"',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class UrlParser {
parseUrl(obj, urlObj) {
let url = urlObj.url;
if (!url) {
throw new Error(i18n.translate('vega.urlParser.dataUrlRequiresUrlParameterInFormErrorMessage', {
throw new Error(i18n.translate('visTypeVega.urlParser.dataUrlRequiresUrlParameterInFormErrorMessage', {
defaultMessage: '{dataUrlParam} requires a {urlParam} parameter in a form "{formLink}"',
values: {
dataUrlParam: '"data.url"',
Expand All @@ -49,7 +49,7 @@ export class UrlParser {

const query = urlObj.query;
if (!query) {
this._onWarning(i18n.translate('vega.urlParser.urlShouldHaveQuerySubObjectWarningMessage', {
this._onWarning(i18n.translate('visTypeVega.urlParser.urlShouldHaveQuerySubObjectWarningMessage', {
defaultMessage: 'Using a {urlObject} should have a {subObjectName} sub-object',
values: {
urlObject: '"url": {"%type%": "url", "url": ...}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class VegaParser {
this.spec = hjson.parse(this.spec, { legacyRoot: false });
}
if (!_.isPlainObject(this.spec)) {
throw new Error(i18n.translate('vega.vegaParser.invalidVegaSpecErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.invalidVegaSpecErrorMessage', {
defaultMessage: 'Invalid Vega specification',
}));
}
Expand Down Expand Up @@ -131,7 +131,7 @@ export class VegaParser {
this.spec.projections.length !== 1 ||
this.spec.projections[0].name !== 'projection'
) {
throw new Error(i18n.translate('vega.vegaParser.VLCompilerShouldHaveGeneratedSingleProtectionObjectErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.VLCompilerShouldHaveGeneratedSingleProtectionObjectErrorMessage', {
defaultMessage: 'Internal error: Vega-Lite compiler should have generated a single projection object',
}));
}
Expand Down Expand Up @@ -185,7 +185,7 @@ export class VegaParser {
delete this.spec.width;
delete this.spec.height;
} else {
this._onWarning(i18n.translate('vega.vegaParser.widthAndHeightParamsAreIgnoredWithAutosizeFitWarningMessage', {
this._onWarning(i18n.translate('visTypeVega.vegaParser.widthAndHeightParamsAreIgnoredWithAutosizeFitWarningMessage', {
defaultMessage: 'The {widthParam} and {heightParam} params are ignored with {autosizeParam}',
values: {
autosizeParam: 'autosize=fit',
Expand All @@ -207,15 +207,15 @@ export class VegaParser {
if (this._config.controlsLocation === undefined) {
this.containerDir = 'column';
} else {
throw new Error(i18n.translate('vega.vegaParser.unrecognizedControlsLocationValueErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.unrecognizedControlsLocationValueErrorMessage', {
defaultMessage: 'Unrecognized {controlsLocationParam} value. Expecting one of [{locToDirMap}]',
values: { locToDirMap: `"${locToDirMap.keys().join('", "')}"`, controlsLocationParam: 'controlsLocation' }
}));
}
}
const dir = this._config.controlsDirection;
if (dir !== undefined && dir !== 'horizontal' && dir !== 'vertical') {
throw new Error(i18n.translate('vega.vegaParser.unrecognizedDirValueErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.unrecognizedDirValueErrorMessage', {
defaultMessage: 'Unrecognized {dirParam} value. Expecting one of [{expectedValues}]',
values: { expectedValues: '"horizontal", "vertical"', dirParam: 'dir' },
}));
Expand All @@ -234,12 +234,12 @@ export class VegaParser {
result = this.spec._hostConfig;
delete this.spec._hostConfig;
if (!_.isPlainObject(result)) {
throw new Error(i18n.translate('vega.vegaParser.hostConfigValueTypeErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.hostConfigValueTypeErrorMessage', {
defaultMessage: 'If present, {configName} must be an object',
values: { configName: '"_hostConfig"' },
}));
}
this._onWarning(i18n.translate('vega.vegaParser.hostConfigIsDeprecatedWarningMessage', {
this._onWarning(i18n.translate('visTypeVega.vegaParser.hostConfigIsDeprecatedWarningMessage', {
defaultMessage: '{deprecatedConfigName} has been deprecated. Use {newConfigName} instead.',
values: {
deprecatedConfigName: '"_hostConfig"',
Expand All @@ -251,7 +251,7 @@ export class VegaParser {
result = this.spec.config.kibana;
delete this.spec.config.kibana;
if (!_.isPlainObject(result)) {
throw new Error(i18n.translate('vega.vegaParser.kibanaConfigValueTypeErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.kibanaConfigValueTypeErrorMessage', {
defaultMessage: 'If present, {configName} must be an object',
values: { configName: 'config.kibana' },
}));
Expand All @@ -270,7 +270,7 @@ export class VegaParser {
if (result.position === undefined) {
result.position = 'top';
} else if (['top', 'right', 'bottom', 'left'].indexOf(result.position) === -1) {
throw new Error(i18n.translate('vega.vegaParser.unexpectedValueForPositionConfigurationErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.unexpectedValueForPositionConfigurationErrorMessage', {
defaultMessage: 'Unexpected value for the {configurationName} configuration',
values: { configurationName: 'result.position' },
}));
Expand All @@ -279,7 +279,7 @@ export class VegaParser {
if (result.padding === undefined) {
result.padding = 16;
} else if (typeof result.padding !== 'number') {
throw new Error(i18n.translate('vega.vegaParser.paddingConfigValueTypeErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.paddingConfigValueTypeErrorMessage', {
defaultMessage: '{configName} is expected to be a number',
values: { configName: 'config.kibana.result.padding' },
}));
Expand All @@ -291,7 +291,7 @@ export class VegaParser {
} else if (typeof result.centerOnMark === 'boolean') {
result.centerOnMark = result.centerOnMark ? Number.MAX_VALUE : -1;
} else if (typeof result.centerOnMark !== 'number') {
throw new Error(i18n.translate('vega.vegaParser.centerOnMarkConfigValueTypeErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.centerOnMarkConfigValueTypeErrorMessage', {
defaultMessage: '{configName} is expected to be {trueValue}, {falseValue}, or a number',
values: { configName: 'config.kibana.result.centerOnMark', trueValue: 'true', falseValue: 'false' },
}));
Expand All @@ -318,7 +318,7 @@ export class VegaParser {
res[name] = parsed;
return;
}
this._onWarning(i18n.translate('vega.vegaParser.someKibanaConfigurationIsNoValidWarningMessage', {
this._onWarning(i18n.translate('visTypeVega.vegaParser.someKibanaConfigurationIsNoValidWarningMessage', {
defaultMessage: '{configName} is not valid',
values: { configName: `config.kibana.${name}` },
}));
Expand All @@ -335,7 +335,7 @@ export class VegaParser {
// `false` is a valid value
res.mapStyle = this._config.mapStyle === undefined ? `default` : this._config.mapStyle;
if (res.mapStyle !== `default` && res.mapStyle !== false) {
this._onWarning(i18n.translate('vega.vegaParser.mapStyleValueTypeWarningMessage', {
this._onWarning(i18n.translate('visTypeVega.vegaParser.mapStyleValueTypeWarningMessage', {
defaultMessage: '{mapStyleConfigName} may either be {mapStyleConfigFirstAllowedValue} or {mapStyleConfigSecondAllowedValue}',
values: {
mapStyleConfigName: 'config.kibana.mapStyle',
Expand All @@ -354,7 +354,7 @@ export class VegaParser {
if (!Array.isArray(maxBounds) || maxBounds.length !== 4 ||
!maxBounds.every(v => typeof v === 'number' && Number.isFinite(v))
) {
this._onWarning(i18n.translate('vega.vegaParser.maxBoundsValueTypeWarningMessage', {
this._onWarning(i18n.translate('visTypeVega.vegaParser.maxBoundsValueTypeWarningMessage', {
defaultMessage: '{maxBoundsConfigName} must be an array with four numbers',
values: {
maxBoundsConfigName: 'config.kibana.maxBounds',
Expand All @@ -373,7 +373,7 @@ export class VegaParser {
if (val === undefined) {
dstObj[paramName] = dflt;
} else if (typeof val !== 'boolean') {
this._onWarning(i18n.translate('vega.vegaParser.someKibanaParamValueTypeWarningMessage', {
this._onWarning(i18n.translate('visTypeVega.vegaParser.someKibanaParamValueTypeWarningMessage', {
defaultMessage: '{configName} must be a boolean value',
values: {
configName: `config.kibana.${paramName}`
Expand All @@ -392,7 +392,7 @@ export class VegaParser {
*/
_parseSchema() {
if (!this.spec.$schema) {
this._onWarning(i18n.translate('vega.vegaParser.inputSpecDoesNotSpecifySchemaWarningMessage', {
this._onWarning(i18n.translate('visTypeVega.vegaParser.inputSpecDoesNotSpecifySchemaWarningMessage', {
defaultMessage: 'The input spec does not specify a {schemaParam}, defaulting to {defaultSchema}',
values: { defaultSchema: `"${DEFAULT_SCHEMA}"`, schemaParam: '"$schema"' },
}));
Expand All @@ -404,7 +404,7 @@ export class VegaParser {
const libVersion = isVegaLite ? vegaLite.version : vega.version;

if (versionCompare(schema.version, libVersion) > 0) {
this._onWarning(i18n.translate('vega.vegaParser.notValidLibraryVersionForInputSpecWarningMessage', {
this._onWarning(i18n.translate('visTypeVega.vegaParser.notValidLibraryVersionForInputSpecWarningMessage', {
defaultMessage: 'The input spec uses {schemaLibrary} {schemaVersion}, but current version of {schemaLibrary} is {libraryVersion}.',
values: {
schemaLibrary: schema.library,
Expand Down Expand Up @@ -436,7 +436,7 @@ export class VegaParser {

const parser = this._urlParsers[type];
if (parser === undefined) {
throw new Error(i18n.translate('vega.vegaParser.notSupportedUrlTypeErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.notSupportedUrlTypeErrorMessage', {
defaultMessage: '{urlObject} is not supported',
values: {
urlObject: 'url: {"%type%": "${type}"}',
Expand Down Expand Up @@ -475,7 +475,7 @@ export class VegaParser {
if (key === 'data' && _.isPlainObject(obj.url)) {
// Assume that any "data": {"url": {...}} is a request for data
if (obj.values !== undefined || obj.source !== undefined) {
throw new Error(i18n.translate('vega.vegaParser.dataExceedsSomeParamsUseTimesLimitErrorMessage', {
throw new Error(i18n.translate('visTypeVega.vegaParser.dataExceedsSomeParamsUseTimesLimitErrorMessage', {
defaultMessage: 'Data must not have more than one of {urlParam}, {valuesParam}, and {sourceParam}',
values: {
urlParam: '"url"',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class VegaActionsMenu extends Component {
onClick={this.onButtonClick}
aria-label={
<FormattedMessage
id="vega.editor.vegaEditorOptionsButtonAriaLabel"
id="visTypeVega.editor.vegaEditorOptionsButtonAriaLabel"
defaultMessage="Vega editor options"
/>
}
Expand All @@ -74,7 +74,7 @@ export class VegaActionsMenu extends Component {
onClick={(event) => { this.closePopover(); this.props.formatHJson(event); }}
>
<FormattedMessage
id="vega.editor.reformatAsHJSONButtonLabel"
id="visTypeVega.editor.reformatAsHJSONButtonLabel"
defaultMessage="Reformat as HJSON"
/>
</EuiContextMenuItem>
Expand All @@ -84,7 +84,7 @@ export class VegaActionsMenu extends Component {
onClick={(event) => { this.closePopover(); this.props.formatJson(event); }}
>
<FormattedMessage
id="vega.editor.reformatAsJSONButtonLabel"
id="visTypeVega.editor.reformatAsJSONButtonLabel"
defaultMessage="Reformat as JSON, delete comments"
/>
</EuiContextMenuItem>
Expand Down
Loading