Skip to content

Commit

Permalink
refactor: Remove node access control (#8730)
Browse files Browse the repository at this point in the history
  • Loading branch information
krynble authored Mar 4, 2024
1 parent 11a5331 commit 0d10bef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,8 @@
</div>
<div v-else-if="activeTab === 'details' && credentialType" :class="$style.mainContent">
<CredentialInfo
:node-access="nodeAccess"
:nodes-with-access="nodesWithAccess"
:current-credential="currentCredential"
:credential-permissions="credentialPermissions"
@accessChange="onNodeAccessChange"
/>
</div>
<div v-else-if="activeTab.startsWith('coming-soon')" :class="$style.mainContent">
Expand Down Expand Up @@ -642,10 +639,6 @@ export default defineComponent({
}
this.credentialName = currentCredentials.name;
currentCredentials.nodesAccess.forEach((access: { nodeType: string }) => {
// keep node access structure to keep dates when updating
this.nodeAccess[access.nodeType] = access;
});
} catch (error) {
this.showError(
error,
Expand All @@ -671,23 +664,6 @@ export default defineComponent({
sharing_enabled: EnterpriseEditionFeature.Sharing,
});
},
onNodeAccessChange({ name, value }: { name: string; value: boolean }) {
this.hasUnsavedChanges = true;
if (value) {
this.nodeAccess = {
...this.nodeAccess,
[name]: {
nodeType: name,
},
};
} else {
this.nodeAccess = {
...this.nodeAccess,
[name]: null,
};
}
},
onChangeSharedWith(sharees: IDataObject[]) {
this.credentialData = {
...this.credentialData,
Expand Down Expand Up @@ -762,17 +738,13 @@ export default defineComponent({
return;
}
const nodesAccess = Object.values(this.nodeAccess).filter(
(access) => !!access,
) as ICredentialNodeAccess[];
const { ownedBy, sharedWith, ...credentialData } = this.credentialData;
const details: ICredentialsDecrypted = {
id: this.credentialId,
name: this.credentialName,
type: this.credentialTypeName!,
data: credentialData,
nodesAccess,
nodesAccess: [],
};
this.isRetesting = true;
Expand Down Expand Up @@ -802,9 +774,6 @@ export default defineComponent({
}
this.isSaving = true;
const nodesAccess = Object.values(this.nodeAccess).filter(
(access) => !!access,
) as ICredentialNodeAccess[];
// Save only the none default data
const data = NodeHelpers.getNodeParameters(
Expand All @@ -827,7 +796,7 @@ export default defineComponent({
name: this.credentialName,
type: this.credentialTypeName!,
data: data as unknown as ICredentialDataDecryptedObject,
nodesAccess,
nodesAccess: [],
sharedWith,
ownedBy,
};
Expand Down Expand Up @@ -1114,18 +1083,7 @@ export default defineComponent({
}
},
setupNodeAccess(): void {
this.nodeAccess = this.nodesWithAccess.reduce(
(accu: NodeAccessMap, node: { name: string }) => {
if (this.mode === 'new') {
accu[node.name] = { nodeType: node.name }; // enable all nodes by default
} else {
accu[node.name] = null;
}
return accu;
},
{},
);
this.nodeAccess = {};
},
resetCredentialData(): void {
if (!this.credentialType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
<template>
<div :class="$style.container">
<el-row v-if="nodesWithAccess.length > 0">
<el-col :span="8" :class="$style.accessLabel">
<n8n-text :compact="true" :bold="true">
{{ $locale.baseText('credentialEdit.credentialInfo.allowUseBy') }}
</n8n-text>
</el-col>
<el-col :span="16">
<div v-for="node in nodesWithAccess" :key="node.name" :class="$style.valueLabel">
<el-checkbox
v-if="credentialPermissions.update"
:label="
$locale.headerText({
key: `headers.${shortNodeType(node)}.displayName`,
fallback: node.displayName,
})
"
:model-value="!!nodeAccess[node.name]"
@update:modelValue="(val) => onNodeAccessChange(node.name, val)"
/>
<n8n-text v-else>
{{
$locale.headerText({
key: `headers.${shortNodeType(node)}.displayName`,
fallback: node.displayName,
})
}}
</n8n-text>
</div>
</el-col>
</el-row>
<el-row v-if="currentCredential">
<el-col :span="8" :class="$style.label">
<n8n-text :compact="true" :bold="true">
Expand Down Expand Up @@ -78,14 +48,8 @@ export default defineComponent({
components: {
TimeAgo,
},
props: ['nodesWithAccess', 'nodeAccess', 'currentCredential', 'credentialPermissions'],
props: ['currentCredential', 'credentialPermissions'],
methods: {
onNodeAccessChange(name: string, value: string) {
this.$emit('accessChange', {
name,
value,
});
},
shortNodeType(nodeType: INodeTypeDescription) {
return this.$locale.shortNodeType(nodeType.name);
},
Expand Down

0 comments on commit 0d10bef

Please sign in to comment.