mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Redirect Settings to the proper sub page depending on the instance type (cloud or not) (#12053)
This commit is contained in:
parent
137a1e761f
commit
7a0a9e4a7b
|
@ -14,6 +14,8 @@ const App = {
|
||||||
};
|
};
|
||||||
const renderComponent = createComponentRenderer(App);
|
const renderComponent = createComponentRenderer(App);
|
||||||
|
|
||||||
|
let settingsStore: ReturnType<typeof useSettingsStore>;
|
||||||
|
|
||||||
describe('router', () => {
|
describe('router', () => {
|
||||||
let server: ReturnType<typeof setupServer>;
|
let server: ReturnType<typeof setupServer>;
|
||||||
const initializeAuthenticatedFeaturesSpy = vi.spyOn(init, 'initializeAuthenticatedFeatures');
|
const initializeAuthenticatedFeaturesSpy = vi.spyOn(init, 'initializeAuthenticatedFeatures');
|
||||||
|
@ -28,6 +30,7 @@ describe('router', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
settingsStore = useSettingsStore();
|
||||||
initializeAuthenticatedFeaturesSpy.mockImplementation(async () => await Promise.resolve());
|
initializeAuthenticatedFeaturesSpy.mockImplementation(async () => await Promise.resolve());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -114,7 +117,6 @@ describe('router', () => {
|
||||||
])(
|
])(
|
||||||
'should resolve %s to %s with %s user permissions',
|
'should resolve %s to %s with %s user permissions',
|
||||||
async (path, name, scopes) => {
|
async (path, name, scopes) => {
|
||||||
const settingsStore = useSettingsStore();
|
|
||||||
const rbacStore = useRBACStore();
|
const rbacStore = useRBACStore();
|
||||||
|
|
||||||
settingsStore.settings.communityNodesEnabled = true;
|
settingsStore.settings.communityNodesEnabled = true;
|
||||||
|
@ -126,4 +128,13 @@ describe('router', () => {
|
||||||
},
|
},
|
||||||
10000,
|
10000,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test.each([
|
||||||
|
[VIEWS.PERSONAL_SETTINGS, true],
|
||||||
|
[VIEWS.USAGE, false],
|
||||||
|
])('should redirect Settings to %s', async (name, hideUsagePage) => {
|
||||||
|
settingsStore.settings.hideUsagePage = hideUsagePage;
|
||||||
|
await router.push('/settings');
|
||||||
|
expect(router.currentRoute.value.name).toBe(name);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -483,7 +483,13 @@ export const routes: RouteRecordRaw[] = [
|
||||||
name: VIEWS.SETTINGS,
|
name: VIEWS.SETTINGS,
|
||||||
component: SettingsView,
|
component: SettingsView,
|
||||||
props: true,
|
props: true,
|
||||||
redirect: { name: VIEWS.USAGE },
|
redirect: () => {
|
||||||
|
const settingsStore = useSettingsStore();
|
||||||
|
if (settingsStore.settings.hideUsagePage) {
|
||||||
|
return { name: VIEWS.PERSONAL_SETTINGS };
|
||||||
|
}
|
||||||
|
return { name: VIEWS.USAGE };
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'usage',
|
path: 'usage',
|
||||||
|
|
|
@ -50,7 +50,7 @@ const router = createRouter({
|
||||||
name: VIEWS.SETTINGS,
|
name: VIEWS.SETTINGS,
|
||||||
component: SettingsView,
|
component: SettingsView,
|
||||||
props: true,
|
props: true,
|
||||||
redirect: { name: VIEWS.USAGE },
|
redirect: { name: VIEWS.PERSONAL_SETTINGS },
|
||||||
children: settingsRouteChildren,
|
children: settingsRouteChildren,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue