Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: update grant access and request export fields (#8005)
boojack3f7ac6fff917
diff --git a/frontend/src/components/Issue/IssueHighlightPanel.vue b/frontend/src/components/Issue/IssueHighlightPanel.vueindex 1abf335ff4..53924c3dff 100644--- a/frontend/src/components/Issue/IssueHighlightPanel.vue+++ b/frontend/src/components/Issue/IssueHighlightPanel.vue@@ -165,7 +165,15 @@ const isFinishedGrantRequestIssueByCurrentUser = computed(() => {const showExportCenterLink = computed(() => {if (!isFinishedGrantRequestIssueByCurrentUser.value) return false;- return issue.value.payload.grantRequest?.role === PresetRoleType.EXPORTER;++ return (+ issue.value.payload.grantRequest?.role === PresetRoleType.EXPORTER &&+ // Show the export button only when the grant request condition is based on the statement.+ // TODO: Use parsed CEL expression instead of string matching.+ (issue.value.payload.grantRequest?.condition.expression || "").includes(+ "request.statement == "+ )+ );});const showSQLEditorLink = computed(() => {diff --git a/frontend/src/components/Issue/form/GrantRequestExporterForm.vue b/frontend/src/components/Issue/form/GrantRequestExporterForm.vueindex f96239dc30..d38615d49f 100644--- a/frontend/src/components/Issue/form/GrantRequestExporterForm.vue+++ b/frontend/src/components/Issue/form/GrantRequestExporterForm.vue@@ -6,10 +6,21 @@<span class="flex items-center textlabel mb-2">{{ $t("common.database") }}</span>- <DatabaseResourceTable- class="w-full"- :database-resource-list="selectedDatabaseResources"- />+ <div+ class="w-full flex flex-row justify-start items-start flex-wrap gap-2 gap-x-4"+ >+ <span+ v-if="+ exportMethod !== 'SQL' && selectedDatabaseResources.length === 0+ "+ >{{ $t("issue.grant-request.all-databases") }}</span+ >+ <DatabaseResourceTable+ v-else+ class="w-full"+ :database-resource-list="selectedDatabaseResources"+ />+ </div></div><divv-if="exportMethod === 'SQL'"diff --git a/frontend/src/components/Issue/panel/RequestExportPanel/index.vue b/frontend/src/components/Issue/panel/RequestExportPanel/index.vueindex cca0256bb4..f8d48653aa 100644--- a/frontend/src/components/Issue/panel/RequestExportPanel/index.vue+++ b/frontend/src/components/Issue/panel/RequestExportPanel/index.vue@@ -23,59 +23,74 @@@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.database") }}- <RequiredStar />- </span>- <div class="flex flex-row justify-start items-center">- <EnvironmentSelect- class="!w-60 mr-4 shrink-0"- name="environment"- :select-default="false"- :selected-id="state.environmentId"- @select-environment-id="handleEnvironmentSelect"- />- <DatabaseSelect- class="!w-96"- :selected-id="state.databaseId ?? String(UNKNOWN_ID)"- :mode="'ALL'"- :environment-id="state.environmentId"++ <template v-if="props.statementOnly">+ <div class="w-full flex flex-col justify-start items-start">+ <span class="flex items-center textlabel mb-2">+ {{ $t("common.database") }}+ <RequiredStar />+ </span>+ <div class="flex flex-row justify-start items-center">+ <EnvironmentSelect+ class="!w-60 mr-4 shrink-0"+ name="environment"+ :select-default="false"+ :selected-id="state.environmentId"+ @select-environment-id="handleEnvironmentSelect"+ />+ <DatabaseSelect+ class="!w-96"+ :selected-id="state.databaseId ?? String(UNKNOWN_ID)"+ :mode="'ALL'"+ :environment-id="state.environmentId"+ :project-id="state.projectId"+ :sync-status="'OK'"+ :customize-item="true"+ @select-database-id="handleDatabaseSelect"+ >+ <template #customizeItem="{ database }">+ <div class="flex items-center">+ <InstanceV1EngineIcon :instance="database.instanceEntity" />+ <span class="mx-2">{{ database.databaseName }}</span>+ <span class="text-gray-400">+ ({{ instanceV1Name(database.instanceEntity) }})+ </span>+ </div>+ </template>+ </DatabaseSelect>+ </div>+ </div>+ <div class="w-full flex flex-col justify-start items-start">+ <span class="flex items-center textlabel mb-2">+ SQL+ <RequiredStar />+ </span>+ <div class="w-full h-[300px] border rounded">+ <MonacoEditor+ class="w-full h-full py-2"+ :value="state.statement"+ :auto-focus="false"+ :language="'sql'"+ :dialect="dialect"+ @change="(value: string) => (state.statement = value)"+ />+ </div>+ </div>+ </template>+ <template v-else>+ <div class="w-full flex flex-col justify-start items-start">+ <span class="flex items-center textlabel mb-2">+ {{ $t("common.databases") }}+ <RequiredStar />+ </span>+ <DatabaseResourceForm:project-id="state.projectId"- :sync-status="'OK'"- :customize-item="true"- @select-database-id="handleDatabaseSelect"- >- <template #customizeItem="{ database }">- <div class="flex items-center">- <InstanceV1EngineIcon :instance="database.instanceEntity" />- <span class="mx-2">{{ database.databaseName }}</span>- <span class="text-gray-400">- ({{ instanceV1Name(database.instanceEntity) }})- </span>- </div>- </template>- </DatabaseSelect>+ :database-resources="state.databaseResources"+ @update:condition="state.databaseResourceCondition = $event"+ @update:database-resources="state.databaseResources = $event"+ /></div>- </div>- <div class="w-full flex flex-col justify-start items-start">- <span class="flex items-center textlabel mb-2">- {{- props.statementOnly- ? "SQL"- : $t("issue.grant-request.export-method")- }}- <RequiredStar />- </span>- <ExportResourceForm- :project-id="state.projectId"- :database-id="state.databaseId"- :statement="statement"- :statement-only="props.statementOnly"- @update:condition="state.databaseResourceCondition = $event"- @update:database-resources="state.databaseResources = $event"- />- </div>+ </template><div class="w-full flex flex-col justify-start items-start"><span class="flex items-center textlabel mb-2">{{ $t("issue.grant-request.export-rows") }}@@ -151,9 +166,12 @@ import {DatabaseResource,IssueCreate,PresetRoleType,+ SQLDialect,SYSTEM_BOT_ID,UNKNOWN_ID,+ dialectOfEngineV1,} from "@/types";+import { Engine } from "@/types/proto/v1/common";import {extractUserUID,instanceV1Name,@@ -161,7 +179,7 @@ import {memberListInProjectV1,} from "@/utils";import { stringifyDatabaseResources } from "@/utils/issue/cel";-import ExportResourceForm from "./ExportResourceForm/index.vue";+import DatabaseResourceForm from "../RequestQueryPanel/DatabaseResourceForm/index.vue";interface LocalState {projectId?: string;@@ -190,6 +208,7 @@ const { t } = useI18n();const router = useRouter();const currentUser = useCurrentUserV1();const databaseStore = useDatabaseV1Store();+const projectStore = useProjectV1Store();const state = reactive<LocalState>({databaseResources: [],expireDays: 1,@@ -224,12 +243,23 @@ const expireDaysOptions = computed(() => [},]);+const dialect = computed((): SQLDialect => {+ const db = selectedDatabase.value;+ return dialectOfEngineV1(db?.instanceEntity.engine ?? Engine.MYSQL);+});+const allowCreate = computed(() => {- if (!state.databaseId) {+ if (!state.projectId) {return false;}- if (isUndefined(state.databaseResourceCondition)) {- return false;+ if (props.statementOnly) {+ if (!state.databaseId || !state.statement) {+ return false;+ }+ } else {+ if (isUndefined(state.databaseResourceCondition)) {+ return false;+ }}return true;});@@ -289,9 +319,7 @@ const doCreateIssue = async () => {};// update issue's assignee to first project owner.- const project = await useProjectV1Store().getOrFetchProjectByUID(- state.projectId!- );+ const project = await projectStore.getOrFetchProjectByUID(state.projectId!);const memberList = memberListInProjectV1(project, project.iamPolicy);const ownerList = memberList.filter((member) =>member.roleList.includes(PresetRoleType.OWNER)@@ -310,17 +338,25 @@ const doCreateIssue = async () => {.toISOString()}")`);expression.push(`request.row_limit <= ${state.maxRowCount}`);- if (state.databaseResourceCondition) {- expression.push(state.databaseResourceCondition);- }- // If the export statement is not empty, add the selected database to the condition.- if (state.databaseResources.length === 0) {- const condition = stringifyDatabaseResources([- {- databaseName: selectedDatabase.value!.name,- },- ]);- expression.push(condition);+ if (props.statementOnly) {+ // Selected database condition.+ expression.push(+ stringifyDatabaseResources([+ {+ databaseName: selectedDatabase.value!.name,+ },+ ])+ );+ // Statement condition.+ expression.push(+ `request.statement == "${btoa(+ unescape(encodeURIComponent(state.statement))+ )}"`+ );+ } else {+ if (state.databaseResourceCondition) {+ expression.push(state.databaseResourceCondition);+ }}const celExpressionString = expression.join(" && ");@@ -356,28 +392,33 @@ const doCreateIssue = async () => {};const generateIssueName = () => {- const database = selectedDatabase.value;- if (!database) {- throw new Error("No database selected");- }+ if (props.statementOnly) {+ const database = selectedDatabase.value;+ if (!database) {+ throw new Error("Database is not selected");+ }- if (state.databaseResources.length === 0) {- return `Request data export for "${database.databaseName} (${database.instanceEntity.title})"`;- } else {- const sections: string[] = [];- for (const databaseResource of state.databaseResources) {- const nameList = [database.databaseName];- if (databaseResource.schema) {- nameList.push(databaseResource.schema);+ if (state.databaseResources.length === 0) {+ return `Request data export for "${database.databaseName} (${database.instanceEntity.title})"`;+ } else {+ const sections: string[] = [];+ for (const databaseResource of state.databaseResources) {+ const nameList = [database.databaseName];+ if (databaseResource.schema) {+ nameList.push(databaseResource.schema);+ }+ if (databaseResource.table) {+ nameList.push(databaseResource.table);+ }+ sections.push(nameList.join("."));}- if (databaseResource.table) {- nameList.push(databaseResource.table);- }- sections.push(nameList.join("."));+ return `Request data export for "${sections.join(".")} (${+ database.instanceEntity.title+ })"`;}- return `Request data export for "${sections.join(".")} (${- database.instanceEntity.title- })"`;+ } else {+ const project = projectStore.getProjectByUID(state.projectId!);+ return `Request data export for "${project.title}"`;}};</script>diff --git a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vueindex 7bca99f372..b84b0507df 100644--- a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue+++ b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue@@ -23,7 +23,10 @@<ProjectMemberRoleSelect v-model:role="state.role" class="mt-2" /></div>- <div v-if="state.role === 'roles/QUERIER'" class="w-full">+ <div+ v-if="state.role === 'roles/QUERIER' || state.role === 'roles/EXPORTER'"+ class="w-full"+ ><span class="block mb-2">{{ $t("common.databases") }}</span><QuerierDatabaseResourceForm:project-id="project.uid"@@ -33,28 +36,6 @@/></div><template v-if="state.role === 'roles/EXPORTER'">- <div class="w-full">- <span class="block mb-2">{{ $t("common.database") }}</span>- <DatabaseSelect- class="!w-full"- :project="project.uid"- :database="state.databaseId"- @update:database="state.databaseId = $event"- />- </div>- <div class="w-full">- <span class="block mb-2">{{- $t("issue.grant-request.export-method")- }}</span>- <ExporterDatabaseResourceForm- class="w-full"- :project-id="project.uid"- :database-id="state.databaseId"- :database-resources="state.databaseResources"- @update:condition="state.databaseResourceCondition = $event"- @update:database-resources="state.databaseResources = $event"- />- </div><div class="w-full flex flex-col justify-start items-start"><span class="mb-2">{{ $t("issue.grant-request.export-rows") }}@@ -86,9 +67,7 @@ import { NInputNumber } from "naive-ui";import { computed, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import ExpirationSelector from "@/components/ExpirationSelector.vue";-import ExporterDatabaseResourceForm from "@/components/Issue/panel/RequestExportPanel/ExportResourceForm/index.vue";import QuerierDatabaseResourceForm from "@/components/Issue/panel/RequestQueryPanel/DatabaseResourceForm/index.vue";-import { DatabaseSelect } from "@/components/v2";import ProjectMemberRoleSelect from "@/components/v2/Select/ProjectMemberRoleSelect.vue";import { useUserStore } from "@/store";import { ComposedProject, DatabaseResource, PresetRoleType } from "@/types";diff --git a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vueindex e491fb75fa..214e0a8c0c 100644--- a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue+++ b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue@@ -102,11 +102,7 @@ const allowConfirm = computed(() => {if (binding.condition?.expression === "") {return false;}- if (- (!binding.condition?.expression.includes("request.statement") &&- !binding.condition?.expression.includes("resource.database")) ||- !binding.condition?.expression.includes("request.row_limit")- ) {+ if (!binding.condition?.expression.includes("request.row_limit")) {return false;}}diff --git a/frontend/src/components/ProjectMember/ProjectRoleTable/EditProjectRolePanel.vue b/frontend/src/components/ProjectMember/ProjectRoleTable/EditProjectRolePanel.vueindex ad324fc1d3..19c2cee545 100644--- a/frontend/src/components/ProjectMember/ProjectRoleTable/EditProjectRolePanel.vue+++ b/frontend/src/components/ProjectMember/ProjectRoleTable/EditProjectRolePanel.vue@@ -23,8 +23,13 @@</div><template v-if="!isLoading">- <!-- Querier blocks -->- <div v-if="binding.role === 'roles/QUERIER'" class="w-full">+ <div+ v-if="+ binding.role === 'roles/QUERIER' ||+ binding.role === 'roles/EXPORTER'+ "+ class="w-full"+ ><p class="mb-2">{{ $t("common.databases") }}</p><QuerierDatabaseResourceForm:project-id="project.uid"@@ -36,27 +41,6 @@<!-- Exporter blocks --><template v-if="binding.role === 'roles/EXPORTER'">- <div class="w-full">- <span class="block mb-2">{{ $t("common.database") }}</span>- <DatabaseSelect- class="!w-full"- :project="project.uid"- :database="state.databaseId"- @update:database="state.databaseId = $event"- />- </div>- <div class="w-full">- <p class="mb-2">{{ $t("issue.grant-request.export-method") }}</p>- <ExporterDatabaseResourceForm- class="w-full"- :project-id="project.uid"- :database-id="state.databaseId"- :database-resources="state.databaseResources"- :statement="state.statement"- @update:condition="state.databaseResourceCondition = $event"- @update:database-resources="state.databaseResources = $event"- />- </div><div class="w-full flex flex-col justify-start items-start"><p class="mb-2">{{ $t("issue.grant-request.export-rows") }}@@ -144,9 +128,7 @@ import {} from "naive-ui";import { computed, reactive, ref } from "vue";import { onMounted } from "vue";-import ExporterDatabaseResourceForm from "@/components/Issue/panel/RequestExportPanel/ExportResourceForm/index.vue";import QuerierDatabaseResourceForm from "@/components/Issue/panel/RequestQueryPanel/DatabaseResourceForm/index.vue";-import { DatabaseSelect } from "@/components/v2";import {extractUserEmail,useCurrentUserV1,