Skip to content

Commit

Permalink
Merge branch 'workspace' into feature/delete_from_workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Hailong-am authored Aug 17, 2023
2 parents 061e482 + d732833 commit 9a578e4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 52 deletions.
1 change: 1 addition & 0 deletions src/core/public/workspace/workspaces_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ export class WorkspaceService implements CoreService<WorkspaceSetup, WorkspaceSt
this.currentWorkspace$.unsubscribe();
this.currentWorkspaceId$.unsubscribe();
this.workspaceList$.unsubscribe();
this.workspaceEnabled$.unsubscribe();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ export const WorkspaceUpdater = () => {
defaultMessage: 'Delete workspace successfully',
}),
});
setDeleteWorkspaceModalVisible(false);
if (http && application) {
const homeUrl = application.getUrlForApp('home', {
path: '/',
absolute: false,
});
const targetUrl = http.basePath.prepend(http.basePath.remove(homeUrl), {
withoutWorkspace: true,
});
await application.navigateToUrl(targetUrl);
}
} else {
notifications?.toasts.addDanger({
title: i18n.translate('workspace.delete.failed', {
Expand All @@ -126,17 +137,6 @@ export const WorkspaceUpdater = () => {
});
}
}
setDeleteWorkspaceModalVisible(false);
if (http && application && result?.success) {
const homeUrl = application.getUrlForApp('home', {
path: '/',
absolute: false,
});
const targetUrl = http.basePath.prepend(http.basePath.remove(homeUrl), {
withoutWorkspace: true,
});
await application.navigateToUrl(targetUrl);
}
};

const exitWorkspace = async () => {
Expand All @@ -152,7 +152,18 @@ export const WorkspaceUpdater = () => {
});
return;
}
if (!result?.success) {
if (result.success) {
if (http && application) {
const homeUrl = application.getUrlForApp('home', {
path: '/',
absolute: false,
});
const targetUrl = http.basePath.prepend(http.basePath.remove(homeUrl), {
withoutWorkspace: true,
});
await application.navigateToUrl(targetUrl);
}
} else {
notifications?.toasts.addDanger({
title: i18n.translate('workspace.exit.failed', {
defaultMessage: 'Failed to exit workspace',
Expand All @@ -161,16 +172,6 @@ export const WorkspaceUpdater = () => {
});
return;
}
if (http && application) {
const homeUrl = application.getUrlForApp('home', {
path: '/',
absolute: false,
});
const targetUrl = http.basePath.prepend(http.basePath.remove(homeUrl), {
withoutWorkspace: true,
});
await application.navigateToUrl(targetUrl);
}
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,15 @@ export class WorkspaceSavedObjectsClientWrapper {
if (!workspaceId) {
return;
}
if (
!(await this.permissionControl.validate(
request,
{
type: WORKSPACE_TYPE,
id: workspaceId,
},
this.formatWorkspacePermissionModeToStringArray(permissionMode)
))
) {
const validateResult = await this.permissionControl.validate(
request,
{
type: WORKSPACE_TYPE,
id: workspaceId,
},
this.formatWorkspacePermissionModeToStringArray(permissionMode)
);
if (!validateResult?.result) {
throw generateWorkspacePermissionError();
}
}
Expand All @@ -97,16 +96,15 @@ export class WorkspaceSavedObjectsClientWrapper {
return;
}
for (const workspaceId of workspaces) {
if (
!(await this.permissionControl.validate(
request,
{
type: WORKSPACE_TYPE,
id: workspaceId,
},
this.formatWorkspacePermissionModeToStringArray(permissionMode)
))
) {
const validateResult = await this.permissionControl.validate(
request,
{
type: WORKSPACE_TYPE,
id: workspaceId,
},
this.formatWorkspacePermissionModeToStringArray(permissionMode)
);
if (!validateResult?.result) {
throw generateWorkspacePermissionError();
}
}
Expand All @@ -122,16 +120,15 @@ export class WorkspaceSavedObjectsClientWrapper {
}
let permitted = false;
for (const workspaceId of workspaces) {
if (
await this.permissionControl.validate(
request,
{
type: WORKSPACE_TYPE,
id: workspaceId,
},
this.formatWorkspacePermissionModeToStringArray(permissionMode)
)
) {
const validateResult = await this.permissionControl.validate(
request,
{
type: WORKSPACE_TYPE,
id: workspaceId,
},
this.formatWorkspacePermissionModeToStringArray(permissionMode)
);
if (validateResult?.result) {
permitted = true;
break;
}
Expand Down

0 comments on commit 9a578e4

Please sign in to comment.