Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Extract to TaskStatusIcon component and use it in both TaskTable and TaskDetail
Tianzhou Chen83fd6fe72692
diff --git a/frontend/src/components/TaskStatusIcon.vue b/frontend/src/components/TaskStatusIcon.vuenew file mode 100644index 0000000000..d1d57c1660--- /dev/null+++ b/frontend/src/components/TaskStatusIcon.vue@@ -0,0 +1,100 @@+<template>+ <span+ class="w-5 h-5 flex items-center justify-center rounded-full select-none"+ :class="taskIconClass(task)"+ >+ <template v-if="task.attributes.status == `OPEN`">+ <span+ v-if="activeStage(task).status == 'RUNNING'"+ class="h-2 w-2 bg-blue-600 hover:bg-blue-700 rounded-full"+ style="animation: pulse 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite"+ aria-hidden="true"+ ></span>+ <span+ v-else-if="activeStage(task).status == 'FAILED'"+ class="h-2 w-2 rounded-full text-center pb-6 font-normal text-base"+ aria-hidden="true"+ >!</span+ >+ <span+ v-else+ class="h-1.5 w-1.5 bg-blue-600 hover:bg-blue-700 rounded-full"+ aria-hidden="true"+ ></span>+ </template>+ <template v-else-if="task.attributes.status == `DONE`">+ <svg+ class="w-4 h-4"+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 20 20"+ fill="currentColor"+ aria-hidden="true"+ >+ <path+ fill-rule="evenodd"+ d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"+ clip-rule="evenodd"+ />+ </svg>+ </template>+ <template v-else-if="task.attributes.status == `CANCELED`">+ <svg+ class="w-5 h-5"+ fill="currentColor"+ viewBox="0 0 20 20"+ xmlns="http://www.w3.org/2000/svg"+ aria-hidden="true"+ >+ >+ <path+ fill-rule="evenodd"+ d="M3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"+ clip-rule="evenodd"+ ></path>+ </svg>+ </template>+ </span>+</template>++<script lang="ts">+import { PropType } from "vue";+import { activeStage } from "../utils";+import { Task } from "../types";++export default {+ name: "TaskStatusIcon",+ props: {+ task: {+ required: true,+ type: Object as PropType<Task>,+ },+ },+ components: {},+ setup(props, ctx) {+ const taskIconClass = (task: Task) => {+ switch (task.attributes.status) {+ case "OPEN":+ switch (activeStage(task).status) {+ case "FAILED":+ return "bg-error text-white hover:text-white hover:bg-error-hover";+ case "RUNNING":+ case "PENDING":+ case "DONE":+ case "CANCELED":+ case "SKIPPED":+ return "bg-white border-2 border-blue-600 text-blue-600 hover:text-blue-700 hover:border-blue-700";+ }+ case "CANCELED":+ return "bg-white border-2 text-gray-400 border-gray-400 hover:text-gray-500 hover:border-gray-500";+ case "DONE":+ return "bg-success hover:bg-success-hover text-white";+ }+ };++ return {+ taskIconClass,+ activeStage,+ };+ },+};+</script>diff --git a/frontend/src/components/TaskTable.vue b/frontend/src/components/TaskTable.vueindex d0000bb80b..57607ec108 100644--- a/frontend/src/components/TaskTable.vue+++ b/frontend/src/components/TaskTable.vue@@ -7,63 +7,7 @@><template v-slot:body="{ rowData: task }"><BBTableCell :leftPadding="4" class="w-4 table-cell">- <span- class="w-5 h-5 flex items-center justify-center rounded-full"- :class="taskIconClass(task)"- >- <template v-if="task.attributes.status == `OPEN`">- <span- v-if="activeStage(task).status == 'RUNNING'"- class="h-2 w-2 bg-blue-600 hover:bg-blue-700 rounded-full"- style="- animation: pulse 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;- "- aria-hidden="true"- ></span>- <span- v-else-if="activeStage(task).status == 'FAILED'"- class="h-2 w-2 rounded-full text-center pb-6 font-normal text-base"- aria-hidden="true"- >!</span- >- <span- v-else- class="h-1.5 w-1.5 bg-blue-600 hover:bg-blue-700 rounded-full"- aria-hidden="true"- ></span>- </template>- <template v-else-if="task.attributes.status == `DONE`">- <svg- class="w-4 h-4"- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 20 20"- fill="currentColor"- aria-hidden="true"- >- <path- fill-rule="evenodd"- d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"- clip-rule="evenodd"- />- </svg>- </template>- <template v-else-if="task.attributes.status == `CANCELED`">- <svg- class="w-5 h-5"- fill="currentColor"- viewBox="0 0 20 20"- xmlns="http://www.w3.org/2000/svg"- aria-hidden="true"- >- >- <path- fill-rule="evenodd"- d="M3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"- clip-rule="evenodd"- ></path>- </svg>- </template>- </span>+ <TaskStatusIcon :task="task" /></BBTableCell><BBTableCell class="w-4 table-cell text-gray-500">@@ -109,6 +53,7 @@ import {BBStep,BBStepStatus,} from "../bbkit/types";+import TaskStatusIcon from "../components/TaskStatusIcon.vue";import { humanize, taskSlug, activeEnvironmentId, activeStage } from "../utils";import { EnvironmentId, Task } from "../types";@@ -119,7 +64,7 @@ interface LocalState {export default {name: "TaskTable",- components: {},+ components: { TaskStatusIcon },props: {taskSectionList: {required: true,@@ -202,26 +147,6 @@ export default {});};- const taskIconClass = (task: Task) => {- switch (task.attributes.status) {- case "OPEN":- switch (activeStage(task).status) {- case "FAILED":- return "bg-error text-white hover:text-white hover:bg-error-hover";- case "RUNNING":- case "PENDING":- case "DONE":- case "CANCELED":- case "SKIPPED":- return "bg-white border-2 border-blue-600 text-blue-600 hover:text-blue-700 hover:border-blue-700";- }- case "CANCELED":- return "bg-white border-2 text-gray-400 border-gray-400 hover:text-gray-500 hover:border-gray-500";- case "DONE":- return "bg-success hover:bg-success-hover text-white";- }- };-const clickTask = function (section: number, row: number) {const task = props.taskSectionList[section].list[row];router.push(`/task/${taskSlug(task.attributes.name, task.id)}`);@@ -231,7 +156,6 @@ export default {state,environmentName,stageList,- taskIconClass,humanize,activeEnvironmentId,activeStage,diff --git a/frontend/src/views/TaskHighlightPanel.vue b/frontend/src/views/TaskHighlightPanel.vueindex eba055f489..3027339291 100644--- a/frontend/src/views/TaskHighlightPanel.vue+++ b/frontend/src/views/TaskHighlightPanel.vue@@ -4,13 +4,13 @@class="px-4 py-6 md:flex md:items-center md:justify-between lg:border-t lg:border-block-border"><div class="flex-1 min-w-0">- <!-- Profile --><div class="flex items-center"><div><div class="flex items-center">+ <TaskStatusIcon :task="task" /><!-- [TODO] overflow-ellipsis/clip doesn't seem to be working, so just use nowrap --><p- class="text-2xl font-bold leading-7 text-gray-900 sm:leading-9 whitespace-nowrap"+ class="ml-1 text-2xl font-bold leading-7 text-gray-900 sm:leading-9 whitespace-nowrap">{{ task.attributes.name }}</p>@@ -40,6 +40,7 @@<script lang="ts">import { PropType, watchEffect, reactive } from "vue";import isEmpty from "lodash-es/isEmpty";+import TaskStatusIcon from "../components/TaskStatusIcon.vue";import { Task } from "../types";interface LocalState {@@ -54,7 +55,7 @@ export default {type: Object as PropType<Task>,},},- components: {},+ components: { TaskStatusIcon },setup(props, ctx) {const state = reactive<LocalState>({new: isEmpty(props.task.id),