refactor: Remove node access control (#8730)

This commit is contained in:
Omar Ajoue 2024-03-04 16:11:35 +00:00 committed by GitHub
parent 11a5331e03
commit 0d10befd60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 82 deletions

View file

@ -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">
@ -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,
@ -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,
@ -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;
@ -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(
@ -827,7 +796,7 @@ export default defineComponent({
name: this.credentialName,
type: this.credentialTypeName!,
data: data as unknown as ICredentialDataDecryptedObject,
nodesAccess,
nodesAccess: [],
sharedWith,
ownedBy,
};
@ -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) {

View file

@ -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">
@ -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);
},