Skip to content

Commit

Permalink
Changed copy on save button and save modal return switch for edits in…
Browse files Browse the repository at this point in the history
… by value mode
  • Loading branch information
ThomThomson committed Sep 21, 2020
1 parent fdd75b7 commit d08ff4e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/plugins/dashboard/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { schema, TypeOf } from '@kbn/config-schema';

export const configSchema = schema.object({
allowByValueEmbeddables: schema.boolean({ defaultValue: false }),
allowByValueEmbeddables: schema.boolean({ defaultValue: true }),
});

export type ConfigSchema = TypeOf<typeof configSchema>;
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface OriginSaveModalProps {
originatingApp?: string;
getAppNameFromId?: (appId: string) => string | undefined;
originatingAppName?: string;
returnToOriginSwitchLabel?: string;
documentInfo: SaveModalDocumentInfo;
objectType: string;
onClose: () => void;
Expand Down Expand Up @@ -74,11 +75,13 @@ export function SavedObjectSaveModalOrigin(props: OriginSaveModalProps) {
setReturnToOriginMode(event.target.checked);
}}
label={
<FormattedMessage
id="savedObjects.saveModalOrigin.originAfterSavingSwitchLabel"
defaultMessage="{originVerb} to {origin} after saving"
values={{ originVerb, origin }}
/>
props.returnToOriginSwitchLabel ?? (
<FormattedMessage
id="savedObjects.saveModalOrigin.originAfterSavingSwitchLabel"
defaultMessage="{originVerb} to {origin} after saving"
values={{ originVerb, origin }}
/>
)
}
/>
</EuiFormRow>
Expand Down
27 changes: 22 additions & 5 deletions x-pack/plugins/lens/public/app_plugin/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ export function App({
[lastKnownDoc]
);

const getIsByValueMode = useCallback(
() =>
Boolean(
// Temporarily required until the 'by value' paradigm is default.
dashboardFeatureFlag.allowByValueEmbeddables &&
state.isLinkedToOriginatingApp &&
!(initialInput as LensByReferenceInput)?.savedObjectId
),
[dashboardFeatureFlag.allowByValueEmbeddables, state.isLinkedToOriginatingApp, initialInput]
);

useEffect(() => {
// Clear app-specific filters when navigating to Lens. Necessary because Lens
// can be loaded without a full page refresh
Expand Down Expand Up @@ -208,11 +219,7 @@ export function App({

// Sync Kibana breadcrumbs any time the saved document's title changes
useEffect(() => {
const isByValueMode =
// Temporarily required until the 'by value' paradigm is default.
dashboardFeatureFlag.allowByValueEmbeddables &&
state.isLinkedToOriginatingApp &&
!(initialInput as LensByReferenceInput)?.savedObjectId;
const isByValueMode = getIsByValueMode();
const breadcrumbs: EuiBreadcrumb[] = [];
if (state.isLinkedToOriginatingApp && getOriginatingAppName() && redirectToOrigin) {
breadcrumbs.push({
Expand Down Expand Up @@ -250,6 +257,7 @@ export function App({
getOriginatingAppName,
state.persistedDoc,
redirectToOrigin,
getIsByValueMode,
initialInput,
application,
chrome,
Expand Down Expand Up @@ -436,6 +444,7 @@ export function App({
// Temporarily required until the 'by value' paradigm is default.
(dashboardFeatureFlag.allowByValueEmbeddables || Boolean(initialInput))
),
isByValueMode: getIsByValueMode(),
showCancel: Boolean(state.isLinkedToOriginatingApp),
savingPermitted,
actions: {
Expand Down Expand Up @@ -598,6 +607,14 @@ export function App({
title: lastKnownDoc.title || '',
description: lastKnownDoc.description || '',
}}
returnToOriginSwitchLabel={
getIsByValueMode() && initialInput
? i18n.translate('xpack.lens.app.updatePanel', {
defaultMessage: 'Update panel on {originatingAppName}',
values: { originatingAppName: getOriginatingAppName() },
})
: undefined
}
objectType={i18n.translate('xpack.lens.app.saveModalType', {
defaultMessage: 'Lens visualization',
})}
Expand Down
22 changes: 15 additions & 7 deletions x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@ import { LensTopNavActions } from './types';
export function getLensTopNavConfig(options: {
showSaveAndReturn: boolean;
showCancel: boolean;
isByValueMode: boolean;
actions: LensTopNavActions;
savingPermitted: boolean;
}): TopNavMenuData[] {
const { showSaveAndReturn, showCancel, actions, savingPermitted } = options;
const topNavMenu: TopNavMenuData[] = [];

const saveButtonLabel = options.isByValueMode
? i18n.translate('xpack.lens.app.addToLibrary', {
defaultMessage: 'Save to library',
})
: options.showSaveAndReturn
? i18n.translate('xpack.lens.app.saveAs', {
defaultMessage: 'Save as',
})
: i18n.translate('xpack.lens.app.save', {
defaultMessage: 'Save',
});

if (showSaveAndReturn) {
topNavMenu.push({
label: i18n.translate('xpack.lens.app.saveAndReturn', {
Expand All @@ -33,13 +47,7 @@ export function getLensTopNavConfig(options: {
}

topNavMenu.push({
label: showSaveAndReturn
? i18n.translate('xpack.lens.app.saveAs', {
defaultMessage: 'Save as',
})
: i18n.translate('xpack.lens.app.save', {
defaultMessage: 'Save',
}),
label: saveButtonLabel,
emphasize: !showSaveAndReturn,
run: actions.showSaveModal,
testId: 'lnsApp_saveButton',
Expand Down

0 comments on commit d08ff4e

Please sign in to comment.