Skip to content

Commit

Permalink
[Workspace]Remove default appended features (#7841)
Browse files Browse the repository at this point in the history
* Remove workspace_detail from default append features

Signed-off-by: Lin Wang <wonglam@amazon.com>

* Changeset file for PR #7841 created/updated

---------

Signed-off-by: Lin Wang <wonglam@amazon.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
wanglam and opensearch-changeset-bot[bot] authored Aug 26, 2024
1 parent 452b65d commit ca66127
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 23 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7841.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [Workspace]Remove default appended features ([#7841](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7841))
5 changes: 0 additions & 5 deletions src/plugins/workspace/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ export const WORKSPACE_DETAIL_APP_ID = 'workspace_detail';
export const WORKSPACE_INITIAL_APP_ID = 'workspace_initial';
export const WORKSPACE_NAVIGATION_APP_ID = 'workspace_navigation';

/**
* Since every workspace always have overview and update page, these features will be selected by default
* and can't be changed in the workspace form feature selector
*/
export const DEFAULT_SELECTED_FEATURES_IDS = [WORKSPACE_DETAIL_APP_ID];
export const WORKSPACE_SAVED_OBJECTS_CLIENT_WRAPPER_ID = 'workspace';
export const WORKSPACE_CONFLICT_CONTROL_SAVED_OBJECTS_CLIENT_WRAPPER_ID =
'workspace_conflict_control';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('useWorkspaceForm', () => {
expect(onSubmitMock).toHaveBeenCalledWith(
expect.objectContaining({
name: 'test-workspace-name',
features: ['use-case-observability', 'workspace_detail'],
features: ['use-case-observability'],
})
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import { DataSource } from '../../../common/types';
import { WorkspaceFormProps, WorkspaceFormErrors, WorkspacePermissionSetting } from './types';
import {
appendDefaultFeatureIds,
generatePermissionSettingsState,
getNumberOfChanges,
getNumberOfErrors,
Expand All @@ -42,9 +41,7 @@ export const useWorkspaceForm = ({
generatePermissionSettingsState(operationType, defaultValues?.permissionSettings)
);

const [featureConfigs, setFeatureConfigs] = useState(
appendDefaultFeatureIds(defaultValues?.features ?? [])
);
const [featureConfigs, setFeatureConfigs] = useState<string[]>(defaultValues?.features ?? []);
const selectedUseCase = useMemo(() => getFirstUseCaseOfFeatureConfigs(featureConfigs), [
featureConfigs,
]);
Expand Down Expand Up @@ -138,7 +135,7 @@ export const useWorkspaceForm = ({
setName(resetValues?.name ?? '');
setDescription(resetValues?.description ?? '');
setColor(resetValues?.color);
setFeatureConfigs(appendDefaultFeatureIds(resetValues?.features ?? []));
setFeatureConfigs(resetValues?.features ?? []);
setPermissionSettings(initialPermissionSettingsRef.current);
setFormErrors({});
setIsEditing(false);
Expand Down
11 changes: 1 addition & 10 deletions src/plugins/workspace/public/components/workspace_form/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
import { i18n } from '@osd/i18n';

import type { SavedObjectPermissions } from '../../../../../core/types';
import {
CURRENT_USER_PLACEHOLDER,
DEFAULT_SELECTED_FEATURES_IDS,
WorkspacePermissionMode,
} from '../../../common/constants';
import { CURRENT_USER_PLACEHOLDER, WorkspacePermissionMode } from '../../../common/constants';
import { isUseCaseFeatureConfig } from '../../utils';
import {
optionIdToWorkspacePermissionModesMap,
Expand All @@ -32,11 +28,6 @@ import {
import { DataSource } from '../../../common/types';
import { validateWorkspaceColor } from '../../../common/utils';

export const appendDefaultFeatureIds = (ids: string[]) => {
// concat default checked ids and unique the result
return Array.from(new Set(ids.concat(DEFAULT_SELECTED_FEATURES_IDS)));
};

export const isValidFormTextInput = (input?: string) => {
/**
* This regular expression is from the workspace form name and description field UI.
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/workspace/public/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
WorkspaceObject,
WorkspaceAvailability,
} from '../../../core/public';
import { DEFAULT_SELECTED_FEATURES_IDS, WORKSPACE_DETAIL_APP_ID } from '../common/constants';
import { WORKSPACE_DETAIL_APP_ID } from '../common/constants';
import { WorkspaceUseCase, WorkspaceUseCaseFeature } from './types';
import { formatUrlWithWorkspaceId } from '../../../core/public/utils';
import { SigV4ServiceName } from '../../../plugins/data_source/common/data_sources';
Expand Down Expand Up @@ -188,7 +188,6 @@ export const filterWorkspaceConfigurableApps = (applications: PublicAppInfo[]) =
const filterCondition =
navLinkStatus !== AppNavLinkStatus.hidden &&
!chromeless &&
!DEFAULT_SELECTED_FEATURES_IDS.includes(id) &&
workspaceAvailability !== WorkspaceAvailability.outsideWorkspace;
// If the category is management, only retain Dashboards Management which contains saved objets and index patterns.
// Saved objets can show all saved objects in the current workspace and index patterns is at workspace level.
Expand Down

0 comments on commit ca66127

Please sign in to comment.