Skip to content

Commit

Permalink
Merge remote-tracking branch 'elastic/master' into monitoring/telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed Sep 23, 2020
2 parents 5152574 + 346c90a commit 11e1077
Show file tree
Hide file tree
Showing 19 changed files with 462 additions and 198 deletions.
537 changes: 362 additions & 175 deletions docs/management/advanced-options.asciidoc

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,6 @@ export class VisualizeEmbeddable
dirty = true;
}

// propagate the title to the output embeddable
// but only when the visualization is in edit/Visualize mode
if (!this.parent && this.vis.title !== this.output.title) {
this.updateOutput({ title: this.vis.title });
}

if (this.vis.description && this.domNode) {
this.domNode.setAttribute('data-description', this.vis.description);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export const getTopNavConfig = (
}
const currentTitle = savedVis.title;
savedVis.title = newTitle;
embeddableHandler.updateInput({ title: newTitle });
savedVis.copyOnSave = newCopyOnSave;
savedVis.description = newDescription;
const saveOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ describe('savedLens', () => {

expect(expression.input.filters).toEqual(embeddableFilters);
});

it('accepts an empty title when title is disabled', () => {
const expression = fn(null, { ...args, title: '' }, {} as any);
expect(expression.input.title).toEqual('');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function savedLens(): ExpressionFunctionDefinition<
id: args.id,
filters: getQueryFilters(filters),
timeRange: args.timerange || defaultTimeRange,
title: args.title ? args.title : undefined,
title: args.title === null ? undefined : args.title,
disableTriggers: true,
},
embeddableType: EmbeddableTypes.lens,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function savedMap(): ExpressionFunctionDefinition<

mapCenter: center,
hideFilterActions: true,
title: args.title ? args.title : undefined,
title: args.title === null ? undefined : args.title,
isLayerTOCOpen: false,
hiddenLayers: args.hideLayer || [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('savedVisualization', () => {
timerange: null,
colors: null,
hideLegend: null,
title: null,
};

it('accepts null context', () => {
Expand All @@ -50,4 +51,9 @@ describe('savedVisualization', () => {

expect(expression.input.filters).toEqual(embeddableFilters);
});

it('accepts an empty title when title is disabled', () => {
const expression = fn(null, { ...args, title: '' }, {} as any);
expect(expression.input.title).toEqual('');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface Arguments {
timerange: TimeRangeArg | null;
colors: SeriesStyle[] | null;
hideLegend: boolean | null;
title: string | null;
}

type Output = EmbeddableExpression<VisualizeInput>;
Expand Down Expand Up @@ -61,9 +62,14 @@ export function savedVisualization(): ExpressionFunctionDefinition<
help: argHelp.hideLegend,
required: false,
},
title: {
types: ['string'],
help: argHelp.title,
required: false,
},
},
type: EmbeddableExpressionType,
fn: (input, { id, timerange, colors, hideLegend }) => {
fn: (input, { id, timerange, colors, hideLegend, title }) => {
const filters = input ? input.and : [];

const visOptions: VisualizeInput['vis'] = {};
Expand All @@ -90,6 +96,7 @@ export function savedVisualization(): ExpressionFunctionDefinition<
timeRange: timerange || defaultTimeRange,
filters: getQueryFilters(filters),
vis: visOptions,
title: title === null ? undefined : title,
},
embeddableType: EmbeddableTypes.visualization,
generatedAt: Date.now(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,16 @@ describe('toExpression', () => {
expect(timerangeExpression.chain[0].arguments.from[0]).toEqual(input.timeRange?.from);
expect(timerangeExpression.chain[0].arguments.to[0]).toEqual(input.timeRange?.to);
});

it('includes empty panel title', () => {
const input: SavedLensInput = {
...baseEmbeddableInput,
title: '',
};

const expression = toExpression(input);
const ast = fromExpression(expression);

expect(ast.chain[0].arguments).toHaveProperty('title', [input.title]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function toExpression(input: SavedLensInput): string {

expressionParts.push(`id="${input.id}"`);

if (input.title) {
if (input.title !== undefined) {
expressionParts.push(`title="${input.title}"`);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,16 @@ describe('toExpression', () => {
expect(timerangeExpression.chain[0].arguments.from[0]).toEqual(input.timeRange?.from);
expect(timerangeExpression.chain[0].arguments.to[0]).toEqual(input.timeRange?.to);
});

it('includes empty panel title', () => {
const input: MapEmbeddableInput = {
...baseSavedMapInput,
title: '',
};

const expression = toExpression(input);
const ast = fromExpression(expression);

expect(ast.chain[0].arguments).toHaveProperty('title', [input.title]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function toExpression(input: MapEmbeddableInput): string {
expressionParts.push('savedMap');
expressionParts.push(`id="${input.id}"`);

if (input.title) {
if (input.title !== undefined) {
expressionParts.push(`title="${input.title}"`);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,16 @@ describe('toExpression', () => {
expect(aColor?.chain[0].arguments.color[0]).toBe(colorMap.a);
expect(bColor?.chain[0].arguments.color[0]).toBe(colorMap.b);
});

it('includes empty panel title', () => {
const input = {
...baseInput,
title: '',
};

const expression = toExpression(input);
const ast = fromExpression(expression);

expect(ast.chain[0].arguments).toHaveProperty('title', [input.title]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export function toExpression(input: VisualizeInput): string {
expressionParts.push('savedVisualization');
expressionParts.push(`id="${input.id}"`);

if (input.title !== undefined) {
expressionParts.push(`title="${input.title}"`);
}

if (input.timeRange) {
expressionParts.push(
`timerange={timerange from="${input.timeRange.from}" to="${input.timeRange.to}"}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ export const help: FunctionHelp<FunctionFactory<typeof savedVisualization>> = {
defaultMessage: `Specifies the option to hide the legend`,
}
),
title: i18n.translate('xpack.canvas.functions.savedVisualization.args.titleHelpText', {
defaultMessage: `The title for the visualization object`,
}),
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { EuiConfirmModal, EuiOverlayMask } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import React, { useEffect, useState } from 'react';
import { HttpSetup } from 'kibana/public';
import { useAppDependencies } from '../app_context';

Expand All @@ -17,6 +17,7 @@ export const DeleteModalConfirmation = ({
onErrors,
singleTitle,
multipleTitle,
setIsLoadingState,
}: {
idsToDelete: string[];
apiDeleteCall: ({
Expand All @@ -31,10 +32,17 @@ export const DeleteModalConfirmation = ({
onErrors: () => void;
singleTitle: string;
multipleTitle: string;
setIsLoadingState: (isLoading: boolean) => void;
}) => {
const [deleteModalFlyoutVisible, setDeleteModalVisibility] = useState<boolean>(false);

useEffect(() => {
setDeleteModalVisibility(idsToDelete.length > 0);
}, [idsToDelete]);

const { http, toastNotifications } = useAppDependencies();
const numIdsToDelete = idsToDelete.length;
if (!numIdsToDelete) {
if (!deleteModalFlyoutVisible) {
return null;
}
const confirmModalText = i18n.translate(
Expand Down Expand Up @@ -65,12 +73,18 @@ export const DeleteModalConfirmation = ({
buttonColor="danger"
data-test-subj="deleteIdsConfirmation"
title={confirmButtonText}
onCancel={() => onCancel()}
onCancel={() => {
setDeleteModalVisibility(false);
onCancel();
}}
onConfirm={async () => {
setDeleteModalVisibility(false);
setIsLoadingState(true);
const { successes, errors } = await apiDeleteCall({ ids: idsToDelete, http });
setIsLoadingState(false);

const numSuccesses = successes.length;
const numErrors = errors.length;
onDeleted(successes);
if (numSuccesses > 0) {
toastNotifications.addSuccess(
i18n.translate(
Expand All @@ -95,8 +109,9 @@ export const DeleteModalConfirmation = ({
}
)
);
onErrors();
await onErrors();
}
await onDeleted(successes);
}}
cancelButtonText={cancelButtonText}
confirmButtonText={confirmButtonText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export const ActionsConnectorsList: React.FunctionComponent = () => {
'xpack.triggersActionsUI.sections.actionsConnectorsList.multipleTitle',
{ defaultMessage: 'connectors' }
)}
setIsLoadingState={(isLoading: boolean) => setIsLoadingActionTypes(isLoading)}
/>
<EuiSpacer size="m" />
{/* Render the view based on if there's data or if they can save */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,16 @@ export const AlertsList: React.FunctionComponent = () => {
<section data-test-subj="alertsList">
<DeleteModalConfirmation
onDeleted={async (deleted: string[]) => {
loadAlertsData();
setSelectedIds([]);
setAlertsToDelete([]);
setSelectedIds([]);
await loadAlertsData();
}}
onErrors={async () => {
// Refresh the alerts from the server, some alerts may have beend deleted
await loadAlertsData();
setAlertsToDelete([]);
}}
onCancel={async () => {
onCancel={() => {
setAlertsToDelete([]);
}}
apiDeleteCall={deleteAlerts}
Expand All @@ -424,6 +424,9 @@ export const AlertsList: React.FunctionComponent = () => {
multipleTitle={i18n.translate('xpack.triggersActionsUI.sections.alertsList.multipleTitle', {
defaultMessage: 'alerts',
})}
setIsLoadingState={(isLoading: boolean) => {
setAlertsState({ ...alertsState, isLoading });
}}
/>
<EuiSpacer size="m" />
{loadedItems.length || isFilterApplied ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
return createdAlert;
}

// FLAKY: https://github.com/elastic/kibana/issues/77401
describe.skip('alerts', function () {
describe('alerts', function () {
before(async () => {
await pageObjects.common.navigateToApp('triggersActions');
await testSubjects.click('alertsTab');
Expand Down Expand Up @@ -385,9 +384,12 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await testSubjects.click('deleteAll');
await testSubjects.existOrFail('deleteIdsConfirmation');
await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton');
await testSubjects.missingOrFail('deleteIdsConfirmation', { timeout: 5000 });
await testSubjects.missingOrFail('deleteIdsConfirmation');

await pageObjects.common.closeToast();
await retry.try(async () => {
const toastTitle = await pageObjects.common.closeToast();
expect(toastTitle).to.eql('Deleted 10 alerts');
});

await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(namePrefix);
Expand Down

0 comments on commit 11e1077

Please sign in to comment.