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
72e6343964
commit
a16d006f89
|
@ -14,6 +14,8 @@ const App = {
|
|||
};
|
||||
const renderComponent = createComponentRenderer(App);
|
||||
|
||||
let settingsStore: ReturnType<typeof useSettingsStore>;
|
||||
|
||||
describe('router', () => {
|
||||
let server: ReturnType<typeof setupServer>;
|
||||
const initializeAuthenticatedFeaturesSpy = vi.spyOn(init, 'initializeAuthenticatedFeatures');
|
||||
|
@ -28,6 +30,7 @@ describe('router', () => {
|
|||
});
|
||||
|
||||
beforeEach(() => {
|
||||
settingsStore = useSettingsStore();
|
||||
initializeAuthenticatedFeaturesSpy.mockImplementation(async () => await Promise.resolve());
|
||||
});
|
||||
|
||||
|
@ -114,7 +117,6 @@ describe('router', () => {
|
|||
])(
|
||||
'should resolve %s to %s with %s user permissions',
|
||||
async (path, name, scopes) => {
|
||||
const settingsStore = useSettingsStore();
|
||||
const rbacStore = useRBACStore();
|
||||
|
||||
settingsStore.settings.communityNodesEnabled = true;
|
||||
|
@ -126,4 +128,13 @@ describe('router', () => {
|
|||
},
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -482,7 +482,13 @@ export const routes: RouteRecordRaw[] = [
|
|||
name: VIEWS.SETTINGS,
|
||||
component: SettingsView,
|
||||
props: true,
|
||||
redirect: { name: VIEWS.USAGE },
|
||||
redirect: () => {
|
||||
const settingsStore = useSettingsStore();
|
||||
if (settingsStore.settings.hideUsagePage) {
|
||||
return { name: VIEWS.PERSONAL_SETTINGS };
|
||||
}
|
||||
return { name: VIEWS.USAGE };
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'usage',
|
||||
|
|
|
@ -50,7 +50,7 @@ const router = createRouter({
|
|||
name: VIEWS.SETTINGS,
|
||||
component: SettingsView,
|
||||
props: true,
|
||||
redirect: { name: VIEWS.USAGE },
|
||||
redirect: { name: VIEWS.PERSONAL_SETTINGS },
|
||||
children: settingsRouteChildren,
|
||||
},
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue