Skip to content

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

fix: display error concerning timing (#246)

Luke Zhoubd26b01f0688
diff --git a/frontend/src/components/IssueSidebar.vue b/frontend/src/components/IssueSidebar.vue
index 735809bf35..83f6dd519f 100644
--- a/frontend/src/components/IssueSidebar.vue
+++ b/frontend/src/components/IssueSidebar.vue
@@ -35,36 +35,6 @@
/>
</div>
- <h2 class="textlabel flex items-center col-span-1 col-start-1">
- {{ $t("common.when") }}
- <div class="tooltip-wrapper">
- <span class="tooltip w-60">{{
- $t("task.earliest-allowed-time-hint")
- }}</span>
- <!-- Heroicons name: outline/question-mark-circle -->
- <heroicons-outline:question-mark-circle class="h-4 w-4" />
- </div>
- </h2>
- <div class="col-span-2">
- <n-date-picker
- v-if="allowEditEarliestAllowedTime"
- v-model:value="state.earliestAllowedTs"
- :is-date-disabled="isDayPassed"
- :placeholder="$t('task.earliest-allowed-time-unset')"
- class="w-full"
- type="datetime"
- clearable
- @update:value="
- (newTimestampNs) => {
- $emit('update-earliest-allowed-time', newTimestampNs / 1000);
- }
- "
- />
- <span v-else class="textfield col-span-2">
- {{ moment(task.earliestAllowedTs * 1000).format("LLL") }}</span
- >
- </div>
-
<template v-for="(field, index) in inputFieldList" :key="index">
<h2 class="textlabel flex items-center col-span-1 col-start-1">
{{ field.name }}
@@ -111,6 +81,43 @@
</div>
</template>
+ <h2 class="textlabel flex items-center col-span-1 col-start-1">
+ {{ $t("common.when") }}
+ <div class="tooltip-wrapper">
+ <span class="tooltip w-60">{{
+ $t("task.earliest-allowed-time-hint")
+ }}</span>
+ <!-- Heroicons name: outline/question-mark-circle -->
+ <heroicons-outline:question-mark-circle class="h-4 w-4" />
+ </div>
+ </h2>
+ <div class="col-span-2">
+ <n-date-picker
+ v-if="allowEditEarliestAllowedTime"
+ :value="
+ state.earliestAllowedTs ? state.earliestAllowedTs * 1000 : null
+ "
+ :is-date-disabled="isDayPassed"
+ :placeholder="$t('task.earliest-allowed-time-unset')"
+ class="w-full"
+ type="datetime"
+ clearable
+ @update:value="
+ (newTimestampNs) => {
+ state.earliestAllowedTs = newTimestampNs / 1000;
+ $emit('update-earliest-allowed-time', newTimestampNs / 1000);
+ }
+ "
+ />
+ <span v-else class="textfield col-span-2">
+ {{
+ task.earliestAllowedTs === 0
+ ? $t("task.earliest-allowed-time-unset")
+ : moment(task.earliestAllowedTs * 1000).format("LLL")
+ }}</span
+ >
+ </div>
+
<template v-if="databaseName">
<h2 class="textlabel flex items-center col-span-1 col-start-1">
{{ $t("common.database") }}
@@ -215,7 +222,7 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType, reactive } from "vue";
+import { computed, defineComponent, PropType, reactive, watch } from "vue";
import { useStore } from "vuex";
import isEqual from "lodash-es/isEqual";
import { NDatePicker } from "naive-ui";
@@ -247,7 +254,9 @@ import { useRouter } from "vue-router";
import moment from "moment";
// eslint-disable-next-line @typescript-eslint/no-empty-interface
-interface LocalState {}
+interface LocalState {
+ earliestAllowedTs: number | null;
+}
export default defineComponent({
name: "IssueSidebar",
@@ -309,10 +318,19 @@ export default defineComponent({
const now = new Date();
const state = reactive<LocalState>({
earliestAllowedTs: props.task.earliestAllowedTs
- ? props.task.earliestAllowedTs * 1000
+ ? props.task.earliestAllowedTs
: null,
});
+ watch(
+ () => props.task,
+ (cur) => {
+ state.earliestAllowedTs = cur.earliestAllowedTs
+ ? cur.earliestAllowedTs
+ : null;
+ }
+ );
+
const currentUser = computed(() => store.getters["auth/currentUser"]());
const fieldValue = (field: InputField): string => {
@@ -371,26 +389,30 @@ export default defineComponent({
});
const allowEditAssignee = computed(() => {
+ const issue = props.issue as Issue;
// We allow the current assignee or DBA to re-assign the issue.
// Though only DBA can be assigned to the issue, the current
// assignee might not have DBA role in case its role is revoked after
// being assigned to the issue.
return (
props.create ||
- ((props.issue as Issue).id != ONBOARDING_ISSUE_ID &&
- (props.issue as Issue).status == "OPEN" &&
- (currentUser.value.id == (props.issue as Issue).assignee?.id ||
+ (issue.id != ONBOARDING_ISSUE_ID &&
+ issue.status == "OPEN" &&
+ (currentUser.value.id == issue.assignee?.id ||
isDBAOrOwner(currentUser.value.role)))
);
});
const allowEditEarliestAllowedTime = computed(() => {
+ const issue = props.issue as Issue;
+ const task = props.task as Task;
// only the assignee is allowed to modify EarliestAllowedTime
return (
props.create ||
- ((props.issue as Issue).id != ONBOARDING_ISSUE_ID &&
- (props.issue as Issue).status == "OPEN" &&
- currentUser.value.id == (props.issue as Issue).assignee?.id)
+ (issue.id != ONBOARDING_ISSUE_ID &&
+ issue.status == "OPEN" &&
+ (task.status == "PENDING" || task.status == "PENDING_APPROVAL") &&
+ currentUser.value.id == issue.assignee?.id)
);
});