Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(bbkit): refactor bbkit using modern vue APIs (#522)
Liu Ji3e10036f15f0
diff --git a/frontend/src/bbkit/BBNotification.vue b/frontend/src/bbkit/BBNotification.vueindex dac970e71d..27f9b1e50a 100644--- a/frontend/src/bbkit/BBNotification.vue+++ b/frontend/src/bbkit/BBNotification.vue@@ -8,15 +8,15 @@:key="index"><!--- Notification panel, show/hide based on alert state.+ Notification panel, show/hide based on alert state.- Entering: "transform ease-out duration-300 transition"- From: "translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"- To: "translate-y-0 opacity-100 sm:translate-x-0"- Leaving: "transition ease-in duration-100"- From: "opacity-100"- To: "opacity-0"- -->+ Entering: "transform ease-out duration-300 transition"+ From: "translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"+ To: "translate-y-0 opacity-100 sm:translate-x-0"+ Leaving: "transition ease-in duration-100"+ From: "opacity-100"+ To: "opacity-0"+ --><transitionenter-active-class="transform ease-out duration-300 transition"enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"@@ -26,31 +26,30 @@leave-to-class="opacity-0"><div- class="- max-w-sm- w-full- bg-white- shadow-lg- rounded-lg- pointer-events-auto- ring-1 ring-black ring-opacity-5- overflow-hidden- "+ class="max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden"><div class="p-4"><div class="flex items-start"><div class="flex-shrink-0"><template v-if="notification.style == 'SUCCESS'">- <heroicons-outline:check-circle class="h-6 w-6 text-success" />+ <heroicons-outline:check-circle+ class="h-6 w-6 text-success"+ /></template><template v-else-if="notification.style == 'WARN'">- <heroicons-outline:exclamation class="h-6 w-6 text-yellow-600" />+ <heroicons-outline:exclamation+ class="h-6 w-6 text-yellow-600"+ /></template><template v-else-if="notification.style == 'CRITICAL'">- <heroicons-outline:exclamation-circle class="h-6 w-6 text-red-600" />+ <heroicons-outline:exclamation-circle+ class="h-6 w-6 text-red-600"+ /></template><template v-else>- <heroicons-outline:information-circle class="w-6 h-6 text-blue-600" />+ <heroicons-outline:information-circle+ class="w-6 h-6 text-blue-600"+ /></template></div><div class="ml-3 w-0 flex-1 pt-0.5">@@ -64,36 +63,13 @@</p><div v-if="notification.link" class="mt-2"><button- class="- bg-white- rounded-md- text-sm- font-medium- text-accent- hover:text-accent-hover- focus:outline-none- focus:ring-2- focus:ring-offset-2- focus:ring-accent- "+ class="bg-white rounded-md text-sm font-medium text-accent hover:text-accent-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent"@click.prevent="viewLink(notification.link)">{{ notification.linkTitle }}</button><button- class="- ml-6- bg-white- rounded-md- text-sm- font-medium- text-gray-700- hover:text-gray-500- focus:outline-none- focus:ring-2- focus:ring-offset-2- focus:ring-accent- "+ class="ml-6 bg-white rounded-md text-sm font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent"@click.prevent="$emit('close', notification)">Dismiss@@ -102,14 +78,7 @@</div><div class="ml-4 flex-shrink-0 flex"><button- class="- bg-white- rounded-md- inline-flex- text-gray-400- hover:text-gray-500- focus:outline-none- "+ class="bg-white rounded-md inline-flex text-gray-400 hover:text-gray-500 focus:outline-none"@click.prevent="$emit('close', notification)"><span class="sr-only">Close</span>@@ -125,8 +94,8 @@</div></template>-<script lang="ts">-import { PropType } from "vue";+<script lang="ts" setup>+import { defineProps, defineEmits, withDefaults, computed } from "vue";import { useRouter } from "vue-router";import { BBNotificationPlacement, BBNotificationItem } from "./types";@@ -150,31 +119,25 @@ const placementClassMap: Map<BBNotificationPlacement, string> = new Map([],]);-export default {- name: "BBNotification",- props: {- notificationList: {- required: true,- type: Object as PropType<BBNotificationItem[]>,- },- placement: {- type: String as PropType<BBNotificationPlacement>,- default: "TOP_RIGHT",- },- },- emits: ["close"],- setup(props, { emit }) {- const router = useRouter();+const props = withDefaults(+ defineProps<{+ notificationList: BBNotificationItem[];+ placement?: BBNotificationPlacement;+ }>(),+ {+ placement: "TOP_RIGHT",+ }+);- const viewLink = (link: string) => {- router.push(link);- emit("close");- };+const emit = defineEmits<{+ (event: "close", notification?: BBNotificationItem): void;+}>();- return {- placementClass: placementClassMap.get(props.placement),- viewLink,- };- },+const router = useRouter();++const viewLink = (link: string) => {+ router.push(link);+ emit("close");};+const placementClass = computed(() => placementClassMap.get(props.placement));</script>diff --git a/frontend/src/bbkit/BBOutline.vue b/frontend/src/bbkit/BBOutline.vueindex e6b57ffbfc..c9c13658f9 100644--- a/frontend/src/bbkit/BBOutline.vue+++ b/frontend/src/bbkit/BBOutline.vue@@ -10,35 +10,14 @@<template v-if="allowCollapse && state.hoverTitle"><svgv-if="collapseState"- class="- mr-2- h-4- w-4- transform- group-hover:text-gray-400- group-focus:text-gray-400- transition-colors- ease-in-out- duration-150- "+ class="mr-2 h-4 w-4 transform group-hover:text-gray-400 group-focus:text-gray-400 transition-colors ease-in-out duration-150"viewBox="0 0 20 20"><path d="M6 6L14 10L6 14V6Z" fill="currentColor" /></svg><svgv-else- class="- mr-2- h-4- w-4- transform- rotate-90- group-hover:text-gray-400- group-focus:text-gray-400- transition-colors- ease-in-out- duration-150- "+ class="mr-2 h-4 w-4 transform rotate-90 group-hover:text-gray-400 group-focus:text-gray-400 transition-colors ease-in-out duration-150"viewBox="0 0 20 20"><path d="M6 6L14 10L6 14V6Z" fill="currentColor" />@@ -81,95 +60,83 @@</div></template>-<script lang="ts">+<script lang="ts" setup>+import {+ computed,+ reactive,+ defineProps,+ defineEmits,+ withDefaults,+} from "vue";+import { useStore } from "vuex";+import { BBOutlineItem } from "./types";+interface LocalState {hoverIndex: number;hoverTitle: boolean;collapseState: boolean;}-import { computed, reactive, PropType } from "vue";-import { useStore } from "vuex";-import { BBOutlineItem } from "./types";--export default {- name: "BBOutline",- props: {+const props = withDefaults(+ defineProps<{// Used for storing the collapse state.// Empty id means not to store collapse state.- id: {- default: "",- type: String,- },- title: {- required: true,- type: String,- },- itemList: {- required: true,- type: Object as PropType<BBOutlineItem[]>,- },- allowDelete: {- default: false,- type: Boolean,- },- allowCollapse: {- default: false,- type: Boolean,- },- level: {- default: 0,- type: Number,- },- },- emits: ["delete-index"],- setup(props) {- const store = useStore();+ id?: string;+ title: string;+ itemList: BBOutlineItem[];+ allowDelete?: boolean;+ allowCollapse?: boolean;+ level?: number;+ }>(),+ {+ id: "",+ allowDelete: false,+ allowCollapse: false,+ level: 0,+ }+);- const state = reactive<LocalState>({- hoverIndex: -1,- hoverTitle: false,- collapseState: true,- });+defineEmits<{+ (event: "delete-index", index: number): void;+}>();- const collapseState = computed(() => {- if (props.id) {- return store.getters["uistate/collapseStateByKey"](props.id);- }- return state.collapseState;- });+const store = useStore();- const toggleCollapse = () => {- if (props.allowCollapse) {- if (props.id) {- const newState = !collapseState.value;- store.dispatch("uistate/savecollapseStateByKey", {- key: props.id,- collapse: newState,- });- } else {- state.collapseState = !state.collapseState;- }- }- };+const state = reactive<LocalState>({+ hoverIndex: -1,+ hoverTitle: false,+ collapseState: true,+});- const dynamicItemClass = () => {- let list = [];- if (props.level == 0) {- list.push("toplevel");- }- if (props.allowCollapse) {- list.push("collapsible");- }- return list.join(" ");- };+const collapseState = computed(() => {+ if (props.id) {+ return store.getters["uistate/collapseStateByKey"](props.id);+ }+ return state.collapseState;+});++const toggleCollapse = () => {+ if (props.allowCollapse) {+ if (props.id) {+ const newState = !collapseState.value;+ store.dispatch("uistate/savecollapseStateByKey", {+ key: props.id,+ collapse: newState,+ });+ } else {+ state.collapseState = !state.collapseState;+ }+ }+};- return {- state,- collapseState,- dynamicItemClass,- toggleCollapse,- };- },+const dynamicItemClass = () => {+ let list = [];+ if (props.level == 0) {+ list.push("toplevel");+ }+ if (props.allowCollapse) {+ list.push("collapsible");+ }+ return list.join(" ");};</script>diff --git a/frontend/src/bbkit/BBSpin.vue b/frontend/src/bbkit/BBSpin.vueindex 172af24bb1..2db1d9dafa 100644--- a/frontend/src/bbkit/BBSpin.vue+++ b/frontend/src/bbkit/BBSpin.vue@@ -24,15 +24,10 @@</div></template>-<script lang="ts">-export default {- name: "BBSpin",- components: {},- props: {- title: {- default: "",- type: String,- },- },-};+<script lang="ts" setup>+import { defineProps, withDefaults } from "vue";++withDefaults(defineProps<{ title?: string }>(), {+ title: "",+});</script>diff --git a/frontend/src/bbkit/BBStepBar.vue b/frontend/src/bbkit/BBStepBar.vueindex 3880e5f2b1..e88c8601ab 100644--- a/frontend/src/bbkit/BBStepBar.vue+++ b/frontend/src/bbkit/BBStepBar.vue@@ -48,15 +48,7 @@</template><template v-else-if="step.status == `FAILED`"><span- class="- h-2.5- w-2.5- rounded-full- text-center- pb-6- font-medium- text-base- "+ class="h-2.5 w-2.5 rounded-full text-center pb-6 font-medium text-base"aria-hidden="true">!</span>@@ -73,46 +65,38 @@</nav></template>-<script lang="ts">-import { PropType } from "vue";+<script lang="ts" setup>+import { defineProps, defineEmits } from "vue";import { BBStep, BBStepStatus } from "./types";-export default {- name: "BBStepBar",- props: {- stepList: {- required: true,- type: Array as PropType<BBStep[]>,- },- },- emits: ["click-step"],- setup() {- const stepClass = (status: BBStepStatus) => {- switch (status) {- case "PENDING":- return "bg-white border-2 border-control hover:border-control-hover";- case "PENDING_ACTIVE":- return "bg-white border-2 border-blue-600 text-blue-600 hover:text-blue-700 hover:border-blue-700";- case "PENDING_APPROVAL":- return "bg-white border-2 border-control hover:border-control-hover";- case "PENDING_APPROVAL_ACTIVE":- return "bg-white border-2 border-blue-600 text-blue-600 hover:text-blue-700 hover:border-blue-700";- case "RUNNING":- return "bg-white border-2 border-blue-600 text-blue-600 hover:text-blue-700 hover:border-blue-700";- case "DONE":- return "bg-success hover:bg-success-hover text-white";- case "FAILED":- return "bg-error hover:bg-error-hover text-white";- case "CANCELED":- return "bg-white border-2 text-gray-400 border-gray-400 hover:text-gray-500 hover:border-gray-500";- case "SKIPPED":- return "bg-white border-2 text-gray-300 border-gray-300 hover:text-gray-400 hover:border-gray-400";- }- };+defineProps<{+ stepList: BBStep[];+}>();++defineEmits<{+ (event: "click-step", step: BBStep): void;+}>();- return {- stepClass,- };- },+const stepClass = (status: BBStepStatus) => {+ switch (status) {+ case "PENDING":+ return "bg-white border-2 border-control hover:border-control-hover";+ case "PENDING_ACTIVE":+ return "bg-white border-2 border-blue-600 text-blue-600 hover:text-blue-700 hover:border-blue-700";+ case "PENDING_APPROVAL":+ return "bg-white border-2 border-control hover:border-control-hover";+ case "PENDING_APPROVAL_ACTIVE":+ return "bg-white border-2 border-blue-600 text-blue-600 hover:text-blue-700 hover:border-blue-700";+ case "RUNNING":+ return "bg-white border-2 border-blue-600 text-blue-600 hover:text-blue-700 hover:border-blue-700";+ case "DONE":+ return "bg-success hover:bg-success-hover text-white";+ case "FAILED":+ return "bg-error hover:bg-error-hover text-white";+ case "CANCELED":+ return "bg-white border-2 text-gray-400 border-gray-400 hover:text-gray-500 hover:border-gray-500";+ case "SKIPPED":+ return "bg-white border-2 text-gray-300 border-gray-300 hover:text-gray-400 hover:border-gray-400";+ }};</script>diff --git a/frontend/src/bbkit/BBStepTab.vue b/frontend/src/bbkit/BBStepTab.vueindex cc78a63ea3..eea6b8ac32 100644--- a/frontend/src/bbkit/BBStepTab.vue+++ b/frontend/src/bbkit/BBStepTab.vue@@ -92,8 +92,8 @@</div></template>-<script lang="ts">-import { PropType, reactive } from "vue";+<script lang="ts" setup>+import { reactive, defineProps, defineEmits, withDefaults } from "vue";import { BBStepTabItem } from "./types";interface LocalState {@@ -101,55 +101,51 @@ interface LocalState {currentStep: number;}-export default {- name: "BBStepTab",- props: {- stepItemList: {- required: true,- type: Object as PropType<BBStepTabItem[]>,- },- allowNext: {- default: true,- type: Boolean,- },- finishTitle: {- default: "bbkit.common.finish",- type: String,- },- },- // For try-change-step and try-finish listener, it needs to call the callback if it determines we can change the step.- emits: ["try-change-step", "try-finish", "cancel"],- setup(props, { emit }) {- const state = reactive<LocalState>({- done: false,- currentStep: 0,- });+withDefaults(+ defineProps<{+ stepItemList: BBStepTabItem[];+ allowNext?: boolean;+ finishTitle?: string;+ }>(),+ {+ allowNext: true,+ finishTitle: "bbkit.common.finish",+ }+);- const changeStep = (step: number) => {- const changeStepCallback = () => {- state.done = false;- state.currentStep = step;- };- emit("try-change-step", state.currentStep, step, changeStepCallback);- };+// For try-change-step and try-finish listener, it needs to call the callback if it determines we can change the step.+const emit = defineEmits<{+ (+ event: "try-change-step",+ from: number,+ to: number,+ allowChangeCallback: () => void+ ): void;+ (event: "try-finish", finishCallback: () => void): void;+ (event: "cancel"): void;+}>();- const finish = () => {- const finishCallback = () => {- state.done = true;- };- emit("try-finish", finishCallback);- };+const state = reactive<LocalState>({+ done: false,+ currentStep: 0,+});- const cancel = () => {- emit("cancel");- };+const changeStep = (step: number) => {+ const changeStepCallback = () => {+ state.done = false;+ state.currentStep = step;+ };+ emit("try-change-step", state.currentStep, step, changeStepCallback);+};++const finish = () => {+ const finishCallback = () => {+ state.done = true;+ };+ emit("try-finish", finishCallback);+};- return {- state,- changeStep,- finish,- cancel,- };- },+const cancel = () => {+ emit("cancel");};</script>diff --git a/frontend/src/bbkit/BBSwitch.vue b/frontend/src/bbkit/BBSwitch.vueindex 01b6143830..efe862764a 100644--- a/frontend/src/bbkit/BBSwitch.vue+++ b/frontend/src/bbkit/BBSwitch.vue@@ -2,22 +2,7 @@<div class="flex items-center"><buttontype="button"- class="- relative- inline-flex- flex-shrink-0- h-6- w-11- border-2 border-transparent- rounded-full- cursor-pointer- transition-colors- ease-in-out- duration-200- focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent- disabled:cursor-not-allowed- select-none- "+ class="relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-accent disabled:cursor-not-allowed select-none":class="on ? 'bg-accent disabled:bg-accent-disabled' : 'bg-gray-200'":disabled="disabled"aria-pressed="false"@@ -32,20 +17,7 @@<!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" --><spanaria-hidden="true"- class="- pointer-events-none- inline-block- h-5- w-5- rounded-full- bg-white- shadow- transform- ring-0- transition- ease-in-out- duration-200- "+ class="pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200":class="on ? 'translate-x-5' : 'translate-x-0'"></span></button>@@ -59,37 +31,32 @@</div></template>-<script lang="ts">-import { ref, watch } from "vue";+<script lang="ts" setup>+import { ref, watch, defineProps, defineEmits, withDefaults } from "vue";++const props = withDefaults(+ defineProps<{+ label?: string;+ value?: boolean;+ disabled?: boolean;+ }>(),+ {+ label: "",+ value: true,+ disabled: false,+ }+);-export default {- name: "BBSwitch",- props: {- label: {- default: "",- type: String,- },- value: {- default: true,- type: Boolean,- },- disabled: {- default: false,- type: Boolean,- },- },- emits: ["toggle"],- setup(props) {- var on = ref(props.value);+defineEmits<{+ (event: "toggle", on: boolean): void;+}>();- watch(- () => props.value,- (cur) => {- on.value = cur;- }- );+const on = ref(props.value);- return { on };- },-};+watch(+ () => props.value,+ (cur) => {+ on.value = cur;+ }+);</script>diff --git a/frontend/src/bbkit/BBTab.vue b/frontend/src/bbkit/BBTab.vueindex 22822bb0b7..787546acf8 100644--- a/frontend/src/bbkit/BBTab.vue+++ b/frontend/src/bbkit/BBTab.vue@@ -6,17 +6,7 @@:id="item.id":key="index":href="`#${item.id}`"- class="- select-none- cursor-pointer- flex- justify-between- py-2- px-1- font-medium- border-b-2 border-transparent- whitespace-nowrap- "+ class="select-none cursor-pointer flex justify-between py-2 px-1 font-medium border-b-2 border-transparent whitespace-nowrap":class="tabClass(index == selectedIndex)"@click.self="selectTabIndex(index)"@mouseenter="state.hoverIndex = index"@@ -29,13 +19,7 @@(reorderModel == 'HOVER' && state.hoverIndex == index))"type="button"- class="- text-control- hover:text-control-hover- focus:outline-none- focus-visible:ring-2- focus:ring-accent- "+ class="text-control hover:text-control-hover focus:outline-none focus-visible:ring-2 focus:ring-accent"@click.prevent="() => {selectTabIndex(index);@@ -54,13 +38,7 @@(reorderModel == 'HOVER' && state.hoverIndex == index))"type="button"- class="- text-control- hover:text-control-hover- focus:outline-none- focus-visible:ring-2- focus:ring-accent- "+ class="text-control hover:text-control-hover focus:outline-none focus-visible:ring-2 focus:ring-accent"@click.prevent="() => {selectTabIndex(index);@@ -75,16 +53,7 @@<buttonv-if="allowCreate"type="button"- class="- flex- justify-center- py-2- text-control- hover:text-control-hover- focus:outline-none- focus-visible:ring-2- focus:ring-accent- "+ class="flex justify-center py-2 text-control hover:text-control-hover focus:outline-none focus-visible:ring-2 focus:ring-accent":class="addTabClass()"@click.prevent="$emit('create')">@@ -95,68 +64,54 @@<slot /></template>-<script lang="ts">-import { reactive, PropType } from "vue";+<script lang="ts" setup>+import { reactive, defineProps, defineEmits, withDefaults } from "vue";import { BBTabItem } from "./types";-export default {- name: "BBTab",- props: {- tabItemList: {- required: true,- type: Object as PropType<BBTabItem[]>,- },- selectedIndex: {- required: true,- type: Number,- },- allowCreate: {- default: false,- type: Boolean,- },- reorderModel: {- default: "NEVER",- type: String as PropType<"NEVER" | "HOVER" | "ALWAYS">,- },- },- emits: ["create", "reorder-index", "select-index"],- setup(props, { emit }) {- const state = reactive({- hoverIndex: -1,- });+export type ReorderModel = "NEVER" | "HOVER" | "ALWAYS";++const props = withDefaults(+ defineProps<{+ tabItemList: BBTabItem[];+ selectedIndex: number;+ allowCreate?: boolean;+ reorderModel?: ReorderModel;+ }>(),+ {+ allowCreate: false,+ reorderModel: "NEVER",+ }+);- const tabClass = (selected: boolean) => {- const width =- "w-1/" + (props.tabItemList.length + (props.allowCreate ? 1 : 0));- if (selected) {- return width + " text-control-hover border-accent";- }- return (- width +- " text-control hover:text-control-hover hover:border-control-border"- );- };+const emit = defineEmits<{+ (event: "create"): void;+ (event: "reorder-index", from: number, to: number): void;+ (event: "select-index", index: number): void;+}>();- const addTabClass = () => {- if (props.tabItemList.length == 0) {- return "w-1/6 ";- }- return "w-1/12";- };+const state = reactive({+ hoverIndex: -1,+});- const selectTabIndex = (index: number) => {- emit("select-index", index);- };+const tabClass = (selected: boolean) => {+ const width =+ "w-1/" + (props.tabItemList.length + (props.allowCreate ? 1 : 0));+ if (selected) {+ return width + " text-control-hover border-accent";+ }+ return (+ width + " text-control hover:text-control-hover hover:border-control-border"+ );+};++const addTabClass = () => {+ if (props.tabItemList.length == 0) {+ return "w-1/6 ";+ }+ return "w-1/12";+};- return {- tabClass,- addTabClass,- selectTabIndex,- state,- };- },- data: function () {- return {};- },+const selectTabIndex = (index: number) => {+ emit("select-index", index);};</script>diff --git a/frontend/src/bbkit/BBTabFilter.vue b/frontend/src/bbkit/BBTabFilter.vueindex 2f40bb0789..c6f7239f96 100644--- a/frontend/src/bbkit/BBTabFilter.vue+++ b/frontend/src/bbkit/BBTabFilter.vue@@ -7,8 +7,8 @@name="tabs"class="control block w-full"@change="- (e) => {- $emit('select-index', parseInt(e.target.value));+ (e: any) => {+ $emit('select-index', parseInt(e.target.value, 10));}">@@ -34,29 +34,11 @@{{ item.title }}<spanv-if="item.alert"- class="- flex- items-center- justify-center- rounded-full- select-none- ml-2- w-4- h-4- text-white- "+ class="flex items-center justify-center rounded-full select-none ml-2 w-4 h-4 text-white":class="index == selectedIndex ? 'bg-gray-600' : 'bg-red-600'"><span- class="- h-2- w-2- rounded-full- text-center- pb-6- font-normal- text-base- "+ class="h-2 w-2 rounded-full text-center pb-6 font-normal text-base"aria-hidden="true">!</span>@@ -67,36 +49,29 @@</div></template>-<script lang="ts">-import { PropType } from "vue";+<script lang="ts" setup>+import { defineProps, defineEmits, withDefaults } from "vue";import { BBTabFilterItem } from "./types";-export default {- name: "BBTabFilter",- props: {- tabItemList: {- required: true,- type: Object as PropType<BBTabFilterItem[]>,- },- selectedIndex: {- required: true,- type: Number,- },- responsive: {- default: true,- type: Boolean,- },- },- emits: ["select-index"],- setup() {- const buttonClass = (selected: boolean) => {- if (selected) {- return "bg-gray-200 text-gray-800 whitespace-nowrap";- }- return "text-gray-500 hover:text-gray-700 whitespace-nowrap";- };+withDefaults(+ defineProps<{+ tabItemList: BBTabFilterItem[];+ selectedIndex: number;+ responsive?: boolean;+ }>(),+ {+ responsive: true,+ }+);- return { buttonClass };- },+defineEmits<{+ (event: "select-index", index: number): void;+}>();++const buttonClass = (selected: boolean) => {+ if (selected) {+ return "bg-gray-200 text-gray-800 whitespace-nowrap";+ }+ return "text-gray-500 hover:text-gray-700 whitespace-nowrap";};</script>diff --git a/frontend/src/bbkit/BBTabPanel.vue b/frontend/src/bbkit/BBTabPanel.vueindex 59f6dbfd0a..e9d1ecde52 100644--- a/frontend/src/bbkit/BBTabPanel.vue+++ b/frontend/src/bbkit/BBTabPanel.vue@@ -1,17 +1,11 @@<template>- <section v-if="active" :aria-hiddem="!active">+ <section v-if="active" :aria-hidden="!active"><slot /></section></template>-<script lang="ts">-export default {- name: "BBTabPanel",- props: {- active: {- required: true,- type: Boolean,- },- },-};+<script lang="ts" setup>+import { defineProps } from "vue";++defineProps<{ active: boolean }>();</script>diff --git a/frontend/src/bbkit/BBTable/BBTable.vue b/frontend/src/bbkit/BBTable/BBTable.vueindex 5da2d400dd..1d944215fd 100644--- a/frontend/src/bbkit/BBTable/BBTable.vue+++ b/frontend/src/bbkit/BBTable/BBTable.vue@@ -90,84 +90,65 @@</table></template>-<script lang="ts">-import { computed, defineComponent, PropType } from "vue";+<script lang="ts" setup>+import { computed, withDefaults, defineProps, defineEmits } from "vue";import { BBTableColumn, BBTableSectionDataSource } from "../types";-export default defineComponent({- name: "BBTable",- components: {},- props: {- columnList: {- type: Array as PropType<BBTableColumn[]>,- default: () => [],- },- dataSource: {- default: () => [],- type: Array as PropType<any[]>,- },- sectionDataSource: {- type: Array as PropType<BBTableSectionDataSource<any>[]>,- default: undefined,- },+type DataType = any; // vue does not support generic typed components yet++const props = withDefaults(+ defineProps<{+ columnList?: BBTableColumn[];+ dataSource?: DataType[];+ sectionDataSource?: BBTableSectionDataSource<DataType>[] | undefined;// Only applicable to sectionDataSource. If true, when there is only one// section, it won't render the extra section header. In another words, it will// just look like a non-section list.- compactSection: {- default: false,- type: Boolean,- },- showHeader: {- default: true,- type: Boolean,- },- customHeader: {- default: false,- type: Boolean,- },- rowClickable: {- default: true,- type: Boolean,- },- leftBordered: {- default: true,- type: Boolean,- },- rightBordered: {- default: true,- type: Boolean,- },- topBordered: {- default: true,- type: Boolean,- },- bottomBordered: {- default: true,- type: Boolean,- },- },- emits: ["click-row"],- setup(props) {- const borderVisibility = computed(() => {- const style = [];- if (props.leftBordered) {- style.push("border-l");- }+ compactSection?: boolean;+ showHeader?: boolean;+ customHeader?: boolean;+ rowClickable?: boolean;+ leftBordered?: boolean;+ rightBordered?: boolean;+ topBordered?: boolean;+ bottomBordered?: boolean;+ }>(),+ {+ columnList: () => [],+ dataSource: () => [],+ sectionDataSource: undefined,+ compactSection: false,+ showHeader: true,+ customHeader: false,+ rowClickable: true,+ leftBordered: true,+ rightBordered: true,+ topBordered: true,+ bottomBordered: true,+ }+);++defineEmits<{+ (event: "click-row", section: number, row: number): void;+}>();++const borderVisibility = computed(() => {+ const style = [];+ if (props.leftBordered) {+ style.push("border-l");+ }- if (props.rightBordered) {- style.push("border-r");- }+ if (props.rightBordered) {+ style.push("border-r");+ }- if (props.topBordered) {- style.push("border-t");- }+ if (props.topBordered) {+ style.push("border-t");+ }- if (props.bottomBordered) {- style.push("border-b");- }- return style.join(" ");- });- return { borderVisibility };- },+ if (props.bottomBordered) {+ style.push("border-b");+ }+ return style.join(" ");});</script>diff --git a/frontend/src/bbkit/BBTable/BBTableCell.vue b/frontend/src/bbkit/BBTable/BBTableCell.vueindex 994c24cc57..8252245491 100644--- a/frontend/src/bbkit/BBTable/BBTableCell.vue+++ b/frontend/src/bbkit/BBTable/BBTableCell.vue@@ -4,33 +4,29 @@</td></template>-<script lang="ts">-import { defineComponent } from "vue";+<script lang="ts" setup>+import { withDefaults, defineProps, computed } from "vue";-export default defineComponent({- name: "BBTableCell",- props: {- leftPadding: {- type: Number,- default: 2,- },- rightPadding: {- type: Number,- default: 2,- },- compact: {- type: Boolean,- default: false,- },- },- setup(props) {- const classNames: string[] = [];- if (!props.compact) {- classNames.push(`pl-${props.leftPadding}`);- classNames.push(`pr-${props.rightPadding}`);- classNames.push("py-2");- }- return { classNames };- },+const props = withDefaults(+ defineProps<{+ leftPadding?: number;+ rightPadding?: number;+ compact?: boolean;+ }>(),+ {+ leftPadding: 2,+ rightPadding: 2,+ compact: false,+ }+);++const classNames = computed((): string[] => {+ const classNames: string[] = [];+ if (!props.compact) {+ classNames.push(`pl-${props.leftPadding}`);+ classNames.push(`pr-${props.rightPadding}`);+ classNames.push("py-2");+ }+ return classNames;});</script>diff --git a/frontend/src/bbkit/BBTable/BBTableHeaderCell.vue b/frontend/src/bbkit/BBTable/BBTableHeaderCell.vueindex 53a5427be8..0077fdbaed 100644--- a/frontend/src/bbkit/BBTable/BBTableHeaderCell.vue+++ b/frontend/src/bbkit/BBTable/BBTableHeaderCell.vue@@ -8,32 +8,27 @@</th></template>-<script lang="ts">-import { defineComponent } from "vue";+<script lang="ts" setup>+import { withDefaults, defineProps, computed } from "vue";+const props = withDefaults(+ defineProps<{+ title?: string;+ leftPadding?: number;+ compact?: boolean;+ }>(),+ {+ title: "",+ leftPadding: 2,+ compact: false,+ }+);-export default defineComponent({- name: "BBTableHeaderCell",- props: {- title: {- type: String,- default: "",- },- leftPadding: {- type: Number,- default: 2,- },- compact: {- type: Boolean,- default: false,- },- },- setup(props) {- const classNames: string[] = [];- if (!props.compact) {- classNames.push(`pl-${props.leftPadding}`);- classNames.push("py-2");- }- return { classNames };- },+const classNames = computed((): string[] => {+ const classNames: string[] = [];+ if (!props.compact) {+ classNames.push(`pl-${props.leftPadding}`);+ classNames.push("py-2");+ }+ return classNames;});</script>diff --git a/frontend/src/bbkit/BBTable/BBTableSearch.vue b/frontend/src/bbkit/BBTable/BBTableSearch.vueindex 91426d278b..9294f42670 100644--- a/frontend/src/bbkit/BBTable/BBTableSearch.vue+++ b/frontend/src/bbkit/BBTable/BBTableSearch.vue@@ -3,15 +3,7 @@<label for="search" class="sr-only">Search</label><div class="relative rounded-md shadow-sm"><div- class="- absolute- inset-y-0- left-0- pl-3- flex- items-center- pointer-events-none- "+ class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none"aria-hidden="true"><!-- Heroicon name: solid/search -->@@ -22,31 +14,26 @@type="text"autocomplete="off"name="search"- class="- focus:ring-main focus:border-main- block- w-full- pl-9- sm:text-sm- border-control-border- rounded-md- "+ class="focus:ring-main focus:border-main block w-full pl-9 sm:text-sm border-control-border rounded-md":placeholder="placeholder"- @input="$emit('change-text', $event.target.value)"+ @input="(e: any) => $emit('change-text', e.target.value)"/></div></div></template>-<script lang="ts">-export default {- name: "BBTableSearch",- props: {- placeholder: {- default: "Search",- type: String,- },- },- emits: ["change-text"],-};+<script lang="ts" setup>+import { withDefaults, defineProps, defineEmits } from "vue";+withDefaults(+ defineProps<{+ placeholder?: string;+ }>(),+ {+ placeholder: "Search",+ }+);++defineEmits<{+ (event: "change-text", value: string): void;+}>();</script>diff --git a/frontend/src/bbkit/BBTextField.vue b/frontend/src/bbkit/BBTextField.vueindex df7d549d28..2e94afecb8 100644--- a/frontend/src/bbkit/BBTextField.vue+++ b/frontend/src/bbkit/BBTextField.vue@@ -20,9 +20,18 @@/></template>-<script lang="ts">-import { nextTick, onMounted, reactive, ref, watch } from "vue";-import isEmpty from "lodash-es/isEmpty";+<script lang="ts" setup>+import {+ nextTick,+ onMounted,+ reactive,+ ref,+ watch,+ defineProps,+ defineEmits,+ withDefaults,+} from "vue";+import { isEmpty } from "lodash-es";interface LocalState {text: string;@@ -30,92 +39,77 @@ interface LocalState {hasError: boolean;}-export default {- name: "BBTextField",- props: {- required: {- default: false,- type: Boolean,- },- value: {- default: "",- type: String,- },- placeholder: {- type: String,- },- disabled: {- default: false,- type: Boolean,- },- bordered: {- default: true,- type: Boolean,- },- focusOnMount: {- default: false,- type: Boolean,- },- },- emits: ["end-editing", "input"],- setup(props, { emit }) {- const inputField = ref();+const props = withDefaults(+ defineProps<{+ required?: boolean;+ value?: string;+ placeholder?: string;+ disabled?: boolean;+ bordered?: boolean;+ focusOnMount?: boolean;+ }>(),+ {+ required: false,+ value: "",+ placeholder: "",+ disabled: false,+ bordered: true,+ focusOnMount: false,+ }+);- const state = reactive<LocalState>({- text: props.value,- originalText: "",- hasError: false,- });+const emit = defineEmits<{+ (event: "end-editing", value: string): void;+ (event: "input", e: Event): void;+}>();- onMounted(() => {- if (props.focusOnMount) {- inputField.value.focus();- inputField.value.select();- }- });+const inputField = ref();- watch(- () => props.value,- (cur) => {- state.text = cur;- }- );+const state = reactive<LocalState>({+ text: props.value,+ originalText: "",+ hasError: false,+});++onMounted(() => {+ if (props.focusOnMount) {+ inputField.value.focus();+ inputField.value.select();+ }+});- const onFocus = () => {- state.originalText = state.text;- };+watch(+ () => props.value,+ (cur) => {+ state.text = cur;+ }+);- const onBlur = () => {- if (props.required && isEmpty(state.text.trim())) {- state.hasError = true;+const onFocus = () => {+ state.originalText = state.text;+};++const onBlur = () => {+ if (props.required && isEmpty(state.text.trim())) {+ state.hasError = true;+ nextTick(() => {+ state.text = state.originalText;+ if (inputField.value) {+ // Since we set focus in the nextTick, inputField might already disappear due to outside state change.+ inputField.value.focus();nextTick(() => {- state.text = state.originalText;- if (inputField.value) {- // Since we set focus in the nextTick, inputField might already disappear due to outside state change.- inputField.value.focus();- nextTick(() => {- inputField.value.select();- });- }+ inputField.value.select();});- } else {- state.hasError = false;- emit("end-editing", state.text);}- };-- const onInput = (e: any) => {- state.hasError = false;- emit("input", e);- };+ });+ } else {+ state.hasError = false;+ emit("end-editing", state.text);+ }+};- return {- inputField,- state,- onFocus,- onBlur,- onInput,- };- },+const onInput = (e: Event) => {+ state.hasError = false;+ emit("input", e);};</script>