fix(editor): Fix Admin panel icon in the sidebar for cloud deployments (no-changelog) (#7738)
Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Mutasem Aldmour <mutasem@n8n.io>
This commit is contained in:
committed by
GitHub
parent
b66b8c18e9
commit
2d039010db
@@ -1,4 +1,4 @@
|
||||
import { hooksAddAdminIcon, hooksAddFakeDoorFeatures } from '@/hooks/utils';
|
||||
import { hooksAddFakeDoorFeatures } from '@/hooks/utils';
|
||||
import {
|
||||
getAuthenticationModalEventData,
|
||||
getExpressionEditorEventsData,
|
||||
@@ -29,9 +29,6 @@ import type { ExternalHooks } from '@/types';
|
||||
export const n8nCloudHooks: PartialDeep<ExternalHooks> = {
|
||||
app: {
|
||||
mount: [
|
||||
() => {
|
||||
hooksAddAdminIcon();
|
||||
},
|
||||
() => {
|
||||
hooksAddFakeDoorFeatures();
|
||||
},
|
||||
@@ -43,9 +40,6 @@ export const n8nCloudHooks: PartialDeep<ExternalHooks> = {
|
||||
const segmentStore = useSegment();
|
||||
segmentStore.identify();
|
||||
},
|
||||
() => {
|
||||
hooksAddAdminIcon();
|
||||
},
|
||||
],
|
||||
createNodeActiveChanged: [
|
||||
(_, meta) => {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import type { IMenuItem } from 'n8n-design-system/types';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { addAutoLoginToAdminPanelButton } from '@/hooks/utils/hooksAddAutoLoginToAdminPanelButton';
|
||||
|
||||
let adminIconAdded = false;
|
||||
|
||||
export const hooksAddAdminIcon = () => {
|
||||
if (adminIconAdded) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uiStore = useUIStore();
|
||||
const usersStore = useUsersStore();
|
||||
|
||||
if (usersStore?.globalRoleName !== 'owner') {
|
||||
return;
|
||||
}
|
||||
|
||||
const menuItems: IMenuItem[] = [
|
||||
{
|
||||
id: 'admin',
|
||||
type: 'link',
|
||||
position: 'bottom',
|
||||
label: 'Admin Panel',
|
||||
icon: 'home',
|
||||
properties: {
|
||||
href: 'https://app.n8n.cloud',
|
||||
newWindow: false,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
addAutoLoginToAdminPanelButton();
|
||||
|
||||
uiStore.sidebarMenuItems = [...uiStore.sidebarMenuItems, ...menuItems] as IMenuItem[];
|
||||
adminIconAdded = true;
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
export function addAutoLoginToAdminPanelButton() {
|
||||
const adminPanelHost = new URL(window.location.href).host.split('.').slice(1).join('.');
|
||||
|
||||
document.body?.addEventListener('click', async (e) => {
|
||||
if (!e.target || !(e.target instanceof Element)) return;
|
||||
if (e.target.getAttribute('id') !== 'admin' && !e.target.closest('#admin')) return;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
const restPath = window.REST_ENDPOINT ?? 'rest';
|
||||
const response = await fetch(`/${restPath}/cloud/proxy/login/code`);
|
||||
const { code } = await response.json();
|
||||
window.location.href = `https://${adminPanelHost}/login?code=${code}`;
|
||||
});
|
||||
}
|
||||
@@ -1,4 +1,2 @@
|
||||
export * from './hooksAddAdminIcon';
|
||||
export * from './hooksAddAutoLoginToAdminPanelButton';
|
||||
export * from './hooksAddFakeDoorFeatures';
|
||||
export * from './hooksNodesPanel';
|
||||
|
||||
Reference in New Issue
Block a user