From f8cdd4108cd5f2b0fb9dc485a1b2402603fc0b91 Mon Sep 17 00:00:00 2001 From: Drew Tate Date: Fri, 26 May 2023 14:17:12 -0500 Subject: [PATCH] marking optional fields optional --- .../embeddable/api/overlays/save_modal.tsx | 35 ++++--------------- .../save_modal/saved_object_save_modal.tsx | 5 +++ .../saved_objects_tagging_oss/public/api.ts | 5 +++ .../utils/get_top_nav_config.tsx | 1 + ...ed_object_save_modal_dashboard_wrapper.tsx | 1 + .../xy/annotations/actions/save_action.tsx | 1 + .../public/routes/map_page/top_nav_config.tsx | 1 + .../saved_object_save_modal_tag_selector.tsx | 13 ++++++- 8 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/api/overlays/save_modal.tsx b/src/plugins/dashboard/public/dashboard_container/embeddable/api/overlays/save_modal.tsx index 21858ba0ccd42..737b8eac640f4 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/api/overlays/save_modal.tsx +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/api/overlays/save_modal.tsx @@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n'; import React, { Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; -import { EuiFormRow, EuiTextArea, EuiSwitch } from '@elastic/eui'; +import { EuiFormRow, EuiSwitch } from '@elastic/eui'; import { SavedObjectSaveModal } from '@kbn/saved-objects-plugin/public'; import type { DashboardSaveOptions } from '../../../types'; @@ -39,14 +39,12 @@ interface Props { } interface State { - description: string; tags: string[]; timeRestore: boolean; } export class DashboardSaveModal extends React.Component { state: State = { - description: this.props.description, timeRestore: this.props.timeRestore, tags: this.props.tags ?? [], }; @@ -57,18 +55,20 @@ export class DashboardSaveModal extends React.Component { saveDashboard = ({ newTitle, + newDescription, newCopyOnSave, isTitleDuplicateConfirmed, onTitleDuplicate, }: { newTitle: string; + newDescription: string; newCopyOnSave: boolean; isTitleDuplicateConfirmed: boolean; onTitleDuplicate: () => void; }) => { this.props.onSave({ newTitle, - newDescription: this.state.description, + newDescription, newCopyOnSave, newTimeRestore: this.state.timeRestore, isTitleDuplicateConfirmed, @@ -77,12 +77,6 @@ export class DashboardSaveModal extends React.Component { }); }; - onDescriptionChange = (event: any) => { - this.setState({ - description: event.target.value, - }); - }; - onTimeRestoreChange = (event: any) => { this.setState({ timeRestore: event.target.checked, @@ -102,28 +96,12 @@ export class DashboardSaveModal extends React.Component { tags, }); }} + markOptional /> ) : undefined; return ( - - } - fullWidth - > - - - {tagSelector} { onSave={this.saveDashboard} onClose={this.props.onClose} title={this.props.title} + description={this.props.description} + showDescription showCopyOnSave={this.props.showCopyOnSave} initialCopyOnSave={this.props.showCopyOnSave} objectType={i18n.translate('dashboard.topNav.saveModal.objectType', { defaultMessage: 'dashboard', })} options={this.renderDashboardSaveOptions()} - showDescription={false} /> ); } diff --git a/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.tsx b/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.tsx index c429b6ff2c918..c471271ead7ed 100644 --- a/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.tsx +++ b/src/plugins/saved_objects/public/save_modal/saved_object_save_modal.tsx @@ -194,6 +194,11 @@ export class SavedObjectSaveModal extends React.Component return ( + + + } label={ void; + + /** + * Add "Optional" to the label + */ + markOptional?: boolean; }; /** diff --git a/src/plugins/visualizations/public/visualize_app/utils/get_top_nav_config.tsx b/src/plugins/visualizations/public/visualize_app/utils/get_top_nav_config.tsx index 250f6b40c1e52..9bc781f464084 100644 --- a/src/plugins/visualizations/public/visualize_app/utils/get_top_nav_config.tsx +++ b/src/plugins/visualizations/public/visualize_app/utils/get_top_nav_config.tsx @@ -544,6 +544,7 @@ export const getTopNavConfig = ( onTagsSelected={(newSelection) => { selectedTags = newSelection; }} + markOptional /> ); } diff --git a/x-pack/plugins/lens/public/app_plugin/tags_saved_object_save_modal_dashboard_wrapper.tsx b/x-pack/plugins/lens/public/app_plugin/tags_saved_object_save_modal_dashboard_wrapper.tsx index 761f46cbbd2c9..39c2f55bdd676 100644 --- a/x-pack/plugins/lens/public/app_plugin/tags_saved_object_save_modal_dashboard_wrapper.tsx +++ b/x-pack/plugins/lens/public/app_plugin/tags_saved_object_save_modal_dashboard_wrapper.tsx @@ -43,6 +43,7 @@ export const TagEnhancedSavedObjectSaveModalDashboard: FC< ) : undefined, [savedObjectsTagging, initialTags] diff --git a/x-pack/plugins/lens/public/visualizations/xy/annotations/actions/save_action.tsx b/x-pack/plugins/lens/public/visualizations/xy/annotations/actions/save_action.tsx index 12946f996a767..0e66654af48c1 100644 --- a/x-pack/plugins/lens/public/visualizations/xy/annotations/actions/save_action.tsx +++ b/x-pack/plugins/lens/public/visualizations/xy/annotations/actions/save_action.tsx @@ -84,6 +84,7 @@ export const SaveModal = ({ ) : undefined } diff --git a/x-pack/plugins/maps/public/routes/map_page/top_nav_config.tsx b/x-pack/plugins/maps/public/routes/map_page/top_nav_config.tsx index 6bef5987dd9f8..28757b251a285 100644 --- a/x-pack/plugins/maps/public/routes/map_page/top_nav_config.tsx +++ b/x-pack/plugins/maps/public/routes/map_page/top_nav_config.tsx @@ -161,6 +161,7 @@ export function getTopNavConfig({ ) : undefined; diff --git a/x-pack/plugins/saved_objects_tagging/public/components/connected/saved_object_save_modal_tag_selector.tsx b/x-pack/plugins/saved_objects_tagging/public/components/connected/saved_object_save_modal_tag_selector.tsx index 8e86c5be4dad5..8b068453b27f7 100644 --- a/x-pack/plugins/saved_objects_tagging/public/components/connected/saved_object_save_modal_tag_selector.tsx +++ b/x-pack/plugins/saved_objects_tagging/public/components/connected/saved_object_save_modal_tag_selector.tsx @@ -7,7 +7,7 @@ import React, { FC, useCallback, useState } from 'react'; import useObservable from 'react-use/lib/useObservable'; -import { EuiFormRow } from '@elastic/eui'; +import { EuiFormRow, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { SavedObjectSaveModalTagSelectorComponentProps } from '@kbn/saved-objects-tagging-oss-plugin/public'; import { TagsCapabilities } from '../../../common'; @@ -29,6 +29,7 @@ export const getConnectedSavedObjectModalTagSelectorComponent = ({ return ({ initialSelection, onTagsSelected: notifySelectionChange, + markOptional, ...rest }: SavedObjectSaveModalTagSelectorComponentProps) => { const tags = useObservable(cache.getState$(), cache.getState()); @@ -51,6 +52,16 @@ export const getConnectedSavedObjectModalTagSelectorComponent = ({ defaultMessage="Tags" /> } + labelAppend={ + markOptional && ( + + + + ) + } >