mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Show v1 banner dismiss button if owner (#7722)
Github issue / Community forum post (link here to close automatically): https://community.n8n.io/t/v1-upgrade-banner-shall-be-dismissed-permanently/32775
This commit is contained in:
parent
ce002a6cc6
commit
44d3b3ed7e
|
@ -5,8 +5,7 @@ import { useUsersStore } from '@/stores/users.store';
|
||||||
import { useUIStore } from '@/stores/ui.store';
|
import { useUIStore } from '@/stores/ui.store';
|
||||||
|
|
||||||
const uiStore = useUIStore();
|
const uiStore = useUIStore();
|
||||||
|
const usersStore = useUsersStore();
|
||||||
const { isInstanceOwner } = useUsersStore();
|
|
||||||
|
|
||||||
async function dismissPermanently() {
|
async function dismissPermanently() {
|
||||||
await uiStore.dismissBanner('V1', 'permanent');
|
await uiStore.dismissBanner('V1', 'permanent');
|
||||||
|
@ -18,7 +17,7 @@ async function dismissPermanently() {
|
||||||
<template #mainContent>
|
<template #mainContent>
|
||||||
<span v-html="locale.baseText('banners.v1.message')"></span>
|
<span v-html="locale.baseText('banners.v1.message')"></span>
|
||||||
<a
|
<a
|
||||||
v-if="isInstanceOwner"
|
v-if="usersStore.isInstanceOwner"
|
||||||
:class="$style.link"
|
:class="$style.link"
|
||||||
@click="dismissPermanently"
|
@click="dismissPermanently"
|
||||||
data-test-id="banner-confirm-v1"
|
data-test-id="banner-confirm-v1"
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { render } from '@testing-library/vue';
|
||||||
|
import V1Banner from '../V1Banner.vue';
|
||||||
|
import { createPinia, setActivePinia } from 'pinia';
|
||||||
|
import { useUsersStore } from '@/stores/users.store';
|
||||||
|
|
||||||
|
describe('V1 Banner', () => {
|
||||||
|
let pinia: ReturnType<typeof createPinia>;
|
||||||
|
let usersStore: ReturnType<typeof useUsersStore>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
pinia = createPinia();
|
||||||
|
setActivePinia(pinia);
|
||||||
|
|
||||||
|
usersStore = useUsersStore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render banner', () => {
|
||||||
|
const { container } = render(V1Banner);
|
||||||
|
expect(container).toMatchSnapshot();
|
||||||
|
expect(container.querySelectorAll('a')).toHaveLength(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render banner with dismiss call if user is owner', () => {
|
||||||
|
vi.spyOn(usersStore, 'currentUser', 'get').mockReturnValue({
|
||||||
|
globalRole: {
|
||||||
|
id: 0,
|
||||||
|
name: 'owner',
|
||||||
|
createdAt: '2021-08-09T14:00:00.000Z',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { container } = render(V1Banner);
|
||||||
|
expect(container).toMatchSnapshot();
|
||||||
|
expect(container.querySelectorAll('a')).toHaveLength(2);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,101 @@
|
||||||
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
|
exports[`V1 Banner > should render banner 1`] = `
|
||||||
|
<div>
|
||||||
|
<n8n-callout
|
||||||
|
class="v1container"
|
||||||
|
data-test-id="banners-V1"
|
||||||
|
icon="info-circle"
|
||||||
|
iconsize="medium"
|
||||||
|
roundcorners="false"
|
||||||
|
theme="warning"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="mainContent keepSpace"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span>
|
||||||
|
n8n has been updated to version 1, introducing some breaking changes. Please consult the
|
||||||
|
<a
|
||||||
|
href="https://docs.n8n.io/1-0-migration-checklist"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
migration guide
|
||||||
|
</a>
|
||||||
|
for more information.
|
||||||
|
</span>
|
||||||
|
<!--v-if-->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</n8n-callout>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`V1 Banner > should render banner if user is not woner 1`] = `
|
||||||
|
<div>
|
||||||
|
<n8n-callout
|
||||||
|
class="v1container"
|
||||||
|
data-test-id="banners-V1"
|
||||||
|
icon="info-circle"
|
||||||
|
iconsize="medium"
|
||||||
|
roundcorners="false"
|
||||||
|
theme="warning"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="mainContent keepSpace"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span>
|
||||||
|
n8n has been updated to version 1, introducing some breaking changes. Please consult the
|
||||||
|
<a
|
||||||
|
href="https://docs.n8n.io/1-0-migration-checklist"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
migration guide
|
||||||
|
</a>
|
||||||
|
for more information.
|
||||||
|
</span>
|
||||||
|
<!--v-if-->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</n8n-callout>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`V1 Banner > should render banner with dismiss call if user is owner 1`] = `
|
||||||
|
<div>
|
||||||
|
<n8n-callout
|
||||||
|
class="v1container"
|
||||||
|
data-test-id="banners-V1"
|
||||||
|
icon="info-circle"
|
||||||
|
iconsize="medium"
|
||||||
|
roundcorners="false"
|
||||||
|
theme="warning"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="mainContent keepSpace"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span>
|
||||||
|
n8n has been updated to version 1, introducing some breaking changes. Please consult the
|
||||||
|
<a
|
||||||
|
href="https://docs.n8n.io/1-0-migration-checklist"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
migration guide
|
||||||
|
</a>
|
||||||
|
for more information.
|
||||||
|
</span>
|
||||||
|
<a
|
||||||
|
class="link"
|
||||||
|
data-test-id="banner-confirm-v1"
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
Don't show again
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</n8n-callout>
|
||||||
|
</div>
|
||||||
|
`;
|
Loading…
Reference in a new issue