Skip to content

Commit d08ff4e

Browse files
committed
Changed copy on save button and save modal return switch for edits in by value mode
1 parent fdd75b7 commit d08ff4e

File tree

4 files changed

+46
-18
lines changed

4 files changed

+46
-18
lines changed

src/plugins/dashboard/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import { schema, TypeOf } from '@kbn/config-schema';
2121

2222
export const configSchema = schema.object({
23-
allowByValueEmbeddables: schema.boolean({ defaultValue: false }),
23+
allowByValueEmbeddables: schema.boolean({ defaultValue: true }),
2424
});
2525

2626
export type ConfigSchema = TypeOf<typeof configSchema>;

src/plugins/saved_objects/public/save_modal/saved_object_save_modal_origin.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface OriginSaveModalProps {
3434
originatingApp?: string;
3535
getAppNameFromId?: (appId: string) => string | undefined;
3636
originatingAppName?: string;
37+
returnToOriginSwitchLabel?: string;
3738
documentInfo: SaveModalDocumentInfo;
3839
objectType: string;
3940
onClose: () => void;
@@ -74,11 +75,13 @@ export function SavedObjectSaveModalOrigin(props: OriginSaveModalProps) {
7475
setReturnToOriginMode(event.target.checked);
7576
}}
7677
label={
77-
<FormattedMessage
78-
id="savedObjects.saveModalOrigin.originAfterSavingSwitchLabel"
79-
defaultMessage="{originVerb} to {origin} after saving"
80-
values={{ originVerb, origin }}
81-
/>
78+
props.returnToOriginSwitchLabel ?? (
79+
<FormattedMessage
80+
id="savedObjects.saveModalOrigin.originAfterSavingSwitchLabel"
81+
defaultMessage="{originVerb} to {origin} after saving"
82+
values={{ originVerb, origin }}
83+
/>
84+
)
8285
}
8386
/>
8487
</EuiFormRow>

x-pack/plugins/lens/public/app_plugin/app.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ export function App({
127127
[lastKnownDoc]
128128
);
129129

130+
const getIsByValueMode = useCallback(
131+
() =>
132+
Boolean(
133+
// Temporarily required until the 'by value' paradigm is default.
134+
dashboardFeatureFlag.allowByValueEmbeddables &&
135+
state.isLinkedToOriginatingApp &&
136+
!(initialInput as LensByReferenceInput)?.savedObjectId
137+
),
138+
[dashboardFeatureFlag.allowByValueEmbeddables, state.isLinkedToOriginatingApp, initialInput]
139+
);
140+
130141
useEffect(() => {
131142
// Clear app-specific filters when navigating to Lens. Necessary because Lens
132143
// can be loaded without a full page refresh
@@ -208,11 +219,7 @@ export function App({
208219

209220
// Sync Kibana breadcrumbs any time the saved document's title changes
210221
useEffect(() => {
211-
const isByValueMode =
212-
// Temporarily required until the 'by value' paradigm is default.
213-
dashboardFeatureFlag.allowByValueEmbeddables &&
214-
state.isLinkedToOriginatingApp &&
215-
!(initialInput as LensByReferenceInput)?.savedObjectId;
222+
const isByValueMode = getIsByValueMode();
216223
const breadcrumbs: EuiBreadcrumb[] = [];
217224
if (state.isLinkedToOriginatingApp && getOriginatingAppName() && redirectToOrigin) {
218225
breadcrumbs.push({
@@ -250,6 +257,7 @@ export function App({
250257
getOriginatingAppName,
251258
state.persistedDoc,
252259
redirectToOrigin,
260+
getIsByValueMode,
253261
initialInput,
254262
application,
255263
chrome,
@@ -436,6 +444,7 @@ export function App({
436444
// Temporarily required until the 'by value' paradigm is default.
437445
(dashboardFeatureFlag.allowByValueEmbeddables || Boolean(initialInput))
438446
),
447+
isByValueMode: getIsByValueMode(),
439448
showCancel: Boolean(state.isLinkedToOriginatingApp),
440449
savingPermitted,
441450
actions: {
@@ -598,6 +607,14 @@ export function App({
598607
title: lastKnownDoc.title || '',
599608
description: lastKnownDoc.description || '',
600609
}}
610+
returnToOriginSwitchLabel={
611+
getIsByValueMode() && initialInput
612+
? i18n.translate('xpack.lens.app.updatePanel', {
613+
defaultMessage: 'Update panel on {originatingAppName}',
614+
values: { originatingAppName: getOriginatingAppName() },
615+
})
616+
: undefined
617+
}
601618
objectType={i18n.translate('xpack.lens.app.saveModalType', {
602619
defaultMessage: 'Lens visualization',
603620
})}

x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,25 @@ import { LensTopNavActions } from './types';
1111
export function getLensTopNavConfig(options: {
1212
showSaveAndReturn: boolean;
1313
showCancel: boolean;
14+
isByValueMode: boolean;
1415
actions: LensTopNavActions;
1516
savingPermitted: boolean;
1617
}): TopNavMenuData[] {
1718
const { showSaveAndReturn, showCancel, actions, savingPermitted } = options;
1819
const topNavMenu: TopNavMenuData[] = [];
20+
21+
const saveButtonLabel = options.isByValueMode
22+
? i18n.translate('xpack.lens.app.addToLibrary', {
23+
defaultMessage: 'Save to library',
24+
})
25+
: options.showSaveAndReturn
26+
? i18n.translate('xpack.lens.app.saveAs', {
27+
defaultMessage: 'Save as',
28+
})
29+
: i18n.translate('xpack.lens.app.save', {
30+
defaultMessage: 'Save',
31+
});
32+
1933
if (showSaveAndReturn) {
2034
topNavMenu.push({
2135
label: i18n.translate('xpack.lens.app.saveAndReturn', {
@@ -33,13 +47,7 @@ export function getLensTopNavConfig(options: {
3347
}
3448

3549
topNavMenu.push({
36-
label: showSaveAndReturn
37-
? i18n.translate('xpack.lens.app.saveAs', {
38-
defaultMessage: 'Save as',
39-
})
40-
: i18n.translate('xpack.lens.app.save', {
41-
defaultMessage: 'Save',
42-
}),
50+
label: saveButtonLabel,
4351
emphasize: !showSaveAndReturn,
4452
run: actions.showSaveModal,
4553
testId: 'lnsApp_saveButton',

0 commit comments

Comments
 (0)