From c013245db726bf7e2a880ac538631c53450a6471 Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Mon, 12 Dec 2022 14:46:34 +0200 Subject: [PATCH] feat: Add sharing permissions info for workflow sharees (#4892) * feat: Add sharing permissions info for workflow sharees * fix: Remove infotip for owner --- .../CredentialEdit/CredentialSharing.ee.vue | 2 +- .../src/components/WorkflowShareModal.ee.vue | 6 ++++++ packages/editor-ui/src/plugins/i18n/locales/en.json | 2 ++ packages/editor-ui/src/stores/workflows.ee.ts | 11 +++++++++++ packages/editor-ui/src/stores/workflows.ts | 3 +++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue b/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue index f76b8b18bd..362ac5a73d 100644 --- a/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue +++ b/packages/editor-ui/src/components/CredentialEdit/CredentialSharing.ee.vue @@ -81,7 +81,7 @@ export default mixins( ].concat(this.credentialData.sharedWith || []); }, credentialOwnerName(): string { - return this.credentialsStore.getCredentialOwnerName(this.credentialId); + return this.credentialsStore.getCredentialOwnerName(`${this.credentialId}`); }, }, methods: { diff --git a/packages/editor-ui/src/components/WorkflowShareModal.ee.vue b/packages/editor-ui/src/components/WorkflowShareModal.ee.vue index f617badf1e..a9a8a2f777 100644 --- a/packages/editor-ui/src/components/WorkflowShareModal.ee.vue +++ b/packages/editor-ui/src/components/WorkflowShareModal.ee.vue @@ -14,6 +14,9 @@
+ + {{ $locale.baseText('workflows.shareModal.info.sharee', { interpolate: { workflowOwnerName } }) }} + an edit to this workflow since you last saved it. Do you want to overwrite their changes?", diff --git a/packages/editor-ui/src/stores/workflows.ee.ts b/packages/editor-ui/src/stores/workflows.ee.ts index 30bf43e87d..28017eeb68 100644 --- a/packages/editor-ui/src/stores/workflows.ee.ts +++ b/packages/editor-ui/src/stores/workflows.ee.ts @@ -8,9 +8,20 @@ import {useRootStore} from "@/stores/n8nRootStore"; import {useSettingsStore} from "@/stores/settings"; import {defineStore} from "pinia"; import {useWorkflowsStore} from "@/stores/workflows"; +import {i18n} from "@/plugins/i18n"; export const useWorkflowsEEStore = defineStore(STORES.WORKFLOWS_EE, { state() { return {}; }, + getters: { + getWorkflowOwnerName() { + return (workflowId: string): string => { + const workflow = useWorkflowsStore().getWorkflowById(workflowId); + return workflow && workflow.ownedBy && workflow.ownedBy.firstName + ? `${workflow.ownedBy.firstName} ${workflow.ownedBy.lastName} (${workflow.ownedBy.email})` + : i18n.baseText('workflows.shareModal.info.sharee.fallback'); + }; + }, + }, actions: { setWorkflowOwnedBy(payload: { workflowId: string, ownedBy: Partial }): void { const workflowsStore = useWorkflowsStore(); diff --git a/packages/editor-ui/src/stores/workflows.ts b/packages/editor-ui/src/stores/workflows.ts index 963de8c9e5..73e27426f2 100644 --- a/packages/editor-ui/src/stores/workflows.ts +++ b/packages/editor-ui/src/stores/workflows.ts @@ -149,6 +149,9 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, { return workflowRunData[nodeName]; }; }, + getWorkflowById() { + return (id: string): IWorkflowDb => this.workflowsById[id]; + }, // Node getters allConnections() : IConnections {