Skip to content

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

Consolidate edit field logic into TaskDetail

天舟b764f57b69ba
diff --git a/frontend/src/views/TaskDescriptionPanel.vue b/frontend/src/views/TaskDescriptionPanel.vue
index 54fe13b5f4..6eab39cb84 100644
--- a/frontend/src/views/TaskDescriptionPanel.vue
+++ b/frontend/src/views/TaskDescriptionPanel.vue
@@ -2,7 +2,7 @@
<!-- Description Bar -->
<div v-if="!$props.new" class="flex justify-end space-x-2">
<button
- v-if="!state.edit"
+ v-if="allowEdit && !state.edit"
type="button"
class="btn-icon"
@click.prevent="beginEdit"
@@ -106,6 +106,10 @@ export default {
required: true,
type: Boolean,
},
+ allowEdit: {
+ required: true,
+ type: Boolean,
+ },
},
components: {},
setup(props, { emit }) {
diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vue
index 5bab55e510..25b26aa47c 100644
--- a/frontend/src/views/TaskDetail.vue
+++ b/frontend/src/views/TaskDetail.vue
@@ -9,6 +9,7 @@
<TaskHighlightPanel
:task="state.task"
:new="state.new"
+ :allowEdit="allowEditFields"
@update-name="updateName"
>
<template v-if="state.new">
@@ -90,6 +91,7 @@
:task="state.task"
:new="state.new"
:fieldList="inputFieldList"
+ :allowEdit="allowEditFields"
@start-status-transition="tryStartTaskStatusTransition"
@update-assignee-id="updateAssigneeId"
@update-custom-field="updateCustomField"
@@ -100,6 +102,7 @@
<TaskDescriptionPanel
:task="state.task"
:new="state.new"
+ :allowEdit="allowEditFields"
@update-description="updateDescription"
/>
<section
@@ -540,6 +543,28 @@ export default {
return true;
});
+ // We may consider consolidating all the editing logic in one place. But for now
+ // this controls editing "name, description and all custom fields".
+ // On the other hand:
+ // - Who can change task status is defined in a separate logic in this component
+ // - Who can change stage status is defined in TaskStageFlow
+ // - Who can reassign task is defined in TaskSidebar
+ // - Who can change output field value is defined in TaskSidebar
+ // - Anyone can comment
+ // - Anyone can subscribe / unsubscribe
+ const allowEditFields = computed(() => {
+ // For now, we allow creator and assignee to update the field any time.
+ // This may cause potential issue that the creator might change some of the
+ // fields after the assignee starts the work.
+ // In the future, we could provide options to enforce more strict rules
+ // e.g. disallow changing a particular field at a particular stage by a particular role.
+ return (
+ state.new ||
+ currentUser.value.id == (state.task as Task).assignee?.id ||
+ currentUser.value.id == (state.task as Task).creator.id
+ );
+ });
+
const showTaskStageFlowBar = computed(() => {
return !state.new && state.task.stageProgressList.length > 1;
});
@@ -585,6 +610,7 @@ export default {
taskTemplate,
outputFieldList,
inputFieldList,
+ allowEditFields,
showTaskStageFlowBar,
showTaskOutputPanel,
applicableStatusTransitionList,
diff --git a/frontend/src/views/TaskHighlightPanel.vue b/frontend/src/views/TaskHighlightPanel.vue
index 41629752d0..5bbbbf346f 100644
--- a/frontend/src/views/TaskHighlightPanel.vue
+++ b/frontend/src/views/TaskHighlightPanel.vue
@@ -12,6 +12,7 @@
</div>
<BBTextField
class="ml-2 my-0.5 w-full text-lg font-bold"
+ :disabled="!allowEdit"
:required="true"
:bordered="false"
:value="state.name"
@@ -63,6 +64,10 @@ export default {
required: true,
type: Boolean,
},
+ allowEdit: {
+ required: true,
+ type: Boolean,
+ },
},
components: { TaskStatusIcon },
setup(props, { emit }) {
diff --git a/frontend/src/views/TaskSidebar.vue b/frontend/src/views/TaskSidebar.vue
index 8514ac199a..46b687b21f 100644
--- a/frontend/src/views/TaskSidebar.vue
+++ b/frontend/src/views/TaskSidebar.vue
@@ -39,7 +39,7 @@
</h2>
<BBTextField
class="w-full mt-4 text-sm"
- :disabled="!allowEditCustomFields"
+ :disabled="!allowEdit"
:required="true"
:value="fieldValue(field)"
:placeholder="field.placeholder"
@@ -53,7 +53,7 @@
</h2>
<div class="w-full">
<EnvironmentSelect
- :disabled="!allowEditCustomFields"
+ :disabled="!allowEdit"
:name="field.id"
:selectedId="fieldValue(field)"
:selectDefault="false"
@@ -72,7 +72,7 @@
</h2>
<div class="w-full">
<DatabaseSelect
- :disabled="!environmentId() || !allowEditCustomFields"
+ :disabled="!environmentId() || !allowEdit"
:selectedId="fieldValue(field)"
:environmentId="environmentId()"
@select-database-id="
@@ -91,7 +91,7 @@
<div class="flex flex-col w-full">
<div class="flex flex-row space-x-2">
<BBCheckbox
- :disabled="!allowEditCustomFields"
+ :disabled="!allowEdit"
:label="'New'"
:value="fieldValue(field).isNew"
class="items-center"
@@ -105,7 +105,7 @@
v-if="fieldValue(field).isNew"
type="text"
class="w-full text-sm"
- :disabled="!allowEditCustomFields"
+ :disabled="!allowEdit"
:required="true"
:value="fieldValue(field).name"
:placeholder="field.placeholder"
@@ -113,7 +113,7 @@
/>
<DatabaseSelect
v-else
- :disabled="!environmentId() || !allowEditCustomFields"
+ :disabled="!environmentId() || !allowEdit"
:selectedId="fieldValue(field).id"
:environmentId="environmentId()"
@select-database-id="
@@ -127,7 +127,7 @@
v-if="!fieldValue(field).isNew"
class="mt-4 flex"
style="margin-left: 3.75rem"
- :disabled="!allowEditCustomFields"
+ :disabled="!allowEdit"
:label="'Read only'"
:value="fieldValue(field).readOnly"
@toggle="
@@ -145,7 +145,7 @@
</h2>
<div class="flex justify-start">
<BBSwitch
- :disabled="!allowEditCustomFields"
+ :disabled="!allowEdit"
:value="fieldValue(field)"
@toggle="
(on) => {
@@ -229,6 +229,10 @@ export default {
required: true,
type: Object as PropType<TaskField[]>,
},
+ allowEdit: {
+ required: true,
+ type: Boolean,
+ },
},
components: {
DatabaseSelect,
@@ -264,19 +268,6 @@ export default {
);
});
- const allowEditCustomFields = computed(() => {
- // For now, we allow creator and assignee to update the field any time.
- // This may cause potential issue that the creator might change some of the
- // fields after the assignee starts the work.
- // In the future, we could provide options to enforce more strict rules
- // e.g. disallow changing a particular field at a particular stage by a particular role.
- return (
- props.new ||
- currentUser.value.id == props.task.assignee?.id ||
- currentUser.value.id == props.task.creator.id
- );
- });
-
const trySaveCustomField = (
field: TaskField,
value: string | EnvironmentId | DatabaseFieldPayload
@@ -321,7 +312,6 @@ export default {
return {
state,
allowEditAssignee,
- allowEditCustomFields,
fieldValue,
environmentId,
trySaveCustomField,