Skip to content

Commit

Permalink
refactor: move cloud dashboard admin to sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutasem Aldmour authored and Mutasem Aldmour committed Nov 17, 2023
1 parent 0c60f4b commit fb97e8d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 62 deletions.
12 changes: 12 additions & 0 deletions packages/editor-ui/src/components/MainSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ export default defineComponent({
this.settingsStore.isQueueModeEnabled && this.settingsStore.isWorkerViewAvailable,
activateOnRouteNames: [VIEWS.WORKER_VIEW],
},
{
id: 'cloud-admin',
type: 'link',
position: 'bottom',
label: 'Admin Panel',
icon: 'home',
available: this.settingsStore.isCloudDeployment && this.usersStore.isInstanceOwner,
},
{
id: 'settings',
icon: 'cog',
Expand Down Expand Up @@ -461,6 +469,10 @@ export default defineComponent({
this.uiStore.openModal(ABOUT_MODAL_KEY);
break;
}
case 'cloud-admin': {
this.cloudPlanStore.redirectToDashboard();
break;
}
case 'quickstart':
case 'docs':
case 'forum':
Expand Down
8 changes: 1 addition & 7 deletions packages/editor-ui/src/hooks/cloud.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hooksAddAdminIcon, hooksAddFakeDoorFeatures } from '@/hooks/utils';
import { hooksAddFakeDoorFeatures } from '@/hooks/utils';
import {
getAuthenticationModalEventData,
getExpressionEditorEventsData,
Expand Down Expand Up @@ -29,9 +29,6 @@ import type { ExternalHooks } from '@/types';
export const n8nCloudHooks: PartialDeep<ExternalHooks> = {
app: {
mount: [
() => {
hooksAddAdminIcon();
},
() => {
hooksAddFakeDoorFeatures();
},
Expand All @@ -43,9 +40,6 @@ export const n8nCloudHooks: PartialDeep<ExternalHooks> = {
const segmentStore = useSegment();
segmentStore.identify();
},
() => {
hooksAddAdminIcon();
},
],
createNodeActiveChanged: [
(_, meta) => {
Expand Down
38 changes: 0 additions & 38 deletions packages/editor-ui/src/hooks/utils/hooksAddAdminIcon.ts

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions packages/editor-ui/src/hooks/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from './hooksAddAdminIcon';
export * from './hooksAddAutoLoginToAdminPanelButton';
export * from './hooksAddFakeDoorFeatures';
export * from './hooksNodesPanel';
7 changes: 7 additions & 0 deletions packages/editor-ui/src/stores/cloudPlan.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ export const useCloudPlanStore = defineStore(STORES.CLOUD_PLAN, () => {
} catch {}
};

const redirectToDashboard = async () => {
const adminPanelHost = new URL(window.location.href).host.split('.').slice(1).join('.');
const { code } = await getAutoLoginCode();
window.location.href = `https://${adminPanelHost}/login?code=${code}`;
};

return {
state,
getOwnerCurrentPlan,
Expand All @@ -166,5 +172,6 @@ export const useCloudPlanStore = defineStore(STORES.CLOUD_PLAN, () => {
checkForCloudPlanData,
fetchUserCloudAccount,
getAutoLoginCode,
redirectToDashboard,
};
});

0 comments on commit fb97e8d

Please sign in to comment.