n8n/packages/editor-ui/src/App.vue
Iván Ovejero 4ae0f5b6fb
fix(editor): Fix i18n issues (#3072)
* 🐛 Fix `defaultLocale` watcher

*  Improve error handling for headers

* ✏️ Improve naming

* 🐛 Fix hiring banner check

*  Flatten base text keys

*  Fix miscorrected key

*  Implement pluralization

* ✏️ Update docs

* 🚚 Move headers fetching to `App.vue`

* fix hiring banner

*  Fix missing import

* ✏️ Alphabetize translations

*  Switch to async check

* feat(editor): Refactor Output Panel + fix i18n issues (#3097)

* update main panel

* finish up tabs

* fix docs link

* add icon

* update node settings

* clean up settings

* add rename modal

* fix component styles

* fix spacing

* truncate name

* remove mixin

* fix spacing

* fix spacing

* hide docs url

* fix bug

* fix renaming

* refactor tabs out

* refactor execute button

* refactor header

* add more views

* fix error view

* fix workflow rename bug

* rename component

* fix small screen bug

* move items, fix positions

* add hover state

* show selector on empty state

* add empty run state

* fix binary view

* 1 item

* add vjs styles

* show empty row for every item

* refactor tabs

* add branch names

* fix spacing

* fix up spacing

* add run selector

* fix positioning

* clean up

* increase width of selector

* fix up spacing

* fix copy button

* fix branch naming; type issues

* fix docs in custom nodes

* add type

* hide items when run selector is shown

* increase selector size

* add select prepend

* clean up a bit

* Add pagination

* add stale icon

* enable stale data in execution run

* Revert "enable stale data in execution run"

8edb68dbff

* move metadata to its own state

* fix smaller size

* add scroll buttons

* update tabs on resize

* update stale data on rename

* remove metadata on delete

* hide x

* change title colors

* binary data classes

* remove duplicate css

* add colors

* delete unused keys

* use event bus

* update styles of pagination

* fix ts issues

* fix ts issues

* use chevron icons

* fix design with download button

* add back to canvas button

* add trigger warning disabled

* show trigger warning tooltip

* update button labels for triggers

* update node output message

* fix add-option bug

* add page selector

* fix pagination selector bug

* fix executions bug

* remove hint

* add json colors

* add colors for json

* add color json keys

* fix select options bug

* update keys

* address comments

* update name limit

* align pencil

* update icon size

* update radio buttons height

* address comments

* fix pencil bug

* change buttons alignment

* fully center

* change order of buttons

* add no output message in branch

* scroll to top

* change active state

* fix page size

* all items

* update expression background

* update naming

* align pencil

* update modal background

* add schedule group

* update schedule nodes messages

* use ellpises for last chars

* fix spacing

* fix tabs issue

* fix too far data bug

* fix executions bug

* fix table wrapping

* fix rename bug

* add padding

* handle unkown errors

* add sticky header

* ignore empty input, trim node name

* nudge lightness of color

* center buttons

* update pagination

* set colors of title

* increase table font, fix alignment

* fix pencil bug

* fix spacing

* use date now

* address pagination issues

* delete unused keys

* update keys sort

* fix prepend

* fix radio button position

* Revert "fix radio button position"

ae42781786

Co-authored-by: Mutasem <mutdmour@gmail.com>
Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com>
2022-04-11 15:12:13 +02:00

205 lines
5 KiB
Vue

<template>
<div :class="$style.container">
<LoadingView v-if="loading" />
<div v-else id="app" :class="$style.container">
<div id="header" :class="$style.header">
<router-view name="header"></router-view>
</div>
<div id="sidebar" :class="$style.sidebar">
<router-view name="sidebar"></router-view>
</div>
<div id="content" :class="$style.content">
<router-view />
</div>
<Modals />
<Telemetry />
</div>
</div>
</template>
<script lang="ts">
import Modals from './components/Modals.vue';
import LoadingView from './views/LoadingView.vue';
import Telemetry from './components/Telemetry.vue';
import { HIRING_BANNER, 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 { addHeaders, loadLanguage } from './plugins/i18n';
import { restApi } from '@/components/mixins/restApi';
export default mixins(
showMessage,
userHelpers,
restApi,
).extend({
name: 'App',
components: {
LoadingView,
Telemetry,
Modals,
},
computed: {
...mapGetters('settings', ['isHiringBannerEnabled', 'isTemplatesEnabled', 'isTemplatesEndpointReachable', 'isUserManagementEnabled', 'showSetupPage']),
...mapGetters('users', ['currentUser']),
defaultLocale (): string {
return this.$store.getters.defaultLocale;
},
},
data() {
return {
loading: true,
};
},
methods: {
async initSettings(): Promise<void> {
try {
await this.$store.dispatch('settings/getSettings');
} catch (e) {
this.$showToast({
title: this.$locale.baseText('startupError'),
message: this.$locale.baseText('startupError.message'),
type: 'error',
duration: 0,
});
throw e;
}
},
async loginWithCookie(): Promise<void> {
try {
await this.$store.dispatch('users/loginWithCookie');
} catch (e) {}
},
async initTemplates(): Promise<void> {
if (!this.isTemplatesEnabled) {
return;
}
try {
await this.$store.dispatch('settings/testTemplatesEndpoint');
} catch (e) {
}
},
logHiringBanner() {
if (this.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);
if (this.$route && this.$route.meta && this.$route.meta.templatesEnabled) {
this.$store.commit('templates/setSessionId');
}
else {
this.$store.commit('templates/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.$route.name === VIEWS.SETUP) {
return;
}
this.$router.replace({ name: VIEWS.SETUP });
return;
}
if (this.canUserAccessCurrentRoute()) {
return;
}
// if cannot access page and not logged in, ask to sign in
const user = this.currentUser as IUser | null;
if (!user) {
const redirect =
this.$route.query.redirect ||
encodeURIComponent(`${window.location.pathname}${window.location.search}`);
this.$router.replace({ name: VIEWS.SIGNIN, query: { redirect } });
return;
}
// if cannot access page and is logged in, respect signin redirect
if (this.$route.name === VIEWS.SIGNIN && typeof this.$route.query.redirect === 'string') {
const redirect = decodeURIComponent(this.$route.query.redirect);
if (redirect.startsWith('/')) { // protect against phishing
this.$router.replace(redirect);
return;
}
}
// if cannot access page and is logged in
this.$router.replace({ name: VIEWS.HOMEPAGE });
},
redirectIfNecessary() {
const redirect = this.$route.meta && typeof this.$route.meta.getRedirect === 'function' && this.$route.meta.getRedirect(this.$store);
if (redirect) {
this.$router.replace(redirect);
}
},
},
async mounted() {
await this.initialize();
this.logHiringBanner();
this.authenticate();
this.redirectIfNecessary();
this.loading = false;
this.trackPage();
this.$externalHooks().run('app.mount');
if (this.defaultLocale !== 'en') {
const headers = await this.restApi().getNodeTranslationHeaders();
if (headers) addHeaders(headers, this.defaultLocale);
}
},
watch: {
$route(route) {
this.authenticate();
this.redirectIfNecessary();
this.trackPage();
},
defaultLocale(newLocale) {
loadLanguage(newLocale);
},
},
});
</script>
<style lang="scss" module>
.container {
height: 100%;
width: 100%;
}
.content {
composes: container;
background-color: var(--color-background-light);
position: relative;
}
.header {
z-index: 10;
position: fixed;
width: 100%;
}
.sidebar {
z-index: 15;
position: fixed;
}
</style>