diff --git a/changelogs/fragments/7627.yml b/changelogs/fragments/7627.yml new file mode 100644 index 000000000000..8b5a7e830062 --- /dev/null +++ b/changelogs/fragments/7627.yml @@ -0,0 +1,2 @@ +feat: +- [Workspace] Set default color for workspace create form ([#7627](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7627)) \ No newline at end of file diff --git a/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx b/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx index 88c46e973c00..c46d17b701ac 100644 --- a/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx +++ b/src/plugins/workspace/public/components/workspace_creator/workspace_creator.tsx @@ -4,7 +4,13 @@ */ import React, { useCallback } from 'react'; -import { EuiPage, EuiPageBody, EuiPageHeader, EuiPageContent } from '@elastic/eui'; +import { + EuiPage, + EuiPageBody, + EuiPageHeader, + EuiPageContent, + euiPaletteColorBlind, +} from '@elastic/eui'; import { i18n } from '@osd/i18n'; import { useObservable } from 'react-use'; import { BehaviorSubject } from 'rxjs'; @@ -18,6 +24,7 @@ import { convertPermissionSettingsToPermissions } from '../workspace_form'; import { DataSource } from '../../../common/types'; import { DataSourceManagementPluginSetup } from '../../../../../plugins/data_source_management/public'; import { WorkspaceUseCase } from '../../types'; +import { WorkspaceFormData } from '../workspace_form/types'; export interface WorkspaceCreatorProps { registeredUseCases$: BehaviorSubject; @@ -37,6 +44,11 @@ export const WorkspaceCreator = (props: WorkspaceCreatorProps) => { workspaceClient: WorkspaceClient; dataSourceManagement?: DataSourceManagementPluginSetup; }>(); + + const defaultWorkspaceFormValues: Partial = { + color: euiPaletteColorBlind()[0], + }; + const isPermissionEnabled = application?.capabilities.workspaces.permissionEnabled; const availableUseCases = useObservable(props.registeredUseCases$, []); @@ -107,6 +119,7 @@ export const WorkspaceCreator = (props: WorkspaceCreatorProps) => { permissionEnabled={isPermissionEnabled} dataSourceManagement={dataSourceManagement} availableUseCases={availableUseCases} + defaultValues={defaultWorkspaceFormValues} /> )} diff --git a/src/plugins/workspace/public/components/workspace_form/types.ts b/src/plugins/workspace/public/components/workspace_form/types.ts index 0e2ab1631fc9..3347b339321c 100644 --- a/src/plugins/workspace/public/components/workspace_form/types.ts +++ b/src/plugins/workspace/public/components/workspace_form/types.ts @@ -79,10 +79,14 @@ export interface WorkspaceFormProps { application: ApplicationStart; savedObjects: SavedObjectsStart; onSubmit?: (formData: WorkspaceFormSubmitData) => void; - defaultValues?: WorkspaceFormData; + defaultValues?: Partial; operationType: WorkspaceOperationType; permissionEnabled?: boolean; detailTab?: DetailTab; dataSourceManagement?: DataSourceManagementPluginSetup; availableUseCases: WorkspaceUseCase[]; } + +export interface WorkspaceDetailedFormProps extends WorkspaceFormProps { + defaultValues?: WorkspaceFormData; +} diff --git a/src/plugins/workspace/public/components/workspace_form/utils.ts b/src/plugins/workspace/public/components/workspace_form/utils.ts index 7588178d8c94..fc771242e8b6 100644 --- a/src/plugins/workspace/public/components/workspace_form/utils.ts +++ b/src/plugins/workspace/public/components/workspace_form/utils.ts @@ -449,12 +449,12 @@ const isSamePermissionSetting = (a: PermissionSettingLike, b: PermissionSettingL }; export const getNumberOfChanges = ( - newFormData: Omit, 'permissionSettings'> & { + newFormData: Partial> & { permissionSettings?: Array< Pick & Partial >; }, - initialFormData: Omit + initialFormData: Partial> ) => { let count = 0; if (newFormData.name !== initialFormData.name) { diff --git a/src/plugins/workspace/public/components/workspace_form/workspace_detail_form.tsx b/src/plugins/workspace/public/components/workspace_form/workspace_detail_form.tsx index 3834e7a23628..90ea5ed193ed 100644 --- a/src/plugins/workspace/public/components/workspace_form/workspace_detail_form.tsx +++ b/src/plugins/workspace/public/components/workspace_form/workspace_detail_form.tsx @@ -8,7 +8,7 @@ import React, { useRef } from 'react'; import { EuiPanel, EuiSpacer, EuiForm, EuiFlexGroup, EuiFlexItem, EuiTitle } from '@elastic/eui'; import { WorkspaceBottomBar } from './workspace_bottom_bar'; -import { WorkspaceFormProps } from './types'; +import { WorkspaceDetailedFormProps } from './types'; import { useWorkspaceForm } from './use_workspace_form'; import { WorkspaceUseCase } from './workspace_use_case'; import { WorkspacePermissionSettingPanel } from './workspace_permission_setting_panel'; @@ -41,7 +41,7 @@ const FormGroup = ({ title, children }: FormGroupProps) => ( ); -export const WorkspaceDetailForm = (props: WorkspaceFormProps) => { +export const WorkspaceDetailForm = (props: WorkspaceDetailedFormProps) => { const { detailTab, application,