Skip to content

Commit

Permalink
Revert "refactor(editor): Turn showMessage mixin to composable" (#6243)
Browse files Browse the repository at this point in the history
Revert "refactor(editor): Turn showMessage mixin to composable (#6081)"

This reverts commit b95fcd7.
  • Loading branch information
cstuncsik authored May 12, 2023
1 parent 13bcec1 commit 638e3f2
Show file tree
Hide file tree
Showing 75 changed files with 863 additions and 991 deletions.
30 changes: 15 additions & 15 deletions packages/editor-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,29 @@
</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, LOCAL_STORAGE_THEME, VIEWS } from '@/constants';
import Modals from './components/Modals.vue';
import LoadingView from './views/LoadingView.vue';
import Telemetry from './components/Telemetry.vue';
import { HIRING_BANNER, LOCAL_STORAGE_THEME, VIEWS } from './constants';
import mixins from 'vue-typed-mixins';
import { showMessage } from '@/mixins/showMessage';
import { userHelpers } from '@/mixins/userHelpers';
import { loadLanguage } from '@/plugins/i18n';
import { useGlobalLinkActions, useToast } from '@/composables';
import { loadLanguage } from './plugins/i18n';
import useGlobalLinkActions from '@/composables/useGlobalLinkActions';
import { mapStores } from 'pinia';
import { useUIStore } from '@/stores/ui.store';
import { useSettingsStore } from '@/stores/settings.store';
import { useUsersStore } from '@/stores/users.store';
import { useRootStore } from '@/stores/n8nRoot.store';
import { useTemplatesStore } from '@/stores/templates.store';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { useUIStore } from './stores/ui.store';
import { useSettingsStore } from './stores/settings.store';
import { useUsersStore } from './stores/users.store';
import { useRootStore } from './stores/n8nRoot.store';
import { useTemplatesStore } from './stores/templates.store';
import { useNodeTypesStore } from './stores/nodeTypes.store';
import { useHistoryHelper } from '@/composables/useHistoryHelper';
import { newVersions } from '@/mixins/newVersions';
import { useRoute } from 'vue-router/composables';
import { useVersionControlStore } from '@/stores/versionControl.store';
export default mixins(newVersions, userHelpers).extend({
export default mixins(newVersions, showMessage, userHelpers).extend({
name: 'App',
components: {
LoadingView,
Expand All @@ -59,7 +60,6 @@ export default mixins(newVersions, userHelpers).extend({
return {
...useGlobalLinkActions(),
...useHistoryHelper(useRoute()),
...useToast(),
};
},
computed: {
Expand All @@ -86,7 +86,7 @@ export default mixins(newVersions, userHelpers).extend({
try {
await this.settingsStore.getSettings();
} catch (e) {
this.showToast({
this.$showToast({
title: this.$locale.baseText('startupError'),
message: this.$locale.baseText('startupError.message'),
type: 'error',
Expand Down
19 changes: 7 additions & 12 deletions packages/editor-ui/src/components/ChangePasswordModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,24 @@
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import mixins from 'vue-typed-mixins';
import { useToast } from '@/composables';
import Modal from '@/components/Modal.vue';
import { showMessage } from '@/mixins/showMessage';
import Modal from './Modal.vue';
import type { IFormInputs } from '@/Interface';
import { CHANGE_PASSWORD_MODAL_KEY } from '@/constants';
import { CHANGE_PASSWORD_MODAL_KEY } from '../constants';
import { mapStores } from 'pinia';
import { useUsersStore } from '@/stores/users.store';
import { createEventBus } from '@/event-bus';
export default defineComponent({
export default mixins(showMessage).extend({
components: { Modal },
name: 'ChangePasswordModal',
props: {
modalName: {
type: String,
},
},
setup() {
return {
...useToast(),
};
},
data() {
return {
config: null as null | IFormInputs,
Expand Down Expand Up @@ -132,15 +127,15 @@ export default defineComponent({
this.loading = true;
await this.usersStore.updateCurrentUserPassword(values);
this.showMessage({
this.$showMessage({
type: 'success',
title: this.$locale.baseText('auth.changePassword.passwordUpdated'),
message: this.$locale.baseText('auth.changePassword.passwordUpdatedMessage'),
});
this.modalBus.emit('close');
} catch (error) {
this.showError(error, this.$locale.baseText('auth.changePassword.error'));
this.$showError(error, this.$locale.baseText('auth.changePassword.error'));
}
this.loading = false;
},
Expand Down
7 changes: 4 additions & 3 deletions packages/editor-ui/src/components/CommunityPackageCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@
import { useUIStore } from '@/stores/ui.store';
import type { PublicInstalledPackage } from 'n8n-workflow';
import { mapStores } from 'pinia';
import { defineComponent } from 'vue';
import { NPM_PACKAGE_DOCS_BASE_URL, COMMUNITY_PACKAGE_MANAGE_ACTIONS } from '@/constants';
import mixins from 'vue-typed-mixins';
import { NPM_PACKAGE_DOCS_BASE_URL, COMMUNITY_PACKAGE_MANAGE_ACTIONS } from '../constants';
import { showMessage } from '@/mixins/showMessage';
export default defineComponent({
export default mixins(showMessage).extend({
name: 'CommunityPackageCard',
props: {
communityPackage: {
Expand Down
19 changes: 7 additions & 12 deletions packages/editor-ui/src/components/CommunityPackageInstallModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,24 @@
</template>

<script lang="ts">
import Modal from '@/components/Modal.vue';
import Modal from './Modal.vue';
import {
COMMUNITY_PACKAGE_INSTALL_MODAL_KEY,
NPM_KEYWORD_SEARCH_URL,
COMMUNITY_NODES_INSTALLATION_DOCS_URL,
COMMUNITY_NODES_RISKS_DOCS_URL,
} from '@/constants';
import { defineComponent } from 'vue';
import { useToast } from '@/composables';
} from '../constants';
import mixins from 'vue-typed-mixins';
import { showMessage } from '@/mixins/showMessage';
import { mapStores } from 'pinia';
import { useCommunityNodesStore } from '@/stores/communityNodes.store';
import { createEventBus } from '@/event-bus';
export default defineComponent({
export default mixins(showMessage).extend({
name: 'CommunityPackageInstallModal',
components: {
Modal,
},
setup() {
return {
...useToast(),
};
},
data() {
return {
loading: false,
Expand Down Expand Up @@ -149,15 +144,15 @@ export default defineComponent({
await this.communityNodesStore.fetchInstalledPackages();
this.loading = false;
this.modalBus.emit('close');
this.showMessage({
this.$showMessage({
title: this.$locale.baseText('settings.communityNodes.messages.install.success'),
type: 'success',
});
} catch (error) {
if (error.httpStatusCode && error.httpStatusCode === 400) {
this.infoTextErrorMessage = error.message;
} else {
this.showError(
this.$showError(
error,
this.$locale.baseText('settings.communityNodes.messages.install.error'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@
</template>

<script>
import { defineComponent } from 'vue';
import Modal from '@/components/Modal.vue';
import { COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY, COMMUNITY_PACKAGE_MANAGE_ACTIONS } from '@/constants';
import { useToast } from '@/composables';
import mixins from 'vue-typed-mixins';
import Modal from './Modal.vue';
import {
COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY,
COMMUNITY_PACKAGE_MANAGE_ACTIONS,
} from '../constants';
import { showMessage } from '@/mixins/showMessage';
import { mapStores } from 'pinia';
import { useCommunityNodesStore } from '@/stores/communityNodes.store';
import { createEventBus } from '@/event-bus';
export default defineComponent({
export default mixins(showMessage).extend({
name: 'CommunityPackageManageConfirmModal',
components: {
Modal,
Expand All @@ -61,11 +64,6 @@ export default defineComponent({
type: String,
},
},
setup() {
return {
...useToast(),
};
},
data() {
return {
loading: false,
Expand Down Expand Up @@ -142,12 +140,12 @@ export default defineComponent({
});
this.loading = true;
await this.communityNodesStore.uninstallPackage(this.activePackageName);
this.showMessage({
this.$showMessage({
title: this.$locale.baseText('settings.communityNodes.messages.uninstall.success.title'),
type: 'success',
});
} catch (error) {
this.showError(
this.$showError(
error,
this.$locale.baseText('settings.communityNodes.messages.uninstall.error'),
);
Expand All @@ -169,7 +167,7 @@ export default defineComponent({
this.loading = true;
const updatedVersion = this.activePackage.updateAvailable;
await this.communityNodesStore.updatePackage(this.activePackageName);
this.showMessage({
this.$showMessage({
title: this.$locale.baseText('settings.communityNodes.messages.update.success.title'),
message: this.$locale.baseText(
'settings.communityNodes.messages.update.success.message',
Expand All @@ -183,7 +181,7 @@ export default defineComponent({
type: 'success',
});
} catch (error) {
this.showError(
this.$showError(
error,
this.$locale.baseText('settings.communityNodes.messages.update.error.title'),
);
Expand Down
10 changes: 2 additions & 8 deletions packages/editor-ui/src/components/ContactPromptModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,16 @@ import mixins from 'vue-typed-mixins';
import type { IN8nPromptResponse } from '@/Interface';
import { VALID_EMAIL_REGEX } from '@/constants';
import { workflowHelpers } from '@/mixins/workflowHelpers';
import Modal from '@/components/Modal.vue';
import Modal from './Modal.vue';
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/settings.store';
import { useRootStore } from '@/stores/n8nRoot.store';
import { createEventBus } from '@/event-bus';
import { useToast } from '@/composables';
export default mixins(workflowHelpers).extend({
components: { Modal },
name: 'ContactPromptModal',
props: ['modalName'],
setup() {
return {
...useToast(),
};
},
data() {
return {
email: '',
Expand Down Expand Up @@ -100,7 +94,7 @@ export default mixins(workflowHelpers).extend({
instance_id: this.rootStore.instanceId,
email: this.email,
});
this.showMessage({
this.$showMessage({
title: 'Thanks!',
message: "It's people like you that help make n8n better",
type: 'success',
Expand Down
11 changes: 3 additions & 8 deletions packages/editor-ui/src/components/CopyInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<script lang="ts">
import mixins from 'vue-typed-mixins';
import { copyPaste } from '@/mixins/copyPaste';
import { useToast } from '@/composables';
import { showMessage } from '@/mixins/showMessage';
export default mixins(copyPaste).extend({
export default mixins(copyPaste, showMessage).extend({
props: {
label: {
type: String,
Expand Down Expand Up @@ -56,17 +56,12 @@ export default mixins(copyPaste).extend({
default: 'large',
},
},
setup() {
return {
...useToast(),
};
},
methods: {
copy(): void {
this.$emit('copy');
this.copyToClipboard(this.value);
this.showMessage({
this.$showMessage({
title: this.toastTitle,
message: this.toastMessage,
type: 'success',
Expand Down
26 changes: 10 additions & 16 deletions packages/editor-ui/src/components/CredentialCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import mixins from 'vue-typed-mixins';
import type { ICredentialsResponse, IUser } from '@/Interface';
import type { ICredentialType } from 'n8n-workflow';
import { EnterpriseEditionFeature, MODAL_CONFIRM } from '@/constants';
import { useMessage } from '@/composables';
import { EnterpriseEditionFeature } from '@/constants';
import { showMessage } from '@/mixins/showMessage';
import CredentialIcon from '@/components/CredentialIcon.vue';
import type { IPermissions } from '@/permissions';
import { getCredentialPermissions } from '@/permissions';
Expand All @@ -50,17 +50,12 @@ export const CREDENTIAL_LIST_ITEM_ACTIONS = {
DELETE: 'delete',
};
export default defineComponent({
export default mixins(showMessage).extend({
data() {
return {
EnterpriseEditionFeature,
};
},
setup() {
return {
...useMessage(),
};
},
components: {
CredentialIcon,
},
Expand Down Expand Up @@ -133,7 +128,7 @@ export default defineComponent({
if (action === CREDENTIAL_LIST_ITEM_ACTIONS.OPEN) {
await this.onClick();
} else if (action === CREDENTIAL_LIST_ITEM_ACTIONS.DELETE) {
const deleteConfirmed = await this.confirm(
const deleteConfirmed = await this.confirmMessage(
this.$locale.baseText(
'credentialEdit.credentialEdit.confirmMessage.deleteCredential.message',
{
Expand All @@ -143,14 +138,13 @@ export default defineComponent({
this.$locale.baseText(
'credentialEdit.credentialEdit.confirmMessage.deleteCredential.headline',
),
{
confirmButtonText: this.$locale.baseText(
'credentialEdit.credentialEdit.confirmMessage.deleteCredential.confirmButtonText',
),
},
null,
this.$locale.baseText(
'credentialEdit.credentialEdit.confirmMessage.deleteCredential.confirmButtonText',
),
);
if (deleteConfirmed === MODAL_CONFIRM) {
if (deleteConfirmed) {
await this.credentialsStore.deleteCredential({ id: this.data.id });
}
}
Expand Down
Loading

0 comments on commit 638e3f2

Please sign in to comment.