Skip to content

Commit

Permalink
feat: change to workspaceless
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Apr 8, 2024
1 parent 1740543 commit c4a3d0d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 32 deletions.
8 changes: 3 additions & 5 deletions src/core/public/application/application_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,12 @@ export class ApplicationService {

if (shouldNavigate) {
const targetApp = applications$.value.get(appId);
if (
workspaces.currentWorkspaceId$.value &&
targetApp?.visibility === AppVisibility.homeOnly
) {
// If user is inside a workspace and the target app is homeOnly
if (workspaces.currentWorkspaceId$.value && targetApp?.workspaceless) {
// If user is inside a workspace and the target app is workspaceless
// refresh the page by doing a hard navigation
window.location.assign(
http.basePath.prepend(getAppUrl(availableMounters, appId, path), {
// Set withoutClientBasePath to true remove the workspace path prefix
withoutClientBasePath: true,
})
);
Expand Down
27 changes: 2 additions & 25 deletions src/core/public/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,6 @@ export enum AppNavLinkStatus {
hidden = 3,
}

/**
* Visibilities of the application
*
* @public
*/
export enum AppVisibility {
/**
* The application visibility will be `both` if the application's {@link AppVisibility} is set to `default` or not set
* which means the application is visible within / out of workspace.
*/
default = 0,
/**
* The application is only visible when user is inside a workspace.
*/
workspaceOnly = 1,
/**
* The application is only visible when user is not in any workspace.
*/
homeOnly = 2,
}

/**
* Defines the list of fields that can be updated via an {@link AppUpdater}.
* @public
Expand Down Expand Up @@ -268,11 +247,9 @@ export interface App<HistoryLocationState = unknown> {
exactRoute?: boolean;

/**
* The visibility of the application based on workspace.
* Defaulting to `both`
* See {@link AppVisibility}
* Prevent the page to be accessible when inside a workspace. Defaults to `false`.
*/
visibility?: AppVisibility;
workspaceless?: boolean;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/nav_links/to_nav_link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { appendAppPath } from '../../application/utils';
export function toNavLink(app: PublicAppInfo, basePath: IBasePath): NavLinkWrapper {
const useAppStatus = app.navLinkStatus === AppNavLinkStatus.default;
let relativeBaseUrl = basePath.prepend(app.appRoute!);
if (app.visibility === AppVisibility.homeOnly) {
if (app.workspaceless) {
relativeBaseUrl = basePath.prepend(app.appRoute!, { withoutClientBasePath: true });
}
const url = relativeToAbsolute(appendAppPath(relativeBaseUrl, app.defaultPath));
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/home/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class HomePublicPlugin
const { renderApp } = await import('./application');
return await renderApp(params.element, coreStart, params.history);
},
visibility: AppVisibility.homeOnly,
workspaceless: true,
});
urlForwarding.forwardApp('home', 'home');

Expand Down

0 comments on commit c4a3d0d

Please sign in to comment.