Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add allowEditAfterCreation to InputField

天舟6afef72858c2
diff --git a/frontend/src/plugins/issue/DatabaseCreateTemplate.ts b/frontend/src/plugins/issue/DatabaseCreateTemplate.ts
index 55af6b7a53..3d80fcbed2 100644
--- a/frontend/src/plugins/issue/DatabaseCreateTemplate.ts
+++ b/frontend/src/plugins/issue/DatabaseCreateTemplate.ts
@@ -51,6 +51,8 @@ const template: IssueTemplate = {
slug: "databaseName",
name: "DB name",
type: "String",
+ // Developer might create a database name which already exists, so we give the assignee the ability to change.
+ allowEditAfterCreation: true,
resolved: (ctx: IssueContext): boolean => {
const databaseName = ctx.issue.payload[INPUT_DATABASE_NAME];
return !isEmpty(databaseName);
diff --git a/frontend/src/plugins/issue/DatabaseGrantTemplate.ts b/frontend/src/plugins/issue/DatabaseGrantTemplate.ts
index 92332d915b..85d45c313a 100644
--- a/frontend/src/plugins/issue/DatabaseGrantTemplate.ts
+++ b/frontend/src/plugins/issue/DatabaseGrantTemplate.ts
@@ -51,6 +51,7 @@ const template: IssueTemplate = {
slug: "readonly",
name: "Read Only",
type: "Boolean",
+ allowEditAfterCreation: false,
resolved: (ctx: IssueContext): boolean => {
return true;
},
diff --git a/frontend/src/plugins/types.ts b/frontend/src/plugins/types.ts
index b4fcc704bd..25d4f37b26 100644
--- a/frontend/src/plugins/types.ts
+++ b/frontend/src/plugins/types.ts
@@ -62,6 +62,8 @@ export type InputField = {
name: string;
// Field type. This must NOT be changed after in use. Similar to id field.
type: InputFieldType;
+ // Whether to allow edit after creation.
+ allowEditAfterCreation: boolean;
// Whether the field is resolved.
// One use case is together with "required" field to validate whether it's ready to submit the data.
// For OUTPUT, one use case is to validate whether the field is filled properly according to the issue.
diff --git a/frontend/src/views/IssueSidebar.vue b/frontend/src/views/IssueSidebar.vue
index c05052f6e8..6386b803e7 100644
--- a/frontend/src/views/IssueSidebar.vue
+++ b/frontend/src/views/IssueSidebar.vue
@@ -41,7 +41,8 @@
<div class="col-span-2">
<template v-if="field.type == 'String'">
<BBTextField
- :disabled="!allowEdit"
+ class="text-sm"
+ :disabled="!allowEditCustomField(field)"
:required="true"
:value="fieldValue(field)"
:placeholder="field.placeholder"
@@ -50,7 +51,7 @@
</template>
<template v-else-if="field.type == 'Boolean'">
<BBSwitch
- :disabled="!allowEdit"
+ :disabled="!allowEditCustomField(field)"
:value="fieldValue(field)"
@toggle="
(on) => {
@@ -67,7 +68,7 @@
>
<template v-if="database.id != EMPTY_ID">
<h2 class="textlabel flex items-center col-span-1 col-start-1">
- Database<span v-if="$props.new" class="text-red-600">*</span>
+ Database
</h2>
<router-link
:to="`/db/${databaseSlug(database)}`"
@@ -313,6 +314,10 @@ export default {
);
});
+ const allowEditCustomField = (field: InputField) => {
+ return props.allowEdit && (props.new || field.allowEditAfterCreation);
+ };
+
const trySaveCustomField = (field: InputField, value: string | boolean) => {
if (!isEqual(value, fieldValue(field))) {
emit("update-custom-field", field, value);
@@ -344,13 +349,14 @@ export default {
return {
EMPTY_ID,
state,
- allowEditAssignee,
fieldValue,
environment,
database,
project,
isCurrentUserSubscribed,
subscriberList,
+ allowEditAssignee,
+ allowEditCustomField,
trySaveCustomField,
toggleSubscription,
};