Skip to content

Commit

Permalink
feat: optimize code
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Oct 7, 2023
1 parent 7a4a79b commit a52f4dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
8 changes: 1 addition & 7 deletions src/core/public/workspace/workspaces_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ import { HttpSetup } from '../http';
*/
export interface WorkspacesStart {
client: WorkspacesClientContract;
formatUrlWithWorkspaceId: (
url: string,
id: WorkspaceAttribute['id'],
options?: {
jumpable?: boolean;
}
) => string;
formatUrlWithWorkspaceId: (url: string, id: WorkspaceAttribute['id']) => string;
setFormatUrlWithWorkspaceId: (formatFn: WorkspacesStart['formatUrlWithWorkspaceId']) => void;
}

Expand Down
12 changes: 2 additions & 10 deletions src/plugins/workspace/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ export class WorkspacesPlugin implements Plugin<{}, {}> {
private getWorkpsaceIdFromURL(): string | null {
return getWorkspaceIdFromUrl(window.location.href);
}
private getPatchedUrl = (
url: string,
workspaceId: string,
options?: {
jumpable?: boolean;
}
) => {
private getPatchedUrl = (url: string, workspaceId: string) => {
const newUrl = new URL(url, window.location.href);
/**
* Patch workspace id into path
Expand All @@ -44,9 +38,7 @@ export class WorkspacesPlugin implements Plugin<{}, {}> {
};
public async setup(core: CoreSetup) {
this.core = core;
this.core?.workspaces.setFormatUrlWithWorkspaceId((url, id, options) =>
this.getPatchedUrl(url, id, options)
);
this.core?.workspaces.setFormatUrlWithWorkspaceId((url, id) => this.getPatchedUrl(url, id));
/**
* Retrive workspace id from url
*/
Expand Down

0 comments on commit a52f4dd

Please sign in to comment.