feat: Add sharing permissions info for workflow sharees (#4892)

* feat: Add sharing permissions info for workflow sharees

* fix: Remove infotip for owner
This commit is contained in:
Alex Grozav 2022-12-12 14:46:34 +02:00 committed by GitHub
parent 1cce8eaf16
commit c013245db7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 1 deletions

View file

@ -81,7 +81,7 @@ export default mixins(
].concat(this.credentialData.sharedWith || []); ].concat(this.credentialData.sharedWith || []);
}, },
credentialOwnerName(): string { credentialOwnerName(): string {
return this.credentialsStore.getCredentialOwnerName(this.credentialId); return this.credentialsStore.getCredentialOwnerName(`${this.credentialId}`);
}, },
}, },
methods: { methods: {

View file

@ -14,6 +14,9 @@
</n8n-text> </n8n-text>
</div> </div>
<div v-else :class="$style.container"> <div v-else :class="$style.container">
<n8n-info-tip v-if="!workflowPermissions.isOwner" :bold="false" class="mb-s" >
{{ $locale.baseText('workflows.shareModal.info.sharee', { interpolate: { workflowOwnerName } }) }}
</n8n-info-tip>
<enterprise-edition :features="[EnterpriseEditionFeature.WorkflowSharing]"> <enterprise-edition :features="[EnterpriseEditionFeature.WorkflowSharing]">
<n8n-user-select <n8n-user-select
v-if="workflowPermissions.updateSharing" v-if="workflowPermissions.updateSharing"
@ -186,6 +189,9 @@ export default mixins(
workflowPermissions(): IPermissions { workflowPermissions(): IPermissions {
return getWorkflowPermissions(this.usersStore.currentUser, this.workflow); return getWorkflowPermissions(this.usersStore.currentUser, this.workflow);
}, },
workflowOwnerName(): string {
return this.workflowsEEStore.getWorkflowOwnerName(`${this.workflow.id}`);
},
isSharingAvailable(): boolean { isSharingAvailable(): boolean {
return this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.WorkflowSharing) === true; return this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.WorkflowSharing) === true;
}, },

View file

@ -1415,6 +1415,8 @@
"workflows.shareModal.notAvailable.button": "Explore n8n cloud", "workflows.shareModal.notAvailable.button": "Explore n8n cloud",
"workflows.shareModal.isDefaultUser.description": "You first need to set up your owner account to enable workflow sharing features.", "workflows.shareModal.isDefaultUser.description": "You first need to set up your owner account to enable workflow sharing features.",
"workflows.shareModal.isDefaultUser.button": "Go to settings", "workflows.shareModal.isDefaultUser.button": "Go to settings",
"workflows.shareModal.info.sharee": "Only {workflowOwnerName} can change who this workflow is shared with",
"workflows.shareModal.info.sharee.fallback": "the owner",
"workflows.roles.editor": "Editor", "workflows.roles.editor": "Editor",
"workflows.concurrentChanges.confirmMessage.title": "Workflow was edited by someone else", "workflows.concurrentChanges.confirmMessage.title": "Workflow was edited by someone else",
"workflows.concurrentChanges.confirmMessage.message": "Another user made <strong>an edit</strong> to this workflow since you last saved it. Do you want to overwrite their changes?", "workflows.concurrentChanges.confirmMessage.message": "Another user made <strong>an edit</strong> to this workflow since you last saved it. Do you want to overwrite their changes?",

View file

@ -8,9 +8,20 @@ import {useRootStore} from "@/stores/n8nRootStore";
import {useSettingsStore} from "@/stores/settings"; import {useSettingsStore} from "@/stores/settings";
import {defineStore} from "pinia"; import {defineStore} from "pinia";
import {useWorkflowsStore} from "@/stores/workflows"; import {useWorkflowsStore} from "@/stores/workflows";
import {i18n} from "@/plugins/i18n";
export const useWorkflowsEEStore = defineStore(STORES.WORKFLOWS_EE, { export const useWorkflowsEEStore = defineStore(STORES.WORKFLOWS_EE, {
state() { return {}; }, 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: { actions: {
setWorkflowOwnedBy(payload: { workflowId: string, ownedBy: Partial<IUser> }): void { setWorkflowOwnedBy(payload: { workflowId: string, ownedBy: Partial<IUser> }): void {
const workflowsStore = useWorkflowsStore(); const workflowsStore = useWorkflowsStore();

View file

@ -149,6 +149,9 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
return workflowRunData[nodeName]; return workflowRunData[nodeName];
}; };
}, },
getWorkflowById() {
return (id: string): IWorkflowDb => this.workflowsById[id];
},
// Node getters // Node getters
allConnections() : IConnections { allConnections() : IConnections {