Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(editor): Migrate part of the vuex store to pinia #4484

Merged
merged 44 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3bbd378
✨ Added pinia support. Migrated community nodes module.
MiloradFilipovic Oct 25, 2022
9395b23
✨ Added ui pinia store, moved some data from root store to it, update…
MiloradFilipovic Oct 25, 2022
10bb3bc
✨ Added ui pinia store and migrated a part of the root store
MiloradFilipovic Oct 25, 2022
360545d
✨ Migrated `settings` store to pinia
MiloradFilipovic Oct 26, 2022
221d1c6
✨ Removing vuex store refs from router
MiloradFilipovic Oct 26, 2022
55973de
✨ Migrated `users` module to pinia store
MiloradFilipovic Oct 26, 2022
a10201a
Merge branch 'master' into N8N-5190-pinia-migration-part1
MiloradFilipovic Oct 27, 2022
cd6467d
⚡ Fixing errors after sync with master
MiloradFilipovic Oct 27, 2022
2cd5495
⚡ One more error after merge
MiloradFilipovic Oct 27, 2022
363988d
⚡ Created `workflows` pinia store. Moved large part of root store to …
MiloradFilipovic Oct 27, 2022
a1c9bf7
✨ Finished migrating workflows store to pinia
MiloradFilipovic Oct 28, 2022
d591bcd
⚡ Renaming some getters and actions to make more sense
MiloradFilipovic Oct 28, 2022
c31ada6
✨ Finished migrating the root store to pinia
MiloradFilipovic Oct 28, 2022
81777b8
✨ Migrated ndv store to pinia
MiloradFilipovic Oct 28, 2022
d98b75d
⚡ Renaming main panel dimensions getter so it doesn't clash with data…
MiloradFilipovic Oct 28, 2022
a1b3bc1
Merge branch 'feature/pinia-migration' into N8N-5190-pinia-migration-…
MiloradFilipovic Oct 28, 2022
b3a5c45
✔️ Fixing lint errors
MiloradFilipovic Oct 29, 2022
b023241
✨ Migrated `templates` store to pinia
MiloradFilipovic Oct 29, 2022
f221754
✨ Migrated the `nodeTypes`store
MiloradFilipovic Oct 30, 2022
8d12931
⚡ Removed unused pieces of code and oold vuex modules
MiloradFilipovic Oct 31, 2022
f133559
✨ Adding vuex calls to pinia store, fi xing wrong references
MiloradFilipovic Oct 31, 2022
373d187
💄 Removing leftover $store refs
MiloradFilipovic Oct 31, 2022
6ac0691
⚡ Added legacy getters and mutations to store to support webhooks
MiloradFilipovic Oct 31, 2022
0abaeca
⚡ Added missing front-end hooks, updated vuex state subscriptions to …
MiloradFilipovic Oct 31, 2022
38a6fbb
✔️ Fixing linting errors
MiloradFilipovic Oct 31, 2022
5091160
Merge branch 'feature/pinia-migration' into N8N-5190-pinia-migration-…
MiloradFilipovic Oct 31, 2022
7019ce3
Removing vue composition api plugin
MiloradFilipovic Oct 31, 2022
4ff2159
⚡ Fixing main sidebar state when loading node view
MiloradFilipovic Nov 2, 2022
557a2d3
🐛 Fixing an error when activating workflows
MiloradFilipovic Nov 2, 2022
b7931a3
🐛 Fixing isses with workflow settings and executions auto-refresh
MiloradFilipovic Nov 2, 2022
e5d14bd
🐛 Removing duplicate listeners which cause import error
MiloradFilipovic Nov 2, 2022
af43749
🐛 Fixing route authentication
MiloradFilipovic Nov 2, 2022
53674f6
Merge branch 'master' into N8N-5190-pinia-migration-part1
MiloradFilipovic Nov 2, 2022
c943775
⚡ Updating freshly pulled $store refs
MiloradFilipovic Nov 2, 2022
d03c492
Adding deleted const
MiloradFilipovic Nov 2, 2022
e7c61b1
⚡ Updating store references in ee features. Reseting NodeView credent…
MiloradFilipovic Nov 2, 2022
3b0cc8b
⚡ Adding return type to email submission modal
MiloradFilipovic Nov 2, 2022
1829c1e
⚡ Making NodeView only react to paste event when active
MiloradFilipovic Nov 2, 2022
3a57695
🐛 Fixing signup view errors
MiloradFilipovic Nov 2, 2022
52aa20d
👌 Addressing PR review comments
MiloradFilipovic Nov 2, 2022
7cb7fa3
Merge branch 'master' into N8N-5190-pinia-migration-part1
MiloradFilipovic Nov 4, 2022
f24f498
👌 Addressing new PR comments
MiloradFilipovic Nov 4, 2022
b61f7f6
Merge branch 'master' into N8N-5190-pinia-migration-part1
MiloradFilipovic Nov 4, 2022
8619610
👌 Updating invite id logic in signup view
MiloradFilipovic Nov 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 88 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/editor-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"n8n-design-system": "~0.41.0",
"n8n-workflow": "~0.123.0",
"normalize-wheel": "^1.0.1",
"pinia": "^2.0.22",
"prismjs": "^1.17.1",
"quill": "2.0.0-dev.4",
"quill-autoformat": "^0.1.1",
Expand Down
55 changes: 33 additions & 22 deletions packages/editor-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
id="app"
:class="{
[$style.container]: true,
[$style.sidebarCollapsed]: sidebarMenuCollapsed
[$style.sidebarCollapsed]: uiStore.sidebarMenuCollapsed
}"
>
<div id="header" :class="$style.header">
Expand Down Expand Up @@ -35,11 +35,17 @@ import { HIRING_BANNER, LOCAL_STORAGE_THEME, VIEWS } from './constants';
import mixins from 'vue-typed-mixins';
import { showMessage } from './components/mixins/showMessage';
import { IUser } from './Interface';
import { mapGetters } from 'vuex';
import { userHelpers } from './components/mixins/userHelpers';
import { loadLanguage } from './plugins/i18n';
import { restApi } from '@/components/mixins/restApi';
import { globalLinkActions } from '@/components/mixins/globalLinkActions';
import { mapStores } from 'pinia';
import { useUIStore } from './stores/ui';
import { useSettingsStore } from './stores/settings';
import { useUsersStore } from './stores/users';
import { useRootStore } from './stores/n8nRootStore';
import { useTemplatesStore } from './stores/templates';
import { useNodeTypesStore } from './stores/nodeTypes';

export default mixins(
showMessage,
Expand All @@ -54,11 +60,16 @@ export default mixins(
Modals,
},
computed: {
...mapGetters('settings', ['isHiringBannerEnabled', 'isTemplatesEnabled', 'isTemplatesEndpointReachable', 'isUserManagementEnabled', 'showSetupPage']),
...mapGetters('users', ['currentUser']),
...mapGetters('ui', ['sidebarMenuCollapsed']),
...mapStores(
useNodeTypesStore,
useRootStore,
useSettingsStore,
useTemplatesStore,
useUIStore,
useUsersStore,
),
defaultLocale (): string {
return this.$store.getters.defaultLocale;
return this.rootStore.defaultLocale;
},
},
data() {
Expand All @@ -69,7 +80,7 @@ export default mixins(
methods: {
async initSettings(): Promise<void> {
try {
await this.$store.dispatch('settings/getSettings');
await this.settingsStore.getSettings();
} catch (e) {
this.$showToast({
title: this.$locale.baseText('startupError'),
Expand All @@ -81,44 +92,43 @@ export default mixins(
throw e;
}
},
async loginWithCookie(): Promise<void> {
loginWithCookie(): void {
try {
await this.$store.dispatch('users/loginWithCookie');
this.usersStore.loginWithCookie();
} catch (e) {}
},
async initTemplates(): Promise<void> {
if (!this.isTemplatesEnabled) {
if (!this.settingsStore.isTemplatesEnabled) {
return;
}

try {
await this.$store.dispatch('settings/testTemplatesEndpoint');
} catch (e) {
await this.settingsStore.testTemplatesEndpoint();
} catch (e) {
}
},
logHiringBanner() {
if (this.isHiringBannerEnabled && this.$route.name !== VIEWS.DEMO) {
if (this.settingsStore.isHiringBannerEnabled && this.$route.name !== VIEWS.DEMO) {
console.log(HIRING_BANNER); // eslint-disable-line no-console
}
},
async initialize(): Promise<void> {
await this.initSettings();
await Promise.all([this.loginWithCookie(), this.initTemplates()]);
},
trackPage() {
this.$store.commit('ui/setCurrentView', this.$route.name);
trackPage(): void {
this.uiStore.currentView = this.$route.name || '';
if (this.$route && this.$route.meta && this.$route.meta.templatesEnabled) {
this.$store.commit('templates/setSessionId');
this.templatesStore.setSessionId();
}
else {
this.$store.commit('templates/resetSessionId'); // reset telemetry session id when user leaves template pages
this.templatesStore.resetSessionId(); // reset telemetry session id when user leaves template pages
}

this.$telemetry.page(this.$route);
},
authenticate() {
// redirect to setup page. user should be redirected to this only once
if (this.isUserManagementEnabled && this.showSetupPage) {
if (this.settingsStore.isUserManagementEnabled && this.settingsStore.showSetupPage) {
if (this.$route.name === VIEWS.SETUP) {
return;
}
Expand All @@ -132,7 +142,7 @@ export default mixins(
}

// if cannot access page and not logged in, ask to sign in
const user = this.currentUser as IUser | null;
const user = this.usersStore.currentUser;
if (!user) {
const redirect =
this.$route.query.redirect ||
Expand All @@ -154,7 +164,7 @@ export default mixins(
this.$router.replace({ name: VIEWS.HOMEPAGE });
},
redirectIfNecessary() {
const redirect = this.$route.meta && typeof this.$route.meta.getRedirect === 'function' && this.$route.meta.getRedirect(this.$store);
const redirect = this.$route.meta && typeof this.$route.meta.getRedirect === 'function' && this.$route.meta.getRedirect();
if (redirect) {
this.$router.replace(redirect);
}
Expand All @@ -176,10 +186,11 @@ export default mixins(
this.loading = false;

this.trackPage();
// TODO: Un-comment once front-end hooks are updated to work with pinia store
this.$externalHooks().run('app.mount');

if (this.defaultLocale !== 'en') {
void this.$store.dispatch('nodeTypes/getNodeTranslationHeaders');
await this.nodeTypesStore.getNodeTranslationHeaders();
}
},
watch: {
Expand Down
Loading