Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update InstanveV1Table to NDataTable (#11702)
boojack6efd616d5fcf
diff --git a/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceV1Table.vue b/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceV1Table.vueindex e1ee1ac93b..0f5bb3fb5c 100644--- a/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceV1Table.vue+++ b/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceV1Table.vue@@ -4,95 +4,63 @@v-if="showOperation":instance-list="selectedInstanceList"/>- <BBGrid- class="border-y"- :column-list="columnList"- :data-source="instanceList"- :custom-header="true"- :show-placeholder="true"- @click-row="clickInstance"- >- <template #header>- <div role="table-row" class="bb-grid-row bb-grid-header-row group">- <div- v-for="(column, index) in columnList"- :key="index"- role="table-cell"- class="bb-grid-header-cell capitalize"- :class="[column.class]"- >- <template- v-if="index === 0 && allowSelection && instanceList.length > 0"- >- <NCheckbox- v-bind="allSelectionState"- @update:checked="selectAllInstances($event)"- />- </template>- <template v-else>{{ column.title }}</template>- </div>- </div>- </template>- <template #item="{ item: instance }: InstanceRow">- <div v-if="allowSelection" class="bb-grid-cell" @click.stop.prevent>- <NCheckbox- :checked="isInstanceSelected(instance)"- @update:checked="toggleSelectInstance(instance, $event)"- />- </div>- <div class="bb-grid-cell">- <InstanceV1Name :instance="instance" :link="false" tag="div" />- </div>- <div class="bb-grid-cell">- <EnvironmentV1Name- :environment="instance.environmentEntity"- :link="false"- />- </div>- <div class="bb-grid-cell">- {{ hostPortOfInstanceV1(instance) }}- </div>- <div class="bb-grid-cell hidden sm:flex">- <button- v-if="instance.externalLink?.trim().length != 0"- class="btn-icon"- @click.stop="window.open(urlfy(instance.externalLink), '_blank')"- >- <heroicons-outline:external-link class="w-4 h-4" />- </button>- </div>- <div v-if="canAssignLicense" class="bb-grid-cell hover:underline">- {{ instance.activation ? "Y" : "" }}- </div>- </template>- </BBGrid>++ <NDataTable+ size="small"+ :columns="columnList"+ :data="instanceList"+ :striped="true"+ :bordered="bordered"+ :loading="loading"+ :row-key="(data: ComposedInstance) => data.name"+ :checked-row-keys="Array.from(state.selectedInstance)"+ :row-props="rowProps"+ :pagination="{ pageSize: 20 }"+ @update:checked-row-keys="+ (val) => (state.selectedInstance = new Set(val as string[]))+ "+ /></div></template>-<script lang="ts" setup>-import { NCheckbox } from "naive-ui";+<script setup lang="tsx">+import { ExternalLinkIcon } from "lucide-vue-next";+import { NButton, NDataTable, type DataTableColumn } from "naive-ui";import { computed, reactive } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";-import type { BBGridColumn, BBGridRow } from "@/bbkit";-import { BBGrid } from "@/bbkit";+import { InstanceV1Name } from "@/components/v2";import type { ComposedInstance } from "@/types";import { urlfy, hostPortOfInstanceV1 } from "@/utils";import EnvironmentV1Name from "../../EnvironmentV1Name.vue";+import InstanceOperations from "./InstanceOperations.vue";-export type InstanceRow = BBGridRow<ComposedInstance>;+type InstanceDataTableColumn = DataTableColumn<ComposedInstance> & {+ hide?: boolean;+};interface LocalState {selectedInstance: Set<string>;processing: boolean;}-const props = defineProps<{- instanceList: ComposedInstance[];- canAssignLicense: boolean;- allowSelection: boolean;- showOperation: boolean;-}>();+const props = withDefaults(+ defineProps<{+ instanceList: ComposedInstance[];+ bordered?: boolean;+ loading?: boolean;+ showSelection?: boolean;+ singleSelection?: boolean;+ showOperation?: boolean;+ canAssignLicense?: boolean;+ }>(),+ {+ bordered: true,+ showSelection: true,+ showOperation: true,+ canAssignLicense: true,+ }+);const { t } = useI18n();const router = useRouter();@@ -101,91 +69,84 @@ const state = reactive<LocalState>({processing: false,});-const columnList = computed((): BBGridColumn[] => {- const list = [- // checkbox- {- title: "",- width: "minmax(auto, 3rem)",- hide: !props.allowSelection,- },- {- title: t("common.name"),- width: "minmax(min-content, auto)",- },- {- title: t("common.environment"),- width: "minmax(min-content, auto)",- },- {- title: t("common.Address"),- width: "minmax(min-content, auto)",- },- {- title: t("instance.external-link"),- width: { sm: "minmax(min-content, auto)" },- class: "hidden sm:flex",+const columnList = computed((): InstanceDataTableColumn[] => {+ const SELECTION: InstanceDataTableColumn = {+ type: "selection",+ hide: !props.showSelection,+ cellProps: () => {+ return {+ onClick: (e: MouseEvent) => {+ e.stopPropagation();+ },+ };},- {- title: t("subscription.instance-assignment.license"),- width: "minmax(min-content, auto)",- hide: !props.canAssignLicense,+ };+ const NAME: InstanceDataTableColumn = {+ key: "title",+ title: t("common.name"),+ resizable: true,+ render: (instance) => {+ return <InstanceV1Name instance={instance} link={false} />;},- ];- return list.filter((col) => !col.hide);-});--const clickInstance = (- instance: ComposedInstance,- section: number,- row: number,- e: MouseEvent-) => {- const url = `/${instance.name}`;- if (e.ctrlKey || e.metaKey) {- window.open(url, "_blank");- } else {- router.push(url);- }-};--const isInstanceSelected = (instance: ComposedInstance): boolean => {- return state.selectedInstance.has(instance.name);-};+ };+ const ENVIRONMENT: InstanceDataTableColumn = {+ key: "environment",+ title: t("common.environment"),+ resizable: true,+ render: (instance) => (+ <EnvironmentV1Name+ environment={instance.environmentEntity}+ link={false}+ />+ ),+ };+ const ADDRESS: InstanceDataTableColumn = {+ key: "address",+ title: t("common.address"),+ resizable: true,+ render: (instance) => hostPortOfInstanceV1(instance),+ };+ const EXTERNAL_LINK: InstanceDataTableColumn = {+ key: "project",+ title: t("instance.external-link"),+ resizable: true,+ width: 150,+ render: (instance) =>+ instance.externalLink?.trim().length !== 0 && (+ <NButton+ quaternary+ size="small"+ onClick={() => window.open(urlfy(instance.externalLink), "_blank")}+ >+ <ExternalLinkIcon class="w-4 h-4" />+ </NButton>+ ),+ };+ const LICENSE: InstanceDataTableColumn = {+ key: "instance",+ title: t("subscription.instance-assignment.license"),+ resizable: true,+ width: 100,+ render: (instance) => (instance.activation ? "Y" : ""),+ };-const allSelectionState = computed(() => {- const checked =- state.selectedInstance.size > 0 &&- props.instanceList.every((instance) =>- state.selectedInstance.has(instance.name)- );- const indeterminate =- !checked &&- props.instanceList.some((instance) =>- state.selectedInstance.has(instance.name)- );+ return [SELECTION, NAME, ENVIRONMENT, ADDRESS, EXTERNAL_LINK, LICENSE].filter(+ (column) => !column.hide+ );+});+const rowProps = (instance: ComposedInstance) => {return {- checked,- indeterminate,+ style: "cursor: pointer;",+ onClick: (e: MouseEvent) => {+ const url = `/${instance.name}`;+ if (e.ctrlKey || e.metaKey) {+ window.open(url, "_blank");+ } else {+ router.push(url);+ }+ },};-});--const toggleSelectInstance = (- instance: ComposedInstance,- selected: boolean-) => {- if (selected) {- state.selectedInstance.add(instance.name);- } else {- state.selectedInstance.delete(instance.name);- }-};--const selectAllInstances = (selected: boolean): void => {- for (const instance of props.instanceList) {- toggleSelectInstance(instance, selected);- }};const selectedInstanceList = computed(() => {diff --git a/frontend/src/views/Archive.vue b/frontend/src/views/Archive.vueindex f2e9ee37c2..d9b855e450 100644--- a/frontend/src/views/Archive.vue+++ b/frontend/src/views/Archive.vue@@ -8,25 +8,26 @@:placeholder="$t('common.filter-by-name')"/></div>- <div class="border-x">+ <div class=""><ProjectV1Tablev-if="state.selectedTab == 'PROJECT'":project-list="filteredProjectList"- class="border-x-0"/><InstanceV1Tablev-else-if="state.selectedTab == 'INSTANCE'"- :allow-selection="false"- :can-assign-license="false":instance-list="filteredInstanceList"+ :show-selection="false"+ :can-assign-license="false":show-operation="false"/><EnvironmentV1Tablev-else-if="state.selectedTab == 'ENVIRONMENT'"+ class="border-x":environment-list="filteredEnvironmentList"/><IdentityProviderTablev-else-if="state.selectedTab == 'SSO'"+ class="border-x":identity-provider-list="filteredSSOList(deletedSSOList)"/></div>diff --git a/frontend/src/views/InstanceDashboard.vue b/frontend/src/views/InstanceDashboard.vueindex 0caa2874a9..8912e668e3 100644--- a/frontend/src/views/InstanceDashboard.vue+++ b/frontend/src/views/InstanceDashboard.vue@@ -13,8 +13,8 @@:support-option-id-list="supportOptionIdList"/><InstanceV1Table- :allow-selection="true"- :show-operation="true"+ :bordered="false"+ :loading="!ready":instance-list="filteredInstanceV1List":can-assign-license="subscriptionStore.currentPlan !== PlanType.FREE"/>@@ -49,7 +49,7 @@ const subscriptionStore = useSubscriptionV1Store();const instanceV1Store = useInstanceV1Store();const uiStateStore = useUIStateStore();const environmentList = useEnvironmentV1List();-const { instanceList: rawInstanceV1List } = useInstanceV1List();+const { instanceList: rawInstanceV1List, ready } = useInstanceV1List();const state = reactive<LocalState>({params: {