Skip to content

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

chore: ui improvement (#9796)

ecmadao13b30b567f74
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue
index 4efcd1357d..3f775eef20 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue
@@ -3,6 +3,7 @@
:column-list="COLUMN_LIST"
:data-source="databaseGroupList"
:row-clickable="true"
+ :show-placeholder="true"
row-key="name"
class="border"
@click-row="clickDatabaseGroup"
diff --git a/frontend/src/components/InstanceAssignment.vue b/frontend/src/components/InstanceAssignment.vue
index a32e2bc729..6f24701d30 100644
--- a/frontend/src/components/InstanceAssignment.vue
+++ b/frontend/src/components/InstanceAssignment.vue
@@ -22,70 +22,61 @@
<span>{{ totalLicenseCount }}</span>
</div>
</div>
- <BBTable
- ref="tableRef"
+ <BBGrid
+ class="border"
:column-list="columnList"
- :section-data-source="datasource"
+ :data-source="instanceList"
:show-header="true"
:custom-header="true"
- :left-bordered="true"
- :right-bordered="true"
- :top-bordered="true"
- :bottom-bordered="true"
- :compact-section="true"
:row-clickable="false"
>
<template #header>
- <th
- v-for="(column, index) in columnList"
- :key="index"
- scope="col"
- class="pl-2 first:pl-4 py-2 text-left text-xs font-medium text-gray-500 tracking-wider capitalize"
- :class="[column.center && 'text-center pr-2']"
- >
- <template v-if="index === 0 && canManageSubscription">
- <input
- v-if="instanceList.length > 0"
- type="checkbox"
- class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"
- :checked="allSelectionState.checked"
- :indeterminate="allSelectionState.indeterminate"
- :disabled="
- !allSelectionState.checked &&
- instanceList.length > instanceLicenseCount
- "
- @input="
- selectAllInstances(
- ($event.target as HTMLInputElement).checked
- )
- "
- />
- </template>
- <template v-else>{{ $t(column.title) }}</template>
- </th>
+ <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 && canManageSubscription">
+ <input
+ v-if="instanceList.length > 0"
+ type="checkbox"
+ class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"
+ :checked="allSelectionState.checked"
+ :indeterminate="allSelectionState.indeterminate"
+ :disabled="
+ !allSelectionState.checked &&
+ instanceList.length > instanceLicenseCount
+ "
+ @input="
+ selectAllInstances(
+ ($event.target as HTMLInputElement).checked
+ )
+ "
+ />
+ </template>
+ <template v-else>{{ column.title }}</template>
+ </div>
+ </div>
</template>
- <template
- #body="{ rowData: instance }: { rowData: ComposedInstance }"
- >
- <BBTableCell
- v-if="canManageSubscription"
- class="w-[1%]"
- @click.stop="
- toggleSelectInstance(instance, !isInstanceSelected(instance))
- "
- >
- <!-- width: 1% means as narrow as possible -->
+ <template #item="{ item: instance }: { item: ComposedInstance }">
+ <div v-if="canManageSubscription" class="bb-grid-cell">
<input
type="checkbox"
- class="ml-2 h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"
+ class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"
:checked="isInstanceSelected(instance)"
:disabled="
!isInstanceSelected(instance) &&
state.selectedInstance.size == instanceLicenseCount
"
+ @click.stop="
+ toggleSelectInstance(instance, !isInstanceSelected(instance))
+ "
/>
- </BBTableCell>
- <BBTableCell class="bb-grid-cell">
+ </div>
+ <div class="bb-grid-cell">
<div class="flex items-center gap-x-1">
<InstanceV1EngineIcon :instance="instance" />
<router-link
@@ -97,20 +88,20 @@
{{ instanceV1Name(instance) }}
</router-link>
</div>
- </BBTableCell>
- <BBTableCell class="bb-grid-cell">
+ </div>
+ <div class="bb-grid-cell">
<EnvironmentV1Name
:environment="instance.environmentEntity"
:link="false"
/>
- </BBTableCell>
- <BBTableCell class="bb-grid-cell">
+ </div>
+ <div class="bb-grid-cell">
<EllipsisText class="w-10">
{{ hostPortOfInstanceV1(instance) }}
</EllipsisText>
- </BBTableCell>
+ </div>
</template>
- </BBTable>
+ </BBGrid>
</div>
<template #footer>
@@ -140,9 +131,9 @@
<script lang="ts" setup>
import { storeToRefs } from "pinia";
-import { reactive, computed, watchEffect, ref } from "vue";
+import { reactive, computed, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
-import type { BBTableColumn, BBTableSectionDataSource } from "@/bbkit/types";
+import { BBGrid, BBGridColumn } from "@/bbkit";
import EllipsisText from "@/components/EllipsisText.vue";
import { EnvironmentV1Name, InstanceV1EngineIcon } from "@/components/v2";
import { Drawer, DrawerContent } from "@/components/v2";
@@ -158,33 +149,16 @@ import { ComposedInstance } from "@/types";
import { instanceV1Slug, instanceV1Name, hostPortOfInstanceV1 } from "@/utils";
import { hasWorkspacePermissionV1 } from "@/utils";
-defineProps({
- show: {
- default: false,
- type: Boolean,
- },
-});
-
-const columnList = computed(() => {
- const resp: BBTableColumn[] = [
- {
- title: "common.name",
- },
- {
- title: "common.environment",
- },
- {
- title: "common.Address",
- },
- ];
- if (canManageSubscription.value) {
- resp.unshift({
- // This column is for selection input.
- title: "",
- });
+const props = withDefaults(
+ defineProps<{
+ show: boolean;
+ selectedInstanceList?: string[];
+ }>(),
+ {
+ show: false,
+ selectedInstanceList: () => [],
}
- return resp;
-});
+);
interface LocalState {
selectedInstance: Set<string>;
@@ -206,6 +180,31 @@ const currentUserV1 = useCurrentUserV1();
const { instanceList } = useInstanceV1List(false /* !showDeleted */);
const { instanceLicenseCount } = storeToRefs(subscriptionStore);
+const columnList = computed(() => {
+ const resp: BBGridColumn[] = [
+ {
+ 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)",
+ },
+ ];
+ if (canManageSubscription.value) {
+ resp.unshift({
+ // This column is for selection input.
+ title: "",
+ width: "minmax(auto, 3rem)",
+ });
+ }
+ return resp;
+});
+
const canManageSubscription = computed((): boolean => {
return hasWorkspacePermissionV1(
"bb.permission.workspace.manage-subscription",
@@ -219,6 +218,9 @@ watchEffect(() => {
state.selectedInstance.add(instance.name);
}
}
+ for (const instance of props.selectedInstanceList) {
+ state.selectedInstance.add(instance);
+ }
});
const totalLicenseCount = computed((): string => {
@@ -232,19 +234,6 @@ const assignedLicenseCount = computed((): string => {
return `${state.selectedInstance.size}`;
});
-const tableRef = ref<HTMLTableElement>();
-
-const datasource = computed(
- (): BBTableSectionDataSource<ComposedInstance>[] => {
- return [
- {
- title: "",
- list: instanceList.value,
- },
- ];
- }
-);
-
const isInstanceSelected = (instance: ComposedInstance): boolean => {
return state.selectedInstance.has(instance.name);
};
diff --git a/frontend/src/components/Project/ProjectSwitchModal.vue b/frontend/src/components/Project/ProjectSwitchModal.vue
index f0720d03cd..7bad852534 100644
--- a/frontend/src/components/Project/ProjectSwitchModal.vue
+++ b/frontend/src/components/Project/ProjectSwitchModal.vue
@@ -21,12 +21,21 @@
</NButton>
</div>
</div>
- <ProjectV1Table
- :project-list="filteredProjectList"
- :current-project="currentProject"
- class="border"
- @click="$emit('dismiss')"
- />
+ <NTabs v-model:value="state.selectedTab" type="line">
+ <NTabPane
+ v-for="tab in tabList"
+ :key="tab.id"
+ :name="tab.id"
+ :tab="tab.title"
+ >
+ <ProjectV1Table
+ :project-list="tab.list"
+ :current-project="currentProject"
+ class="border"
+ @click="$emit('dismiss')"
+ />
+ </NTabPane>
+ </NTabs>
</div>
</BBModal>
<Drawer
@@ -40,7 +49,9 @@
</template>
<script lang="ts" setup>
-import { computed, reactive } from "vue";
+import { computed, reactive, onMounted } from "vue";
+import { useI18n } from "vue-i18n";
+import { useRecentProjects } from "@/components/Project/useRecentProjects";
import { SearchBox, ProjectV1Table } from "@/components/v2";
import { Drawer } from "@/components/v2";
import { useProjectV1ListByCurrentUser } from "@/store";
@@ -55,6 +66,7 @@ import { filterProjectV1ListByKeyword } from "@/utils";
interface LocalState {
searchText: string;
showCreateDrawer: boolean;
+ selectedTab: "recent" | "all";
}
const props = defineProps<{
@@ -65,18 +77,40 @@ const emit = defineEmits<{
(event: "dismiss"): void;
}>();
+const { t } = useI18n();
const state = reactive<LocalState>({
searchText: "",
showCreateDrawer: false,
+ selectedTab: "all",
});
const { projectList } = useProjectV1ListByCurrentUser();
+const { recentViewProjects } = useRecentProjects();
+
+onMounted(() => {
+ state.selectedTab = recentViewProjects.value.length < 1 ? "all" : "recent";
+});
-const filteredProjectList = computed(() => {
- const list = projectList.value.filter(
+const getFilteredProjectList = (
+ projectList: ComposedProject[]
+): ComposedProject[] => {
+ const list = projectList.filter(
(project) => project.uid !== String(DEFAULT_PROJECT_ID)
);
return filterProjectV1ListByKeyword(list, state.searchText);
-});
+};
+
+const tabList = computed(() => [
+ {
+ title: t("common.recent"),
+ id: "recent",
+ list: getFilteredProjectList(recentViewProjects.value),
+ },
+ {
+ title: t("common.all"),
+ id: "all",
+ list: getFilteredProjectList(projectList.value),
+ },
+]);
const currentProject = computed(() => {
if (
diff --git a/frontend/src/components/Project/useRecentProjects.ts b/frontend/src/components/Project/useRecentProjects.ts
new file mode 100644
index 0000000000..5e6d9754e3
--- /dev/null
+++ b/frontend/src/components/Project/useRecentProjects.ts
@@ -0,0 +1,42 @@
+import { useLocalStorage } from "@vueuse/core";
+import { computed } from "vue";
+import { useProjectV1Store, useCurrentUserIamPolicy } from "@/store";
+
+const MAX_RECENT_PROJECT = 5;
+
+export const useRecentProjects = () => {
+ const projectV1Store = useProjectV1Store();
+ const currentUserIamPolicy = useCurrentUserIamPolicy();
+
+ const recentViewProjectNames = useLocalStorage<string[]>(
+ "bb.project.recent-view",
+ []
+ );
+
+ const setRecentProject = (name: string) => {
+ if (!name) {
+ return;
+ }
+ if (new Set(recentViewProjectNames.value).has(name)) {
+ return;
+ }
+
+ recentViewProjectNames.value.unshift(name);
+ if (recentViewProjectNames.value.length > MAX_RECENT_PROJECT) {
+ recentViewProjectNames.value.pop();
+ }
+ };
+
+ const recentViewProjects = computed(() => {
+ return recentViewProjectNames.value
+ .filter((project) => currentUserIamPolicy.isMemberOfProject(project))
+ .map((project) => {
+ return projectV1Store.getProjectByName(project);
+ });
+ });
+
+ return {
+ setRecentProject,
+ recentViewProjects,
+ };
+};
diff --git a/frontend/src/components/ProjectDatabasesPanel.vue b/frontend/src/components/ProjectDatabasesPanel.vue
index 833060fcd1..a092df2815 100644
--- a/frontend/src/components/ProjectDatabasesPanel.vue
+++ b/frontend/src/components/ProjectDatabasesPanel.vue
@@ -19,7 +19,6 @@
<DatabaseOperations
v-if="showDatabaseOperations"
:databases="selectedDatabases"
- @dismiss="state.selectedDatabaseIds.clear()"
/>
<template v-if="databaseList.length > 0">
@@ -184,7 +183,7 @@ const showDatabaseOperations = computed(() => {
return true;
}
- return selectedDatabases.value.length > 0;
+ return true;
});
const showEmptyActions = computed(() => {
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vue
index 43ee6d8db2..a5928d5891 100644
--- a/frontend/src/components/QuickActionPanel.vue
+++ b/frontend/src/components/QuickActionPanel.vue
@@ -2,204 +2,16 @@
<div
class="pt-1 overflow-hidden grid grid-cols-3 gap-x-2 gap-y-4 md:inline-flex items-stretch"
>
- <template v-for="(quickAction, index) in quickActionList" :key="index">
- <div
- v-if="quickAction === 'quickaction.bb.instance.create'"
- class="flex flex-col items-center w-24"
- data-label="bb-quick-action-add-instance"
- >
- <button class="btn-icon-primary p-3" @click.prevent="createInstance">
- <heroicons-outline:plus-sm class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("quick-action.add-instance") }}
- </h3>
- </div>
-
- <template v-if="shouldShowAlterDatabaseEntries">
- <div
- v-if="quickAction === 'quickaction.bb.database.create'"
- class="flex flex-col items-center w-24"
- data-label="bb-quick-action-new-db"
- >
- <button class="btn-icon-primary p-3" @click.prevent="createDatabase">
- <heroicons-outline:database class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("quick-action.new-db") }}
- </h3>
- </div>
-
- <div
- v-if="quickAction === 'quickaction.bb.database.schema.update'"
- class="flex flex-col items-center w-24"
- >
- <button
- class="btn-icon-primary p-3"
- data-label="bb-alter-schema-button"
- @click.prevent="alterSchema"
- >
- <heroicons-outline:pencil-alt class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("database.edit-schema") }}
- </h3>
- </div>
-
- <div
- v-if="quickAction === 'quickaction.bb.database.data.update'"
- class="flex flex-col items-center w-24"
- >
- <button class="btn-icon-primary p-3" @click.prevent="changeData">
- <heroicons-outline:pencil class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("database.change-data") }}
- </h3>
- </div>
- </template>
-
- <div
- v-if="quickAction === 'quickaction.bb.environment.create'"
- class="flex flex-col items-center w-36"
- >
- <button class="btn-icon-primary p-3" @click.prevent="createEnvironment">
- <heroicons-outline:plus-sm class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("environment.create") }}
- </h3>
- </div>
-
- <div
- v-if="quickAction === 'quickaction.bb.environment.reorder'"
- class="flex flex-col items-center w-24"
- >
- <button
- class="btn-icon-primary p-3"
- @click.prevent="reorderEnvironment"
- >
- <heroicons-outline:selector class="transform rotate-90 w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("common.reorder") }}
- </h3>
- </div>
-
- <div
- v-if="quickAction === 'quickaction.bb.project.create'"
- class="flex flex-col items-center w-24"
- data-label="bb-quick-action-new-project"
- >
- <button class="btn-icon-primary p-3" @click.prevent="createProject">
- <heroicons-outline:template class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("quick-action.new-project") }}
- </h3>
- </div>
-
- <div
- v-if="quickAction === 'quickaction.bb.project.database.transfer'"
- class="flex flex-col items-center w-24"
- >
- <button class="btn-icon-primary p-3" @click.prevent="transferDatabase">
- <heroicons-outline:chevron-double-down class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("quick-action.transfer-in-db") }}
- </h3>
- </div>
-
- <div
- v-if="quickAction === 'quickaction.bb.project.database.transfer'"
- class="flex flex-col items-center w-24"
- >
- <button
- class="btn-icon-primary p-3"
- @click.prevent="transferOutDatabase"
- >
- <heroicons-outline:chevron-double-up class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("quick-action.transfer-out-db") }}
- </h3>
- </div>
-
- <template v-if="hasDBAWorkflowFeature">
- <div
- v-if="quickAction === 'quickaction.bb.issue.grant.request.querier'"
- class="flex flex-col items-center w-24"
- >
- <button
- class="btn-icon-primary p-3"
- @click.prevent="state.showRequestQueryPanel = true"
- >
- <heroicons-outline:document-search class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("quick-action.request-query-permission") }}
- </h3>
- </div>
-
- <div
- v-if="quickAction === 'quickaction.bb.issue.grant.request.exporter'"
- class="flex flex-col items-center w-24"
- >
- <button
- class="btn-icon-primary p-3"
- @click.prevent="state.showRequestExportPanel = true"
- >
- <heroicons-outline:document-download class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("quick-action.request-export-permission") }}
- </h3>
- </div>
- </template>
-
- <div
- v-if="quickAction === 'quickaction.bb.subscription.license-assignment'"
- class="flex flex-col items-center w-24"
- >
- <button
- class="btn-icon-primary p-3"
- @click.prevent="
- () =>
- (state.quickActionType =
- 'quickaction.bb.subscription.license-assignment')
- "
- >
- <heroicons-outline:academic-cap class="w-4 h-4" />
- </button>
- <h3
- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
- >
- {{ $t("subscription.instance-assignment.assign-license") }}
- </h3>
- </div>
+ <template
+ v-for="(quickAction, index) in availableQuickActionList"
+ :key="index"
+ >
+ <NButton @click="quickAction.action">
+ <template #icon>
+ <component :is="quickAction.icon" class="h-4 w-4" />
+ </template>
+ {{ quickAction.title }}
+ </NButton>
</template>
</div>
@@ -263,13 +75,6 @@
@close="state.showRequestExportPanel = false"
/>
- <InstanceAssignment
- :show="
- state.quickActionType === 'quickaction.bb.subscription.license-assignment'
- "
- @dismiss="state.quickActionType = undefined"
- />
-
<FeatureModal
:open="state.showFeatureModal && !!state.feature"
:feature="(state.feature as FeatureType)"
@@ -278,8 +83,20 @@
</template>
<script lang="ts" setup>
-import { Action, defineAction, useRegisterActions } from "@bytebase/vue-kbar";
-import { reactive, PropType, computed, watch } from "vue";
+import { defineAction, useRegisterActions } from "@bytebase/vue-kbar";
+import {
+ PlusIcon,
+ DatabaseIcon,
+ PencilIcon,
+ PenSquareIcon,
+ ListOrderedIcon,
+ GalleryHorizontalEndIcon,
+ ChevronsDownIcon,
+ ChevronsUpIcon,
+ FileSearchIcon,
+ FileDownIcon,
+} from "lucide-vue-next";
+import { reactive, PropType, computed, watch, VNode, h } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
import AlterSchemaPrepForm from "@/components/AlterSchemaPrepForm/";
@@ -309,6 +126,14 @@ interface LocalState {
showRequestExportPanel: boolean;
}
+interface QuickAction {
+ type: QuickActionType;
+ title: string;
+ icon?: VNode;
+ hide?: boolean;
+ action: () => void;
+}
+
const props = defineProps({
quickActionList: {
required: true,
@@ -398,59 +223,112 @@ const reorderEnvironment = () => {
commandStore.dispatchCommand("bb.environment.reorder");
};
-const QuickActionMap: Record<string, Partial<Action>> = {
- "quickaction.bb.instance.create": {
- name: t("quick-action.add-instance"),
- perform: () => createInstance(),
- },
- "quickaction.bb.database.create": {
- name: t("quick-action.new-db"),
- perform: () => createDatabase(),
- },
- "quickaction.bb.database.schema.update": {
- name: t("database.edit-schema"),
- perform: () => alterSchema(),
- },
- "quickaction.bb.environment.create": {
- name: t("quick-action.add-environment"),
- perform: () => createEnvironment(),
- },
- "quickaction.bb.environment.reorder": {
- name: t("common.reorder"),
- perform: () => reorderEnvironment(),
- },
- "quickaction.bb.project.create": {
- name: t("quick-action.new-project"),
- perform: () => createProject(),
- },
- "quickaction.bb.project.database.transfer": {
- name: t("quick-action.transfer-in-db"),
- perform: () => transferDatabase(),
- },
- "quickaction.bb.subscription.license-assignment": {
- name: t("subscription.instance-assignment.manage-license"),
- perform: () =>
- (state.quickActionType =
- "quickaction.bb.subscription.license-assignment"),
- },
-};
+const availableQuickActionList = computed((): QuickAction[] => {
+ const fullList: QuickAction[] = [
+ {
+ type: "quickaction.bb.instance.create",
+ title: t("quick-action.add-instance"),
+ action: createInstance,
+ icon: h(PlusIcon),
+ },
+ {
+ type: "quickaction.bb.database.create",
+ title: t("quick-action.new-db"),
+ hide: !shouldShowAlterDatabaseEntries.value,
+ action: createDatabase,
+ icon: h(DatabaseIcon),
+ },
+ {
+ type: "quickaction.bb.database.schema.update",
+ title: t("database.edit-schema"),
+ hide: !shouldShowAlterDatabaseEntries.value,
+ action: alterSchema,
+ icon: h(PenSquareIcon),
+ },
+ {
+ type: "quickaction.bb.database.data.update",
+ title: t("database.change-data"),
+ hide: !shouldShowAlterDatabaseEntries.value,
+ action: changeData,
+ icon: h(PencilIcon),
+ },
+ {
+ type: "quickaction.bb.environment.create",
+ title: t("environment.create"),
+ action: createEnvironment,
+ icon: h(PlusIcon),
+ },
+ {
+ type: "quickaction.bb.environment.reorder",
+ title: t("common.reorder"),
+ action: reorderEnvironment,
+ icon: h(ListOrderedIcon),
+ },
+ {
+ type: "quickaction.bb.project.create",
+ title: t("quick-action.new-project"),
+ action: createProject,
+ icon: h(GalleryHorizontalEndIcon),
+ },
+ {
+ type: "quickaction.bb.project.database.transfer",
+ title: t("quick-action.transfer-in-db"),
+ action: transferDatabase,
+ icon: h(ChevronsDownIcon),
+ },
+ {
+ type: "quickaction.bb.project.database.transfer-out",
+ title: t("quick-action.transfer-out-db"),
+ action: transferOutDatabase,
+ icon: h(ChevronsUpIcon),
+ },
+ {
+ type: "quickaction.bb.issue.grant.request.querier",
+ title: t("quick-action.request-query-permission"),
+ hide: !hasDBAWorkflowFeature.value,
+ action: () => (state.showRequestQueryPanel = true),
+ icon: h(FileSearchIcon),
+ },
+ {
+ type: "quickaction.bb.issue.grant.request.exporter",
+ title: t("quick-action.request-export-permission"),
+ hide: !hasDBAWorkflowFeature.value,
+ action: () => (state.showRequestExportPanel = true),
+ icon: h(FileDownIcon),
+ },
+ ];
+
+ return props.quickActionList.reduce((list, quickAction) => {
+ const filter = fullList.filter(
+ (item) => item.type === quickAction && !item.hide
+ );
+ list.push(...filter);
+ return list;
+ }, [] as QuickAction[]);
+});
const kbarActions = computed(() => {
- return props.quickActionList
- .filter((qa) => qa in QuickActionMap)
- .map((qa) => {
- // a QuickActionType starts with "quickaction.bb."
- // it's already namespaced so we don't need prefix here
- // just re-order the identifier to match other kbar action ids' format
- // here `id` looks like "bb.quickaction.instance.create"
- const id = qa.replace(/^quickaction\.bb\.(.+)$/, "bb.quickaction.$1");
- return defineAction({
- id,
- section: t("common.quick-action"),
- keywords: "quick action",
- ...QuickActionMap[qa],
- });
- });
+ return (
+ availableQuickActionList.value
+ // .filter((qa) => qa in QuickActionMap)
+ .map((item) => {
+ // a QuickActionType starts with "quickaction.bb."
+ // it's already namespaced so we don't need prefix here
+ // just re-order the identifier to match other kbar action ids' format
+ // here `id` looks like "bb.quickaction.instance.create"
+ const id = item.type.replace(
+ /^quickaction\.bb\.(.+)$/,
+ "bb.quickaction.$1"
+ );
+ return defineAction({
+ id,
+ section: t("common.quick-action"),
+ keywords: "quick action",
+ name: item.title,
+ perform: item.action,
+ });
+ })
+ );
});
useRegisterActions(kbarActions, true);
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
index 343c30f29a..ffba4615c0 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
@@ -1,41 +1,34 @@
<template>
<div
v-bind="$attrs"
- class="flex flex-col sm:flex-row items-start sm:items-center bg-blue-100 py-3 px-2 text-main gap-y-2 gap-x-4"
+ class="text-sm flex flex-col lg:flex-row items-start lg:items-center bg-blue-100 py-3 px-4 text-main gap-y-2 gap-x-4 overflow-x-auto"
>
+ {{
+ $t("database.selected-n-databases", {
+ n: databases.length,
+ })
+ }}
<div class="flex items-center">
- <button
- v-if="!isStandaloneMode"
- class="w-7 h-7 p-1 mr-3 rounded cursor-pointer"
- @click.prevent="$emit('dismiss')"
- >
- <heroicons-outline:x class="w-5 h-5" />
- </button>
- {{
- $t("database.selected-n-databases", {
- n: databases.length,
- })
- }}
- </div>
- <div class="flex items-center gap-x-4 text-sm text-accent">
<template v-for="action in actions" :key="action.text">
- <NTooltip :disabled="!action.disabled">
+ <NTooltip
+ :disabled="!action.disabled || !getDisabledTooltip(action.text)"
+ >
<template #trigger>
- <button
+ <NButton
+ quaternary
+ size="small"
+ type="primary"
:disabled="action.disabled"
- class="flex items-center gap-x-1 hover:text-accent-hover disabled:text-control-light disabled:cursor-not-allowed"
@click="action.click"
>
- <component :is="action.icon" class="h-4 w-4" />
- {{ action.text }}
- </button>
+ <template #icon>
+ <component :is="action.icon" class="h-4 w-4" />
+ </template>
+ <span class="text-sm">{{ action.text }}</span>
+ </NButton>
</template>
<span class="w-56 text-sm">
- {{
- $t("database.batch-action-disabled", {
- action: action.text.toLowerCase(),
- })
- }}
+ {{ getDisabledTooltip(action.text) }}
</span>
</NTooltip>
</template>
@@ -126,10 +119,6 @@ const props = defineProps<{
databases: ComposedDatabase[];
}>();
-defineEmits<{
- (event: "dismiss"): void;
-}>();
-
const state = reactive<LocalState>({
loading: false,
showSchemaEditorModal: false,
@@ -157,6 +146,20 @@ const selectedProjectNames = computed(() => {
return new Set(props.databases.map((db) => db.project));
});
+const getDisabledTooltip = (action: string) => {
+ if (selectedProjectNames.value.size > 1) {
+ return t("database.batch-action-disabled", {
+ action: action.toLowerCase(),
+ });
+ }
+ if (selectedProjectNames.value.has(DEFAULT_PROJECT_V1_NAME)) {
+ return t("database.batch-action-disabled-for-unassigned", {
+ action: action.toLowerCase(),
+ });
+ }
+ return "";
+};
+
const selectedProjectUid = computed(() => {
if (selectedProjectNames.value.size !== 1) {
return "";
@@ -336,28 +339,30 @@ const actions = computed((): DatabaseAction[] => {
resp.push({
icon: h(TagIcon),
text: t("database.edit-labels"),
- disabled: false,
+ disabled: props.databases.length < 1,
click: () => (state.showLabelEditorDrawer = true),
});
}
}
- if (!selectedProjectNames.value.has(DEFAULT_PROJECT_V1_NAME)) {
- if (allowChangeData.value) {
- resp.unshift({
- icon: h(PencilIcon),
- text: t("database.change-data"),
- disabled: !selectedProjectUid.value,
- click: () => generateMultiDb("bb.issue.database.data.update"),
- });
- }
- if (allowEditSchema.value) {
- resp.unshift({
- icon: h(PencilAltIcon),
- text: t("database.edit-schema"),
- disabled: !selectedProjectUid.value,
- click: () => generateMultiDb("bb.issue.database.schema.update"),
- });
- }
+ if (allowChangeData.value) {
+ resp.unshift({
+ icon: h(PencilIcon),
+ text: t("database.change-data"),
+ disabled:
+ !selectedProjectUid.value ||
+ selectedProjectNames.value.has(DEFAULT_PROJECT_V1_NAME),
+ click: () => generateMultiDb("bb.issue.database.data.update"),
+ });
+ }
+ if (allowEditSchema.value) {
+ resp.unshift({
+ icon: h(PencilAltIcon),
+ text: t("database.edit-schema"),
+ disabled:
+ !selectedProjectUid.value ||
+ selectedProjectNames.value.has(DEFAULT_PROJECT_V1_NAME),
+ click: () => generateMultiDb("bb.issue.database.schema.update"),
+ });
}
return resp;
});
diff --git a/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceOperations.vue b/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceOperations.vue
index bcb83dd510..4c4f896354 100644
--- a/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceOperations.vue
+++ b/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceOperations.vue
@@ -1,14 +1,8 @@
<template>
<div
v-bind="$attrs"
- class="flex items-center bg-blue-100 py-3 px-2 text-main"
+ class="text-sm flex flex-col lg:flex-row items-start lg:items-center bg-blue-100 py-3 px-4 text-main gap-y-2 gap-x-4 overflow-x-auto"
>
- <button
- class="w-7 h-7 p-1 mr-3 rounded cursor-pointer"
- @click.prevent="$emit('dismiss')"
- >
- <heroicons-outline:x class="w-5 h-5" />
- </button>
{{
$t("instance.selected-n-instances", {
n: instanceList.length,
@@ -16,25 +10,39 @@
}}
<div class="flex items-center gap-x-4 text-sm ml-5 text-accent">
<template v-for="action in actions" :key="action.text">
- <button
+ <NButton
+ quaternary
+ size="small"
+ type="primary"
:disabled="action.disabled"
- class="flex items-center gap-x-1 hover:text-accent-hover disabled:text-control-light disabled:cursor-not-allowed"
@click="action.click"
>
- <component :is="action.icon" class="h-4 w-4" />
- {{ action.text }}
- </button>
+ <template #icon>
+ <component :is="action.icon" class="h-4 w-4" />
+ </template>
+ <span class="text-sm">{{ action.text }}</span>
+ </NButton>
</template>
</div>
</div>
+ <InstanceAssignment
+ :show="state.showAssignLicenseDrawer"
+ :selected-instance-list="instanceList.map((ins) => ins.name)"
+ @dismiss="state.showAssignLicenseDrawer = false"
+ />
</template>
<script setup lang="ts">
+import { GraduationCapIcon, RefreshCwIcon } from "lucide-vue-next";
import { computed, h, VNode, reactive } from "vue";
import { useI18n } from "vue-i18n";
-import RefreshIcon from "~icons/heroicons-outline/refresh";
-import { useInstanceV1Store, pushNotification } from "@/store";
+import {
+ useInstanceV1Store,
+ pushNotification,
+ useCurrentUserV1,
+} from "@/store";
import { ComposedInstance } from "@/types";
+import { hasWorkspacePermissionV1 } from "@/utils";
interface Action {
icon: VNode;
@@ -45,31 +53,46 @@ interface Action {
interface LocalState {
loading: boolean;
+ showAssignLicenseDrawer: boolean;
}
const props = defineProps<{
instanceList: ComposedInstance[];
}>();
-defineEmits<{
- (event: "dismiss"): void;
-}>();
-
const { t } = useI18n();
const state = reactive<LocalState>({
loading: false,
+ showAssignLicenseDrawer: false,
});
const instanceStore = useInstanceV1Store();
+const currentUserV1 = useCurrentUserV1();
+
+const canManageSubscription = computed((): boolean => {
+ return hasWorkspacePermissionV1(
+ "bb.permission.workspace.manage-subscription",
+ currentUserV1.value.userRole
+ );
+});
const actions = computed((): Action[] => {
- return [
+ const list: Action[] = [
{
- icon: h(RefreshIcon),
+ icon: h(RefreshCwIcon),
text: t("common.sync"),
disabled: props.instanceList.length < 1 || state.loading,
click: syncSchema,
},
];
+ if (canManageSubscription.value) {
+ list.push({
+ icon: h(GraduationCapIcon),
+ text: t("subscription.instance-assignment.assign-license"),
+ disabled: props.instanceList.length < 1,
+ click: () => (state.showAssignLicenseDrawer = true),
+ });
+ }
+ return list;
});
const syncSchema = async () => {
diff --git a/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceV1Table.vue b/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceV1Table.vue
index c3a0e2eef3..53ec75724a 100644
--- a/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceV1Table.vue
+++ b/frontend/src/components/v2/Model/Instance/InstanceV1Table/InstanceV1Table.vue
@@ -1,11 +1,6 @@
<template>
<div>
- <InstanceOperations
- v-if="state.selectedInstance.size > 0"
- class="mb-3"
- :instance-list="selectedInstanceList"
- @dismiss="state.selectedInstance.clear()"
- />
+ <InstanceOperations class="mb-3" :instance-list="selectedInstanceList" />
<BBGrid
class="border-y"
:column-list="columnList"
diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vue
index 9b8480f07e..09d1ec84b1 100644
--- a/frontend/src/layouts/BodyLayout.vue
+++ b/frontend/src/layouts/BodyLayout.vue
@@ -190,28 +190,11 @@
<div class="w-full mx-auto md:flex">
<div class="md:min-w-0 md:flex-1">
<div
- class="w-full flex flex-row justify-between items-center flex-wrap px-2 gap-x-4"
+ class="w-full flex flex-row justify-between items-center flex-wrap px-4 gap-x-4"
>
<div v-if="quickActionList.length > 0" class="flex-1 pt-3 pb-4">
<QuickActionPanel :quick-action-list="quickActionList" />
</div>
- <div
- v-if="route.name === 'workspace.home'"
- class="hidden md:flex"
- >
- <a
- href="/sql-editor"
- target="_blank"
- class="btn-normal items-center !px-4 !text-base"
- >
- <heroicons-outline:terminal
- class="text-accent w-6 h-6 mr-2"
- />
- <span class="whitespace-nowrap">{{
- $t("sql-editor.self")
- }}</span>
- </a>
- </div>
</div>
</div>
</div>
@@ -245,7 +228,7 @@
<script lang="ts" setup>
import { storeToRefs } from "pinia";
import { computed, reactive } from "vue";
-import { useRoute, useRouter } from "vue-router";
+import { useRouter } from "vue-router";
import HideInStandaloneMode from "@/components/misc/HideInStandaloneMode.vue";
import {
useActuatorV1Store,
@@ -268,7 +251,6 @@ interface LocalState {
const actuatorStore = useActuatorV1Store();
const subscriptionStore = useSubscriptionV1Store();
-const route = useRoute();
const router = useRouter();
const state = reactive<LocalState>({
diff --git a/frontend/src/layouts/ProjectLayout.vue b/frontend/src/layouts/ProjectLayout.vue
index 3878320ab1..081d8608f6 100644
--- a/frontend/src/layouts/ProjectLayout.vue
+++ b/frontend/src/layouts/ProjectLayout.vue
@@ -23,8 +23,9 @@
</template>
<script lang="ts" setup>
-import { computed } from "vue";
+import { computed, watchEffect } from "vue";
import ArchiveBanner from "@/components/ArchiveBanner.vue";
+import { useRecentProjects } from "@/components/Project/useRecentProjects";
import HideInStandaloneMode from "@/components/misc/HideInStandaloneMode.vue";
import { useCurrentUserV1, useProjectV1Store } from "@/store";
import { DEFAULT_PROJECT_V1_NAME } from "@/types";
@@ -52,11 +53,16 @@ const props = defineProps({
const currentUserV1 = useCurrentUserV1();
const projectV1Store = useProjectV1Store();
+const recentProjects = useRecentProjects();
const project = computed(() => {
return projectV1Store.getProjectByUID(String(idFromSlug(props.projectSlug)));
});
+watchEffect(() => {
+ recentProjects.setRecentProject(project.value.name);
+});
+
const isDefaultProject = computed((): boolean => {
return project.value.name === DEFAULT_PROJECT_V1_NAME;
});
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 4137dba0c1..1b2b06b9b2 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -172,6 +172,7 @@
"agents": "Agents",
"billings": "Billings",
"all": "All",
+ "recent": "Recent",
"deployment-config": "Deployment Config",
"by": "by",
"ok": "OK",
@@ -1518,6 +1519,7 @@
"delete-this-branch": "Delete this branch",
"table-detail": "Table detail",
"batch-action-disabled": "Can not {action} for the databases from different projects",
+ "batch-action-disabled-for-unassigned": "Can not {action} for unassigned database",
"successfully-transferred-updateddatabase-name-to-project-updateddatabase-project-name": "Successfully transferred '{0}' to project '{1}'.",
"backup-name": "Backup name",
"create-backup": "Create backup",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 74ee46405a..df60fb2750 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -172,6 +172,7 @@
"agents": "Agentes",
"billings": "Facturación",
"all": "Todos",
+ "recent": "Reciente",
"deployment-config": "Configuración de Despliegue",
"by": "por",
"ok": "OK",
@@ -1517,6 +1518,7 @@
"delete-this-branch": "Eliminar esta rama",
"table-detail": "Detalle de la tabla",
"batch-action-disabled": "No se puede {action} para las bases de datos de diferentes proyectos",
+ "batch-action-disabled-for-unassigned": "No se puede {action} para una base de datos no asignada",
"successfully-transferred-updateddatabase-name-to-project-updateddatabase-project-name": "Se transfirió correctamente '{0}' al proyecto '{1}'.",
"backup-name": "Nombre de la copia de seguridad",
"create-backup": "Crear copia de seguridad",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index c58aca7d90..932ce2e56f 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -172,6 +172,7 @@
"agents": "Agents",
"billings": "计费",
"all": "全部",
+ "recent": "最近访问",
"deployment-config": "部署配置",
"by": "由",
"ok": "OK",
@@ -1514,6 +1515,7 @@
"delete-this-branch": "删除这个分支",
"table-detail": "表详情",
"batch-action-disabled": "无法对来自不同项目的数据库{action}",
+ "batch-action-disabled-for-unassigned": "无法对未分配的数据库{action}",
"successfully-transferred-updateddatabase-name-to-project-updateddatabase-project-name": "成功将'{0}'转移到项目'{1}'。",
"database-backup": "数据库备份",
"backup-name": "备份名称",
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 4f3582490c..45b4fbe9c8 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -757,13 +757,7 @@ const routes: Array<RouteRecordRaw> = [
title: () => t("common.instances"),
quickActionListByRole: () => {
return new Map([
- [
- "OWNER",
- [
- "quickaction.bb.instance.create",
- "quickaction.bb.subscription.license-assignment",
- ],
- ],
+ ["OWNER", ["quickaction.bb.instance.create"]],
["DBA", ["quickaction.bb.instance.create"]],
]);
},
@@ -781,13 +775,9 @@ const routes: Array<RouteRecordRaw> = [
title: () => t("common.databases"),
quickActionListByRole: () => {
const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.data.update",
"quickaction.bb.database.create",
];
const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.data.update",
"quickaction.bb.database.create",
"quickaction.bb.issue.grant.request.querier",
"quickaction.bb.issue.grant.request.exporter",
diff --git a/frontend/src/types/quickAction.ts b/frontend/src/types/quickAction.ts
index e036b2fa38..1fa85ec946 100644
--- a/frontend/src/types/quickAction.ts
+++ b/frontend/src/types/quickAction.ts
@@ -14,13 +14,10 @@ export type DatabaseQuickActionType =
export type IssueQuickActionType =
| "quickaction.bb.issue.grant.request.querier"
| "quickaction.bb.issue.grant.request.exporter";
-type SubscriptionQuickActionType =
- "quickaction.bb.subscription.license-assignment";
export type QuickActionType =
| EnvironmentQuickActionType
| ProjectQuickActionType
| InstanceQuickActionType
| DatabaseQuickActionType
- | IssueQuickActionType
- | SubscriptionQuickActionType;
+ | IssueQuickActionType;
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index 09aedc0777..4cfde1dd21 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -47,8 +47,13 @@
<span class="hidden lg:block mr-2">{{ $t("common.want-help") }}</span>
<heroicons-outline:chat-bubble-left-right class="w-4 h-4" />
</div>
- <a href="/sql-editor" target="_blank">
+ <a
+ href="/sql-editor"
+ target="_blank"
+ class="flex items-center text-sm gap-x-1 rounded-sm border border-control-border bg-gray-100 hover:bg-control-bg-hover py-0.5 px-1"
+ >
<heroicons-outline:terminal class="w-6 h-6" />
+ <span class="whitespace-nowrap">{{ $t("sql-editor.self") }}</span>
</a>
<router-link to="/setting/general" exact-active-class="">
<Settings class="w-6 h-6" />
diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vue
index eaea3d0f9c..1ec838c2a4 100644
--- a/frontend/src/views/DatabaseDashboard.vue
+++ b/frontend/src/views/DatabaseDashboard.vue
@@ -15,12 +15,7 @@
/>
</div>
- <DatabaseOperations
- v-if="selectedDatabases.length > 0 || isStandaloneMode"
- class="mb-3"
- :databases="selectedDatabases"
- @dismiss="state.selectedDatabaseIds.clear()"
- />
+ <DatabaseOperations class="mb-3" :databases="selectedDatabases" />
<DatabaseV1Table
pagination-class="mb-4"
diff --git a/frontend/src/views/ProjectDetail.vue b/frontend/src/views/ProjectDetail.vue
index 87153ac97c..b66de27e60 100644
--- a/frontend/src/views/ProjectDetail.vue
+++ b/frontend/src/views/ProjectDetail.vue
@@ -211,11 +211,8 @@ onMounted(() => {
const quickActionMapByRole = computed(() => {
if (project.value.state === State.ACTIVE) {
const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.data.update",
"quickaction.bb.database.create",
"quickaction.bb.project.database.transfer",
- "quickaction.bb.project.database.transfer-out",
];
const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [];
@@ -230,11 +227,7 @@ const quickActionMapByRole = computed(() => {
) {
// Default project (Unassigned databases) are not allowed
// to be changed.
- DEVELOPER_QUICK_ACTION_LIST.push(
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.data.update",
- "quickaction.bb.database.create"
- );
+ DEVELOPER_QUICK_ACTION_LIST.push("quickaction.bb.database.create");
}
if (
hasPermissionInProjectV1(
@@ -244,8 +237,7 @@ const quickActionMapByRole = computed(() => {
)
) {
DEVELOPER_QUICK_ACTION_LIST.push(
- "quickaction.bb.project.database.transfer",
- "quickaction.bb.project.database.transfer-out"
+ "quickaction.bb.project.database.transfer"
);
}
if (!isOwnerOfProjectV1(project.value.iamPolicy, currentUserV1.value)) {