Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove management workspace #278

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/core/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ export { WorkspacesStart, WorkspacesSetup, WorkspacesService } from './workspace
export {
WorkspacePermissionMode,
PUBLIC_WORKSPACE_ID,
MANAGEMENT_WORKSPACE_ID,
WORKSPACE_TYPE,
cleanWorkspaceId,
} from '../utils';
1 change: 0 additions & 1 deletion src/core/public/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ export {
formatUrlWithWorkspaceId,
getWorkspaceIdFromUrl,
PUBLIC_WORKSPACE_ID,
MANAGEMENT_WORKSPACE_ID,
} from '../../utils';
1 change: 0 additions & 1 deletion src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ export {
DEFAULT_APP_CATEGORIES,
WorkspacePermissionMode,
PUBLIC_WORKSPACE_ID,
MANAGEMENT_WORKSPACE_ID,
WORKSPACE_TYPE,
} from '../utils';

Expand Down
2 changes: 0 additions & 2 deletions src/core/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ export enum WorkspacePermissionMode {
}

export const PUBLIC_WORKSPACE_ID = 'public';

export const MANAGEMENT_WORKSPACE_ID = 'management';
1 change: 0 additions & 1 deletion src/core/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export {
WORKSPACE_PATH_PREFIX,
WorkspacePermissionMode,
PUBLIC_WORKSPACE_ID,
MANAGEMENT_WORKSPACE_ID,
WORKSPACE_TYPE,
} from './constants';
export { getWorkspaceIdFromUrl, formatUrlWithWorkspaceId, cleanWorkspaceId } from './workspace';
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
AppNavLinkStatus,
ApplicationStart,
DEFAULT_APP_CATEGORIES,
MANAGEMENT_WORKSPACE_ID,
} from '../../../../../core/public';
import { useApplications } from '../../hooks';
import { DEFAULT_CHECKED_FEATURES_IDS } from '../../../common/constants';
Expand Down Expand Up @@ -172,17 +171,8 @@ export const WorkspaceForm = ({
const [color, setColor] = useState(defaultValues?.color);
const [icon, setIcon] = useState(defaultValues?.icon);
const [defaultVISTheme, setDefaultVISTheme] = useState(defaultValues?.defaultVISTheme);
const isEditingManagementWorkspace = defaultValues?.id === MANAGEMENT_WORKSPACE_ID;

// feature visibility section will be hidden in management workspace
// permission section will be hidden when permission is not enabled
const [selectedTab, setSelectedTab] = useState(
!isEditingManagementWorkspace
? WorkspaceFormTabs.FeatureVisibility
: permissionEnabled
? WorkspaceFormTabs.UsersAndPermissions
: WorkspaceFormTabs.NotSelected
);

const [selectedTab, setSelectedTab] = useState(WorkspaceFormTabs.FeatureVisibility);
const [numberOfErrors, setNumberOfErrors] = useState(0);
// The matched feature id list based on original feature config,
// the feature category will be expanded to list of feature ids
Expand Down Expand Up @@ -602,14 +592,12 @@ export const WorkspaceForm = ({
<EuiSpacer />

<EuiTabs>
{!isEditingManagementWorkspace && (
<EuiTab
onClick={handleTabFeatureClick}
isSelected={selectedTab === WorkspaceFormTabs.FeatureVisibility}
>
<EuiText>{featureVisibilityTitle}</EuiText>
</EuiTab>
)}
<EuiTab
onClick={handleTabFeatureClick}
isSelected={selectedTab === WorkspaceFormTabs.FeatureVisibility}
>
<EuiText>{featureVisibilityTitle}</EuiText>
</EuiTab>
{permissionEnabled && (
<EuiTab
onClick={handleTabPermissionClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import type { EuiContextMenuPanelItemDescriptor } from '@elastic/eui';
import {
ApplicationStart,
HttpSetup,
MANAGEMENT_WORKSPACE_ID,
WorkspaceAttribute,
WorkspacesStart,
} from '../../../../../core/public';
Expand All @@ -46,10 +45,7 @@ function getFilteredWorkspaceList(
// list top5 workspaces except management workspace, place current workspace at the top
return [
...(currentWorkspace ? [currentWorkspace] : []),
...workspaceList.filter(
(workspace) =>
workspace.id !== MANAGEMENT_WORKSPACE_ID && workspace.id !== currentWorkspace?.id
),
...workspaceList.filter((workspace) => workspace.id !== currentWorkspace?.id),
].slice(0, 5);
}

Expand All @@ -64,12 +60,7 @@ export const WorkspaceMenu = ({ basePath, getUrlForApp, workspaces, navigateToUr
defaultMessage: 'OpenSearch Dashboards',
}
);
const managementWorkspaceName = i18n.translate(
'core.ui.primaryNav.workspacePickerMenu.managementWorkspaceName',
{
defaultMessage: 'Management',
}
);

const filteredWorkspaceList = getFilteredWorkspaceList(workspaceList, currentWorkspace);
const currentWorkspaceName = currentWorkspace?.name ?? defaultHeaderName;

Expand Down Expand Up @@ -199,17 +190,6 @@ export const WorkspaceMenu = ({ basePath, getUrlForApp, workspaces, navigateToUr
icon: 'folderClosed',
panel: 1,
},
{
name: managementWorkspaceName,
icon: 'managementApp',
href: formatUrlWithWorkspaceId(
getUrlForApp(WORKSPACE_OVERVIEW_APP_ID, {
absolute: false,
}),
MANAGEMENT_WORKSPACE_ID,
basePath
),
},
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ describe('workspace service', () => {
})
.expect(200);
// Global and Management workspace will be created by default after workspace list API called.
yubonluo marked this conversation as resolved.
Show resolved Hide resolved
expect(listResult.body.result.total).toEqual(4);
expect(listResult.body.result.total).toEqual(3);
});
it('unable to perform operations on workspace by calling saved objects APIs', async () => {
const result = await osdTestServer.request
Expand Down Expand Up @@ -296,7 +296,7 @@ describe('workspace service', () => {
.expect(200);
expect(findResult.body.total).toEqual(0);
// Global and Management workspace will be created by default after workspace list API called.
yubonluo marked this conversation as resolved.
Show resolved Hide resolved
expect(listResult.body.result.total).toEqual(3);
expect(listResult.body.result.total).toEqual(2);
});
});
});
40 changes: 0 additions & 40 deletions src/plugins/workspace/server/workspace_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type {
import {
ACL,
DEFAULT_APP_CATEGORIES,
MANAGEMENT_WORKSPACE_ID,
PUBLIC_WORKSPACE_ID,
WORKSPACE_TYPE,
WorkspacePermissionMode,
Expand Down Expand Up @@ -223,35 +222,6 @@ export class WorkspaceClientWithSavedObject implements IWorkspaceClientImpl {
publicWorkspaceACL.getPermissions()
);
}
private async setupManagementWorkspace(savedObjectClient?: SavedObjectsClientContract) {
const managementWorkspaceACL = new ACL().addPermission(
[WorkspacePermissionMode.LibraryWrite, WorkspacePermissionMode.Write],
{
users: ['*'],
}
);
const DSM_APP_ID = 'dataSources';
const DEV_TOOLS_APP_ID = 'dev_tools';

return this.checkAndCreateWorkspace(
savedObjectClient,
MANAGEMENT_WORKSPACE_ID,
{
name: i18n.translate('workspaces.management.workspace.default.name', {
defaultMessage: 'Management',
}),
features: [
`@${DEFAULT_APP_CATEGORIES.management.id}`,
WORKSPACE_OVERVIEW_APP_ID,
WORKSPACE_UPDATE_APP_ID,
DSM_APP_ID,
DEV_TOOLS_APP_ID,
],
reserved: true,
},
managementWorkspaceACL.getPermissions()
);
}

public async setup(core: CoreSetup): Promise<IResponse<boolean>> {
this.setupDep.savedObjects.registerType(workspace);
Expand Down Expand Up @@ -335,16 +305,6 @@ export class WorkspaceClientWithSavedObject implements IWorkspaceClientImpl {
tasks.push(this.setupPublicWorkspace(scopedClientWithoutPermissionCheck));
}

/**
* Setup management workspace if management workspace can not be found
*/
const hasManagementWorkspace = savedObjects.some(
(item) => item.id === MANAGEMENT_WORKSPACE_ID
);
if (!hasManagementWorkspace) {
tasks.push(this.setupManagementWorkspace(scopedClientWithoutPermissionCheck));
}

try {
await Promise.all(tasks);
if (tasks.length) {
Expand Down
Loading