Skip to content

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

feat: implement request query panel (#6683)

boojackcf346cc59526
diff --git a/frontend/src/components/Issue/form/GrantRequestExporterForm.vue b/frontend/src/components/Issue/form/GrantRequestExporterForm.vue
index fd3f9975cc..898db331aa 100644
--- a/frontend/src/components/Issue/form/GrantRequestExporterForm.vue
+++ b/frontend/src/components/Issue/form/GrantRequestExporterForm.vue
@@ -74,7 +74,7 @@ import { convertFromCELString } from "@/utils/issue/cel";
import { Engine } from "@/types/proto/v1/common";
import dayjs from "dayjs";
import DatabaseResourceTable from "../table/DatabaseResourceTable.vue";
-import { DatabaseResource } from "./SelectDatabaseResourceForm/common";
+import { DatabaseResource } from "../panel/RequestExportPanel/SelectTableForm/common";
interface LocalState {
databaseId?: string;
diff --git a/frontend/src/components/Issue/form/GrantRequestQuerierForm.vue b/frontend/src/components/Issue/form/GrantRequestQuerierForm.vue
index 4063d52357..3188192dfc 100644
--- a/frontend/src/components/Issue/form/GrantRequestQuerierForm.vue
+++ b/frontend/src/components/Issue/form/GrantRequestQuerierForm.vue
@@ -2,70 +2,11 @@
<div
class="w-full mx-auto flex flex-col justify-start items-start space-y-4 gap-4 mb-4"
>
- <div v-if="create" class="w-full flex flex-col justify-start items-start">
- <span class="flex w-full items-center textlabel mb-2">
- {{ $t("common.project") }}
- <RequiredStar />
- </span>
- <ProjectSelect
- class="!w-60"
- :only-userself="false"
- :selected-id="projectId"
- @select-project-id="handleProjectSelect"
- />
- </div>
<div class="w-full flex flex-col justify-start items-start">
<span class="flex w-full items-center textlabel mb-2">
{{ $t("common.databases") }}
- <RequiredStar />
</span>
- <div v-if="create" class="w-full">
- <NRadioGroup
- v-model:value="state.allDatabases"
- class="w-full !flex flex-row justify-start items-start gap-4"
- name="radiogroup"
- >
- <NTooltip trigger="hover">
- <template #trigger>
- <NRadio
- class="!leading-6 whitespace-nowrap"
- :value="true"
- :label="$t('issue.grant-request.all-databases')"
- />
- </template>
- {{ $t("issue.grant-request.all-databases-tip") }}
- </NTooltip>
- <div class="flex flex-row justify-start flex-wrap gap-y-2">
- <NRadio
- class="!leading-6"
- :value="false"
- :disabled="!state.projectId"
- :label="$t('issue.grant-request.manually-select')"
- />
- <button
- v-if="state.projectId && state.allDatabases === false"
- class="ml-2 normal-link h-6 disabled:cursor-not-allowed"
- @click="state.showSelectDatabasePanel = true"
- >
- {{ $t("common.select") }}
- </button>
- </div>
- </NRadioGroup>
- <div
- v-if="
- state.selectedDatabaseResourceList.length > 0 &&
- state.allDatabases === false
- "
- class="w-full max-w-3xl mt-2"
- >
- <DatabaseResourceTable
- class="w-full"
- :database-resource-list="state.selectedDatabaseResourceList"
- />
- </div>
- </div>
<div
- v-else
class="w-full flex flex-row justify-start items-start flex-wrap gap-2 gap-x-4"
>
<span v-if="state.selectedDatabaseResourceList.length === 0">{{
@@ -80,88 +21,25 @@
</div>
<div class="w-full flex flex-col justify-start items-start">
<span class="flex w-full items-center textlabel mb-4">
- {{
- create
- ? $t("issue.grant-request.expire-days")
- : $t("issue.grant-request.expired-at")
- }}
- <RequiredStar />
+ {{ $t("issue.grant-request.expired-at") }}
</span>
- <div v-if="create">
- <NRadioGroup
- v-model:value="state.expireDays"
- class="!grid grid-cols-4 gap-4"
- name="radiogroup"
- >
- <div
- v-for="day in expireDaysOptions"
- :key="day.value"
- class="col-span-1 flex flex-row justify-start items-center"
- >
- <NRadio :value="day.value" :label="day.label" />
- </div>
- <div class="col-span-2 flex flex-row justify-start items-center">
- <NRadio :value="-1" :label="$t('issue.grant-request.customize')" />
- <NInputNumber
- v-model:value="state.customDays"
- class="!w-24 ml-2"
- :disabled="state.expireDays !== -1"
- :min="1"
- :show-button="false"
- :placeholder="''"
- >
- <template #suffix>{{ $t("common.date.days") }}</template>
- </NInputNumber>
- </div>
- </NRadioGroup>
- </div>
- <div v-else>
+ <div>
{{ state.expiredAt }}
</div>
</div>
</div>
-
- <BBModal
- v-if="state.showSelectDatabasePanel && state.projectId"
- class="relative overflow-hidden"
- :title="$t('issue.grant-request.manually-select')"
- @close="state.showSelectDatabasePanel = false"
- >
- <SelectDatabaseResourceForm
- :project-id="state.projectId"
- :selected-database-resource-list="state.selectedDatabaseResourceList"
- @close="state.showSelectDatabasePanel = false"
- @update="handleSelectedDatabaseResourceChanged"
- />
- </BBModal>
</template>
<script lang="ts" setup>
import dayjs from "dayjs";
-import { head } from "lodash-es";
-import { NRadioGroup, NRadio, NInputNumber, NTooltip } from "naive-ui";
-import { computed, onMounted, reactive, watch } from "vue";
-import { useI18n } from "vue-i18n";
+import { onMounted, reactive } from "vue";
import { useIssueLogic } from "../logic";
-import {
- GrantRequestContext,
- GrantRequestPayload,
- Issue,
- IssueCreate,
- PresetRoleType,
- UNKNOWN_ID,
-} from "@/types";
-import { extractUserUID, memberListInProjectV1 } from "@/utils";
-import { useDatabaseV1Store, useProjectV1Store } from "@/store";
+import { GrantRequestPayload, Issue, PresetRoleType } from "@/types";
import { convertFromCELString } from "@/utils/issue/cel";
-import { DatabaseResource } from "./SelectDatabaseResourceForm/common";
-import RequiredStar from "@/components/RequiredStar.vue";
-import SelectDatabaseResourceForm from "./SelectDatabaseResourceForm/index.vue";
import DatabaseResourceTable from "../table/DatabaseResourceTable.vue";
+import { DatabaseResource } from "../panel/RequestQueryPanel/SelectTableForm/common";
interface LocalState {
- showSelectDatabasePanel: boolean;
- // For creating
projectId?: string;
allDatabases: boolean;
selectedDatabaseResourceList: DatabaseResource[];
@@ -171,11 +49,8 @@ interface LocalState {
expiredAt: string;
}
-const { t } = useI18n();
-const { create, issue } = useIssueLogic();
-const databaseStore = useDatabaseV1Store();
+const { issue } = useIssueLogic();
const state = reactive<LocalState>({
- showSelectDatabasePanel: false,
projectId: undefined,
allDatabases: true,
selectedDatabaseResourceList: [],
@@ -184,130 +59,26 @@ const state = reactive<LocalState>({
expiredAt: "",
});
-const projectId = computed(() => {
- return create.value ? state.projectId : (issue.value as Issue).project.id;
-});
-
-const expireDaysOptions = computed(() => [
- {
- value: 7,
- label: t("common.date.days", { days: 7 }),
- },
- {
- value: 30,
- label: t("common.date.days", { days: 30 }),
- },
- {
- value: 60,
- label: t("common.date.days", { days: 60 }),
- },
- {
- value: 90,
- label: t("common.date.days", { days: 90 }),
- },
- {
- value: 180,
- label: t("common.date.months", { months: 6 }),
- },
- {
- value: 365,
- label: t("common.date.years", { years: 1 }),
- },
-]);
-
-onMounted(() => {
- if (create.value) {
- const projectId = String((issue.value as IssueCreate).projectId);
- if (projectId && projectId !== String(UNKNOWN_ID)) {
- handleProjectSelect(projectId);
- }
- }
-});
-
-const handleProjectSelect = async (projectId: string) => {
- if (!create.value) {
- return;
+onMounted(async () => {
+ const payload = ((issue.value as Issue).payload as any)
+ .grantRequest as GrantRequestPayload;
+ if (payload.role !== PresetRoleType.QUERIER) {
+ throw "Only support QUERIER role";
}
- state.projectId = projectId;
- (issue.value as IssueCreate).projectId = parseInt(projectId, 10);
- // update issue assignee
-
- const project = await useProjectV1Store().getOrFetchProjectByUID(projectId);
- const memberList = memberListInProjectV1(project, project.iamPolicy);
- const ownerList = memberList.filter((member) =>
- member.roleList.includes(PresetRoleType.OWNER)
+ const conditionExpression = await convertFromCELString(
+ payload.condition.expression
);
- const projectOwner = head(ownerList);
- if (projectOwner) {
- const userUID = extractUserUID(projectOwner.user.name);
- (issue.value as IssueCreate).assigneeId = Number(userUID);
+ if (conditionExpression.expiredTime !== undefined) {
+ state.expiredAt = dayjs(new Date(conditionExpression.expiredTime)).format(
+ "LLL"
+ );
}
- state.selectedDatabaseResourceList =
- state.selectedDatabaseResourceList.filter((resource) => {
- const database = databaseStore.getDatabaseByName(resource.databaseName);
- return database.projectEntity.uid === projectId;
- });
-};
-
-const handleSelectedDatabaseResourceChanged = (
- databaseResourceList: DatabaseResource[]
-) => {
- state.selectedDatabaseResourceList = databaseResourceList;
- state.showSelectDatabasePanel = false;
- state.allDatabases = false;
-
- if (create.value) {
- (
- (issue.value as IssueCreate).createContext as GrantRequestContext
- ).databaseResources = databaseResourceList;
+ if (
+ conditionExpression.databaseResources !== undefined &&
+ conditionExpression.databaseResources.length > 0
+ ) {
+ state.selectedDatabaseResourceList = conditionExpression.databaseResources;
}
-};
-
-watch(
- () => [state.expireDays, state.customDays],
- () => {
- if (create.value) {
- const context = (issue.value as IssueCreate)
- .createContext as GrantRequestContext;
- if (state.expireDays === -1) {
- context.expireDays = state.customDays;
- } else {
- context.expireDays = state.expireDays;
- }
- }
- }
-);
-
-watch(
- create,
- async () => {
- if (!create.value) {
- const payload = ((issue.value as Issue).payload as any)
- .grantRequest as GrantRequestPayload;
- if (payload.role !== PresetRoleType.QUERIER) {
- throw "Only support QUERIER role";
- }
-
- const conditionExpression = await convertFromCELString(
- payload.condition.expression
- );
- if (conditionExpression.expiredTime !== undefined) {
- state.expiredAt = dayjs(
- new Date(conditionExpression.expiredTime)
- ).format("LLL");
- }
- if (
- conditionExpression.databaseResources !== undefined &&
- conditionExpression.databaseResources.length > 0
- ) {
- state.selectedDatabaseResourceList =
- conditionExpression.databaseResources;
- }
- }
- },
- {
- immediate: true,
- }
-);
+});
</script>
diff --git a/frontend/src/components/Issue/form/SelectDatabaseResourceForm/Label.vue b/frontend/src/components/Issue/panel/RequestQueryPanel/SelectDatabaseResourceForm/Label.vue
similarity index 95%
rename from frontend/src/components/Issue/form/SelectDatabaseResourceForm/Label.vue
rename to frontend/src/components/Issue/panel/RequestQueryPanel/SelectDatabaseResourceForm/Label.vue
index ced0b9d4b1..ece6785206 100644
--- a/frontend/src/components/Issue/form/SelectDatabaseResourceForm/Label.vue
+++ b/frontend/src/components/Issue/panel/RequestQueryPanel/SelectDatabaseResourceForm/Label.vue
@@ -1,11 +1,11 @@
<template>
- <div class="flex items-center gap-x-1">
+ <div class="w-full flex items-center truncate gap-x-1">
<span v-if="environment" class="text-gray-400">
(<EnvironmentV1Name :environment="environment" :link="false" />)
</span>
<Prefix />
<!-- eslint-disable-next-line vue/no-v-html -->
- <span class="truncate" v-html="optionName" />
+ <span v-html="optionName" />
<span v-if="database" class="ml-1 text-gray-500 flex flex-row items-center">
(<InstanceV1Name
:instance="database.instanceEntity"
diff --git a/frontend/src/components/Issue/form/SelectDatabaseResourceForm/common.ts b/frontend/src/components/Issue/panel/RequestQueryPanel/SelectDatabaseResourceForm/common.ts
similarity index 100%
rename from frontend/src/components/Issue/form/SelectDatabaseResourceForm/common.ts
rename to frontend/src/components/Issue/panel/RequestQueryPanel/SelectDatabaseResourceForm/common.ts
diff --git a/frontend/src/components/Issue/form/SelectDatabaseResourceForm/index.vue b/frontend/src/components/Issue/panel/RequestQueryPanel/SelectDatabaseResourceForm/index.vue
similarity index 74%
rename from frontend/src/components/Issue/form/SelectDatabaseResourceForm/index.vue
rename to frontend/src/components/Issue/panel/RequestQueryPanel/SelectDatabaseResourceForm/index.vue
index f600d97800..041ccb9d65 100644
--- a/frontend/src/components/Issue/form/SelectDatabaseResourceForm/index.vue
+++ b/frontend/src/components/Issue/panel/RequestQueryPanel/SelectDatabaseResourceForm/index.vue
@@ -11,18 +11,6 @@
:source-filterable="true"
:source-filter-placeholder="$t('database.search-database-name')"
/>
- <div class="flex items-center justify-end gap-x-2">
- <NButton @click="$emit('close')">{{ $t("common.cancel") }}</NButton>
- <NButton type="primary" :disabled="!allowConfirm" @click="doConfirm">
- {{ $t("common.confirm") }}
- </NButton>
- </div>
- <div
- v-if="loading"
- class="absolute inset-0 z-10 bg-white/70 flex items-center justify-center"
- >
- <BBSpin />
- </div>
</div>
</template>
@@ -32,7 +20,6 @@ import { uniq } from "lodash-es";
import {
NTransfer,
TransferRenderSourceList,
- NButton,
NTree,
TreeOption,
} from "naive-ui";
@@ -56,8 +43,7 @@ const props = defineProps<{
selectedDatabaseResourceList: DatabaseResource[];
}>();
-const emits = defineEmits<{
- (e: "close"): void;
+const emit = defineEmits<{
(e: "update", databaseResourceList: DatabaseResource[]): void;
}>();
@@ -101,6 +87,20 @@ onMounted(async () => {
}
}
loading.value = false;
+
+ const selectedKeyList = [];
+ for (const databaseResource of props.selectedDatabaseResourceList) {
+ let key = "";
+ if (databaseResource.table !== undefined) {
+ key = `t-${databaseResource.databaseName}-${databaseResource.schema}-${databaseResource.table}`;
+ } else if (databaseResource.schema !== undefined) {
+ key = `s-${databaseResource.databaseName}-${databaseResource.schema}`;
+ } else {
+ key = `d-${databaseResource.databaseName}`;
+ }
+ selectedKeyList.push(key);
+ }
+ selectedValueList.value = uniq(selectedKeyList);
});
const databaseList = computed(() => {
@@ -111,10 +111,6 @@ const databaseList = computed(() => {
: list;
});
-const allowConfirm = computed(() => {
- return selectedValueList.value.length > 0;
-});
-
const sourceTreeOptions = computed(() => {
return mapTreeOptions(databaseList.value);
});
@@ -173,34 +169,10 @@ const renderTargetList: TransferRenderSourceList = ({ onCheck }) => {
});
};
-const doConfirm = () => {
- const list = selectedValueList.value
- .map((key) => {
- return databaseResourceMap.value.get(key);
- })
- .filter((item) => item !== undefined);
- emits("update", list as DatabaseResource[]);
-};
-
-watch(
- () => props.selectedDatabaseResourceList,
- () => {
- const selectedKeyList = [];
- for (const databaseResource of props.selectedDatabaseResourceList) {
- let key = "";
- if (databaseResource.table !== undefined) {
- key = `t-${databaseResource.databaseName}-${databaseResource.schema}-${databaseResource.table}`;
- } else if (databaseResource.schema !== undefined) {
- key = `s-${databaseResource.databaseName}-${databaseResource.schema}`;
- } else {
- key = `d-${databaseResource.databaseName}`;
- }
- selectedKeyList.push(key);
- }
- selectedValueList.value = uniq(selectedKeyList);
- },
- {
- immediate: true,
- }
-);
+watch(selectedValueList, () => {
+ emit(
+ "update",
+ selectedValueList.value.map((key) => databaseResourceMap.value.get(key)!)
+ );
+});
</script>
diff --git a/frontend/src/components/Issue/panel/RequestQueryPanel/index.vue b/frontend/src/components/Issue/panel/RequestQueryPanel/index.vue
new file mode 100644
index 0000000000..af7bd7244b
--- /dev/null
+++ b/frontend/src/components/Issue/panel/RequestQueryPanel/index.vue
@@ -0,0 +1,311 @@
+<template>
+ <NDrawer
+ :show="true"
+ width="auto"
+ :auto-focus="false"
+ @update:show="(show: boolean) => !show && $emit('close')"
+ >
+ <NDrawerContent
+ :title="$t('quick-action.request-query')"
+ :closable="true"
+ class="w-[50rem] max-w-[100vw] relative"
+ >
+ <div class="w-full mx-auto space-y-4">
+ <div class="w-full flex flex-col justify-start items-start">
+ <span class="flex items-center textlabel mb-2">
+ {{ $t("common.project") }}
+ <RequiredStar />
+ </span>
+ <ProjectSelect
+ class="!w-60 shrink-0"
+ :only-userself="false"
+ :selected-id="state.projectId"
+ @select-project-id="handleProjectSelect"
+ />
+ </div>
+ <div class="w-full flex flex-col justify-start items-start">
+ <span class="flex items-center textlabel mb-2">
+ {{ $t("common.databases") }}
+ <RequiredStar />
+ </span>
+ <div class="w-full mb-2">
+ <NRadioGroup
+ v-model:value="state.allDatabases"
+ class="w-full !flex flex-row justify-start items-center gap-4"
+ name="export-method"
+ >
+ <NTooltip trigger="hover">
+ <template #trigger>
+ <NRadio
+ :value="true"
+ :label="$t('issue.grant-request.all-databases')"
+ />
+ </template>
+ {{ $t("issue.grant-request.all-databases-tip") }}
+ </NTooltip>
+ <NRadio
+ class="!leading-6"
+ :value="false"
+ :disabled="!state.projectId"
+ :label="$t('issue.grant-request.manually-select')"
+ />
+ </NRadioGroup>
+ </div>
+ <div
+ v-if="!state.allDatabases"
+ class="w-full flex flex-row justify-start items-center"
+ >
+ <SelectDatabaseResourceForm
+ :project-id="state.projectId"
+ :selected-database-resource-list="
+ state.selectedDatabaseResourceList
+ "
+ @update="handleSelectedDatabaseResourceChanged"
+ />
+ </div>
+ </div>
+ <div class="w-full flex flex-col justify-start items-start">
+ <span class="flex items-start textlabel mb-4">
+ {{ $t("issue.grant-request.expire-days") }}
+ <RequiredStar />
+ </span>
+ <div>
+ <NRadioGroup
+ v-model:value="state.expireDays"
+ class="!grid grid-cols-4 gap-4"
+ name="radiogroup"
+ >
+ <div
+ v-for="day in expireDaysOptions"
+ :key="day.value"
+ class="col-span-1 flex flex-row justify-start items-center"
+ >
+ <NRadio :value="day.value" :label="day.label" />
+ </div>
+ <div class="col-span-2 flex flex-row justify-start items-center">
+ <NRadio
+ :value="-1"
+ :label="$t('issue.grant-request.customize')"
+ />
+ <NInputNumber
+ v-model:value="state.customDays"
+ class="!w-24 ml-2"
+ :disabled="state.expireDays !== -1"
+ :min="1"
+ :show-button="false"
+ :placeholder="''"
+ >
+ <template #suffix>{{ $t("common.date.days") }}</template>
+ </NInputNumber>
+ </div>
+ </NRadioGroup>
+ </div>
+ </div>
+ <div class="w-full flex flex-col justify-start items-start">
+ <span class="flex items-center textlabel mb-2">{{
+ $t("common.reason")
+ }}</span>
+ <NInput
+ v-model:value="state.description"
+ type="textarea"
+ class="w-full"
+ placeholder=""
+ />
+ </div>
+ </div>
+ <template #footer>
+ <div class="flex items-center justify-end gap-x-2">
+ <NButton @click="$emit('close')">{{ $t("common.cancel") }}</NButton>
+ <NButton
+ type="primary"
+ :disabled="!allowCreate"
+ @click="doCreateIssue"
+ >
+ {{ $t("common.ok") }}
+ </NButton>
+ </div>
+ </template>
+ </NDrawerContent>
+ </NDrawer>
+</template>
+
+<script lang="ts" setup>
+import {
+ NDrawer,
+ NDrawerContent,
+ NRadioGroup,
+ NRadio,
+ NInputNumber,
+ NInput,
+ NTooltip,
+} from "naive-ui";
+import { computed, reactive } from "vue";
+import { useI18n } from "vue-i18n";
+import { IssueCreate, PresetRoleType, SYSTEM_BOT_ID } from "@/types";
+import { extractUserUID, issueSlug, memberListInProjectV1 } from "@/utils";
+import {
+ useCurrentUserV1,
+ useDatabaseV1Store,
+ useIssueStore,
+ useProjectV1Store,
+} from "@/store";
+import RequiredStar from "@/components/RequiredStar.vue";
+import { head, uniq } from "lodash-es";
+import { useRouter } from "vue-router";
+import { DatabaseResource } from "./SelectTableForm/common";
+import dayjs from "dayjs";
+import { stringifyDatabaseResources } from "@/utils/issue/cel";
+import SelectDatabaseResourceForm from "./SelectDatabaseResourceForm/index.vue";
+
+interface LocalState {
+ projectId?: string;
+ allDatabases: boolean;
+ selectedDatabaseResourceList: DatabaseResource[];
+ expireDays: number;
+ customDays: number;
+ description: string;
+}
+
+defineEmits<{
+ (event: "close"): void;
+}>();
+
+const { t } = useI18n();
+const router = useRouter();
+const databaseStore = useDatabaseV1Store();
+const currentUser = useCurrentUserV1();
+const state = reactive<LocalState>({
+ allDatabases: true,
+ selectedDatabaseResourceList: [],
+ expireDays: 7,
+ customDays: 365,
+ description: "",
+});
+
+const expireDaysOptions = computed(() => [
+ {
+ value: 7,
+ label: t("common.date.days", { days: 7 }),
+ },
+ {
+ value: 30,
+ label: t("common.date.days", { days: 30 }),
+ },
+ {
+ value: 60,
+ label: t("common.date.days", { days: 60 }),
+ },
+ {
+ value: 90,
+ label: t("common.date.days", { days: 90 }),
+ },
+ {
+ value: 180,
+ label: t("common.date.months", { months: 6 }),
+ },
+ {
+ value: 365,
+ label: t("common.date.years", { years: 1 }),
+ },
+]);
+
+const allowCreate = computed(() => {
+ if (!state.projectId) {
+ return false;
+ }
+
+ if (!state.allDatabases) {
+ return state.selectedDatabaseResourceList.length > 0;
+ }
+ return true;
+});
+
+const handleProjectSelect = async (projectId: string) => {
+ state.projectId = projectId;
+};
+
+const handleSelectedDatabaseResourceChanged = (
+ databaseResourceList: DatabaseResource[]
+) => {
+ state.selectedDatabaseResourceList = databaseResourceList;
+};
+
+const doCreateIssue = async () => {
+ if (!allowCreate.value) {
+ return;
+ }
+
+ const newIssue: IssueCreate = {
+ name: generateIssueName(),
+ type: "bb.issue.grant.request",
+ description: state.description,
+ projectId: Number(state.projectId),
+ assigneeId: SYSTEM_BOT_ID,
+ createContext: {},
+ payload: {},
+ };
+
+ // update issue's assignee to first project owner.
+ const project = await useProjectV1Store().getOrFetchProjectByUID(
+ state.projectId!
+ );
+ const memberList = memberListInProjectV1(project, project.iamPolicy);
+ const ownerList = memberList.filter((member) =>
+ member.roleList.includes(PresetRoleType.OWNER)
+ );
+ const projectOwner = head(ownerList);
+ if (projectOwner) {
+ const userUID = extractUserUID(projectOwner.user.name);
+ newIssue.assigneeId = Number(userUID);
+ }
+
+ const expression: string[] = [];
+ const expireDays =
+ state.expireDays === -1 ? state.customDays : state.expireDays;
+ expression.push(
+ `request.time < timestamp("${dayjs()
+ .add(expireDays, "days")
+ .toISOString()}")`
+ );
+ if (!state.allDatabases) {
+ const cel = stringifyDatabaseResources(state.selectedDatabaseResourceList);
+ expression.push(cel);
+ }
+
+ const celExpressionString = expression.join(" && ");
+ newIssue.payload = {
+ grantRequest: {
+ role: "roles/QUERIER",
+ user: currentUser.value.name,
+ condition: {
+ expression: celExpressionString,
+ },
+ },
+ };
+
+ const issue = await useIssueStore().createIssue(newIssue);
+ router.push(`/issue/${issueSlug(issue.name, issue.id)}`);
+};
+
+const generateIssueName = () => {
+ if (!state.projectId) {
+ throw new Error("No project selected");
+ }
+
+ if (state.allDatabases) {
+ return `Request query for all database`;
+ } else {
+ const databaseNames = uniq(
+ state.selectedDatabaseResourceList.map(
+ (databaseResource) => databaseResource.databaseName
+ )
+ );
+ const databases = databaseNames.map((name) =>
+ databaseStore.getDatabaseByName(name)
+ );
+ return `Request query for "${databases
+ .map((database) => database.databaseName)
+ .join(", ")}"`;
+ }
+};
+</script>
diff --git a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue
index 90b7ba3f85..e3a45076fe 100644
--- a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue
+++ b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue
@@ -108,7 +108,7 @@ const expireDaysOptions = computed(() => [
},
{
value: 0,
- label: "Never",
+ label: t("project.members.never-expires"),
},
]);
diff --git a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue
index 062d699669..d71402d3f3 100644
--- a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue
+++ b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue
@@ -19,7 +19,9 @@
</div>
<div>
<NButton @click="handleAddMore">
- <heroicons-solid:plus class="w-5 h-auto" />Add more
+ <heroicons-solid:plus class="w-5 h-auto" />{{
+ $t("project.members.add-more")
+ }}
</NButton>
</div>
<template #footer>
diff --git a/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberRolePanel.vue b/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberRolePanel.vue
index 77cbadd884..2cdd4a2812 100644
--- a/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberRolePanel.vue
+++ b/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberRolePanel.vue
@@ -335,7 +335,7 @@ const handleDeleteCondition = async (singleBinding: SingleBinding) => {
onPositiveClick: async () => {
const user = `user:${props.member.user.email}`;
const policy = cloneDeep(iamPolicy.value);
- let rawBinding = policy.bindings.find((binding) =>
+ const rawBinding = policy.bindings.find((binding) =>
isEqual(binding, singleBinding.rawBinding)
);
if (!rawBinding) {
@@ -358,11 +358,11 @@ const handleDeleteCondition = async (singleBinding: SingleBinding) => {
(binding) => !isEqual(binding, rawBinding)
);
} else {
- rawBinding = cloneDeep(rawBinding);
- rawBinding.members = [user];
- rawBinding.condition!.expression =
+ const newBinding = cloneDeep(rawBinding);
+ newBinding.members = [user];
+ newBinding.condition!.expression =
stringifyConditionExpression(conditionExpr);
- policy.bindings.push(rawBinding);
+ policy.bindings.push(newBinding);
}
}
}
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vue
index f4e740f095..d4ef0489b2 100644
--- a/frontend/src/components/QuickActionPanel.vue
+++ b/frontend/src/components/QuickActionPanel.vue
@@ -179,7 +179,7 @@
>
<button
class="btn-icon-primary p-3"
- @click.prevent="createRequestQueryIssue"
+ @click.prevent="state.showRequestQueryPanel = true"
>
<heroicons-outline:document-search class="w-5 h-5" />
</button>
@@ -264,6 +264,11 @@
@cancel="state.showFeatureModal = false"
/>
+ <RequestQueryPanel
+ v-if="state.showRequestQueryPanel"
+ @close="state.showRequestQueryPanel = false"
+ />
+
<RequestExportPanel
v-if="state.showRequestExportPanel"
@close="state.showRequestExportPanel = false"
@@ -283,7 +288,6 @@ import {
useCurrentUserIamPolicy,
useInstanceV1Store,
useProjectV1ListByCurrentUser,
- useRouterStore,
useSubscriptionV1Store,
} from "@/store";
import { Drawer } from "@/components/v2";
@@ -294,11 +298,13 @@ import { CreateDatabasePrepPanel } from "@/components/CreateDatabasePrepForm";
import TransferDatabaseForm from "@/components/TransferDatabaseForm.vue";
import TransferOutDatabaseForm from "@/components/TransferOutDatabaseForm";
import RequestExportPanel from "@/components/Issue/panel/RequestExportPanel/index.vue";
+import RequestQueryPanel from "@/components/Issue/panel/RequestQueryPanel/index.vue";
interface LocalState {
featureName: string;
showFeatureModal: boolean;
quickActionType: QuickActionType | undefined;
+ showRequestQueryPanel: boolean;
showRequestExportPanel: boolean;
}
@@ -312,7 +318,6 @@ const props = defineProps({
const { t } = useI18n();
const router = useRouter();
const route = useRoute();
-const routerStore = useRouterStore();
const commandStore = useCommandStore();
const subscriptionStore = useSubscriptionV1Store();
@@ -324,6 +329,7 @@ const state = reactive<LocalState>({
featureName: "",
showFeatureModal: false,
quickActionType: undefined,
+ showRequestQueryPanel: false,
showRequestExportPanel: false,
});
@@ -388,27 +394,6 @@ const createEnvironment = () => {
commandStore.dispatchCommand("bb.environment.create");
};
-const createRequestQueryIssue = () => {
- const routeInfo = {
- name: "workspace.issue.detail",
- params: {
- issueSlug: "new",
- },
- query: {
- template: "bb.issue.grant.request",
- role: "QUERIER",
- name: "Request data query permission",
- },
- };
- const routeSlug = routerStore.routeSlug(route);
- const projectSlug = routeSlug.projectSlug;
- if (projectSlug) {
- const id = idFromSlug(projectSlug);
- (routeInfo.query as any).project = id;
- }
- router.push(routeInfo);
-};
-
const reorderEnvironment = () => {
commandStore.dispatchCommand("bb.environment.reorder");
};
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 8dfc1e92f9..c2b04bdd9c 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1478,7 +1478,9 @@
"show-inactive": "Show inactive members",
"select-users": "Select users",
"assign-role": "Assign role",
- "role-never-expires": "This role will never expires."
+ "never-expires": "Never",
+ "role-never-expires": "This role never expires.",
+ "add-more": "Add more"
},
"mode": {
"standard": "Standard Mode",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 8a45b6bfde..1c7f828980 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1471,7 +1471,9 @@
"show-inactive": "Mostrar miembros inactivos",
"select-users": "Seleccionar usuarios",
"assign-role": "Asignar rol",
- "role-never-expires": "Este rol nunca expira."
+ "never-expires": "Nunca caduca",
+ "role-never-expires": "Este rol nunca expira.",
+ "add-more": "Más información"
},
"mode": {
"standard": "Modo Estándar",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index d748c76eb6..f99b5f756a 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1473,7 +1473,9 @@
"show-inactive": "显示未激活成员",
"select-users": "选择用户",
"assign-role": "分配角色",
- "role-never-expires": "此角色没有过期时间。"
+ "never-expires": "永不过期",
+ "role-never-expires": "此角色没有过期时间。",
+ "add-more": "增加更多"
},
"mode": {
"standard": "标准模式",