Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Handles the Environment/Instance/Project archive logic in list and select
天舟826e71eb9df7
diff --git a/frontend/src/components/DatabaseListSidePanel.vue b/frontend/src/components/DatabaseListSidePanel.vueindex dd3ad372e8..cd080e9e69 100644--- a/frontend/src/components/DatabaseListSidePanel.vue+++ b/frontend/src/components/DatabaseListSidePanel.vue@@ -26,7 +26,7 @@ export default {const environmentList = computed(() => {return cloneDeep(- store.getters["environment/environmentList"]("NORMAL")+ store.getters["environment/environmentList"]()).reverse();});diff --git a/frontend/src/components/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm.vueindex 7c4e60d53c..6e6ddd3f02 100644--- a/frontend/src/components/EnvironmentForm.vue+++ b/frontend/src/components/EnvironmentForm.vue@@ -123,7 +123,7 @@ export default {const currentUser = computed(() => store.getters["auth/currentUser"]());const environmentList = computed(() => {- return store.getters["environment/environmentList"]("NORMAL");+ return store.getters["environment/environmentList"]();});const allowArchive = computed(() => {diff --git a/frontend/src/components/EnvironmentSelect.vue b/frontend/src/components/EnvironmentSelect.vueindex d6a1ab284a..e0ba6cffa6 100644--- a/frontend/src/components/EnvironmentSelect.vue+++ b/frontend/src/components/EnvironmentSelect.vue@@ -17,7 +17,7 @@:value="environment.id":selected="environment.id == state.selectedId">- {{ environment.name }}+ {{ environmentName(environment) }}</option><optionv-else-if="environment.id == state.selectedId"@@ -65,7 +65,7 @@ export default {const environmentList = computed(() => {return cloneDeep(- store.getters["environment/environmentList"]()+ store.getters["environment/environmentList"](["NORMAL", "ARCHIVED"])).reverse();});diff --git a/frontend/src/components/EnvironmentTabFilter.vue b/frontend/src/components/EnvironmentTabFilter.vueindex e8c2d7bfc7..dc5b273c5e 100644--- a/frontend/src/components/EnvironmentTabFilter.vue+++ b/frontend/src/components/EnvironmentTabFilter.vue@@ -41,7 +41,7 @@ export default {// Usually env is ordered by ascending importance (dev -> test -> staging -> prod),// thus we rervese the order to put more important ones first.return cloneDeep(- store.getters["environment/environmentList"]("NORMAL")+ store.getters["environment/environmentList"]()).reverse();});diff --git a/frontend/src/components/InstanceSelect.vue b/frontend/src/components/InstanceSelect.vueindex b100919bbe..bf1936d6ef 100644--- a/frontend/src/components/InstanceSelect.vue+++ b/frontend/src/components/InstanceSelect.vue@@ -11,14 +11,23 @@<option disabled :selected="undefined === state.selectedId">Select instance</option>- <option- v-for="(instance, index) in instanceList"- :key="index"- :value="instance.id"- :selected="instance.id == state.selectedId"- >- {{ instance.name }}- </option>+ <template v-for="(instance, index) in instanceList" :key="index">+ <option+ v-if="instance.rowStatus == 'NORMAL'"+ :key="index"+ :value="instance.id"+ :selected="instance.id == state.selectedId"+ >+ {{ instanceName(instance) }}+ </option>+ <option+ v-else-if="instance.id == state.selectedId"+ :value="instance.id"+ :selected="true"+ >+ {{ instanceName(instance) }}+ </option>+ </template></select></template>@@ -55,12 +64,11 @@ export default {const instanceList = computed(() => {if (props.environmentId) {- return store.getters["instance/instanceListByEnvironmentId"](- props.environmentId,- "NORMAL"- );+ return store.getters[+ "instance/instanceListByEnvironmentId"+ ](props.environmentId, ["NORMAL", "ARCHIVED"]);}- return store.getters["instance/instanceList"]("NORMAL");+ return store.getters["instance/instanceList"](["NORMAL", "ARCHIVED"]);});watch(diff --git a/frontend/src/components/ProjectSelect.vue b/frontend/src/components/ProjectSelect.vueindex 8788385395..7edf602a1c 100644--- a/frontend/src/components/ProjectSelect.vue+++ b/frontend/src/components/ProjectSelect.vue@@ -31,7 +31,7 @@:value="project.id":selected="project.id == state.selectedId">- {{ project.name }}+ {{ projectName(project) }}</option><optionv-else-if="project.id == state.selectedId"@@ -81,6 +81,7 @@ export default {store.dispatch("project/fetchProjectListByUser", {userId: currentUser.value.id,+ rowStatusList: ["NORMAL", "ARCHIVED"],}).catch((error) => {console.log(error);@@ -90,7 +91,10 @@ export default {watchEffect(prepareProjectList);const projectList = computed((): Project[] => {- return store.getters["project/projectListByUser"](currentUser.value.id);+ return store.getters["project/projectListByUser"](currentUser.value.id, [+ "NORMAL",+ "ARCHIVED",+ ]);});const selectedIdNotInList = computed((): boolean => {diff --git a/frontend/src/miragejs/routes/environment.js b/frontend/src/miragejs/routes/environment.jsindex 22718b20ab..5a85c9a956 100644--- a/frontend/src/miragejs/routes/environment.js+++ b/frontend/src/miragejs/routes/environment.js@@ -17,10 +17,15 @@ export default function configureEnvironment(route) {if (environment.rowStatus != "NORMAL") {return false;}- } else if (- environment.rowStatus.toLowerCase() != rowStatus.toLowerCase()- ) {- return false;+ } else {+ const rowStatusList = rowStatus.split(",");+ if (+ !rowStatusList.find((item) => {+ return item.toLowerCase() == environment.rowStatus.toLowerCase();+ })+ ) {+ return false;+ }}return true;diff --git a/frontend/src/miragejs/routes/instance.js b/frontend/src/miragejs/routes/instance.jsindex 4faad77919..86abdc14c5 100644--- a/frontend/src/miragejs/routes/instance.js+++ b/frontend/src/miragejs/routes/instance.js@@ -17,8 +17,15 @@ export default function configurInstance(route) {if (instance.rowStatus != "NORMAL") {return false;}- } else if (instance.rowStatus.toLowerCase() != rowStatus.toLowerCase()) {- return false;+ } else {+ const rowStatusList = rowStatus.split(",");+ if (+ !rowStatusList.find((item) => {+ return item.toLowerCase() == instance.rowStatus.toLowerCase();+ })+ ) {+ return false;+ }}return true;diff --git a/frontend/src/miragejs/routes/project.js b/frontend/src/miragejs/routes/project.jsindex 9d5c64fe67..738bf1f3f6 100644--- a/frontend/src/miragejs/routes/project.js+++ b/frontend/src/miragejs/routes/project.js@@ -16,8 +16,15 @@ export default function configureProject(route) {if (project.rowStatus != "NORMAL") {return false;}- } else if (project.rowStatus.toLowerCase() != rowStatus.toLowerCase()) {- return false;+ } else {+ const rowStatusList = rowStatus.split(",");+ if (+ !rowStatusList.find((item) => {+ return item.toLowerCase() == project.rowStatus.toLowerCase();+ })+ ) {+ return false;+ }}if (userId) {diff --git a/frontend/src/store/modules/environment.ts b/frontend/src/store/modules/environment.tsindex 8dfc9fba3b..27e7b8a950 100644--- a/frontend/src/store/modules/environment.ts+++ b/frontend/src/store/modules/environment.ts@@ -24,14 +24,11 @@ const state: () => EnvironmentState = () => ({const getters = {environmentList: (state: EnvironmentState) => (- rowStatus?: RowStatus+ rowStatusList?: RowStatus[]): Environment[] => {- if (rowStatus) {- return state.environmentList.filter((environment: Environment) => {- return environment.rowStatus == rowStatus;- });- }- return state.environmentList;+ return state.environmentList.filter((environment: Environment) => {+ return !rowStatusList || rowStatusList.includes(environment.rowStatus);+ });},environmentById: (state: EnvironmentState) => (@@ -47,10 +44,10 @@ const getters = {};const actions = {- async fetchEnvironmentList({ commit }: any, rowStatus?: RowStatus) {+ async fetchEnvironmentList({ commit }: any, rowStatusList?: RowStatus[]) {const path ="/api/environment" +- (rowStatus ? "?rowstatus=" + rowStatus.toLowerCase() : "");+ (rowStatusList ? "?rowstatus=" + rowStatusList.join(",") : "");const environmentList = (await axios.get(path)).data.data.map((env: ResourceObject) => {return convert(env);diff --git a/frontend/src/store/modules/instance.ts b/frontend/src/store/modules/instance.tsindex be3b7e4cb2..19f60d9803 100644--- a/frontend/src/store/modules/instance.ts+++ b/frontend/src/store/modules/instance.ts@@ -14,14 +14,15 @@ import {} from "../../types";function convert(instance: ResourceObject, rootGetters: any): Instance {- const environment = rootGetters["environment/environmentList"]().find(- (env: Environment) => {- return (- env.id ==- (instance.relationships!.environment.data as ResourceIdentifier).id- );- }- );+ const environment = rootGetters["environment/environmentList"]([+ "NORMAL",+ "ARCHIVED",+ ]).find((env: Environment) => {+ return (+ env.id ==+ (instance.relationships!.environment.data as ResourceIdentifier).id+ );+ });const creator = rootGetters["principal/principalById"](instance.attributes.creatorId);@@ -56,11 +57,11 @@ const getters = {},instanceList: (state: InstanceState) => (- rowStatus?: RowStatus+ rowStatusList?: RowStatus[]): Instance[] => {const list = [];for (const [_, instance] of state.instanceById) {- if (!rowStatus || rowStatus == instance.rowStatus) {+ if (!rowStatusList || rowStatusList.includes(instance.rowStatus)) {list.push(instance);}}@@ -71,9 +72,9 @@ const getters = {instanceListByEnvironmentId: (state: InstanceState, getters: any) => (environmentId: EnvironmentId,- rowStatus?: RowStatus+ rowStatusList?: RowStatus[]): Instance[] => {- const list = getters["instanceList"](rowStatus);+ const list = getters["instanceList"](rowStatusList);return list.filter((item: Instance) => {return item.environment.id == environmentId;});@@ -89,10 +90,13 @@ const getters = {};const actions = {- async fetchInstanceList({ commit, rootGetters }: any, rowStatus?: RowStatus) {+ async fetchInstanceList(+ { commit, rootGetters }: any,+ rowStatusList?: RowStatus[]+ ) {const path ="/api/instance" +- (rowStatus ? "?rowstatus=" + rowStatus.toLowerCase() : "");+ (rowStatusList ? "?rowstatus=" + rowStatusList.join(",") : "");const instanceList = (await axios.get(path)).data.data.map((instance: ResourceObject) => {return convert(instance, rootGetters);diff --git a/frontend/src/store/modules/project.ts b/frontend/src/store/modules/project.tsindex 59467a6805..61a98ee0d5 100644--- a/frontend/src/store/modules/project.ts+++ b/frontend/src/store/modules/project.ts@@ -125,17 +125,16 @@ const getters = {projectListByUser: (state: ProjectState) => (userId: UserId,- rowStatus?: RowStatus+ rowStatusList?: RowStatus[]): Project[] => {const result: Project[] = [];for (const [_, project] of state.projectById) {- for (const member of project.memberList) {- if (- member.principal.id == userId &&- (!rowStatus || rowStatus == project.rowStatus)- ) {- result.push(project);- break;+ if (!rowStatusList || rowStatusList.includes(project.rowStatus)) {+ for (const member of project.memberList) {+ if (member.principal.id == userId) {+ result.push(project);+ break;+ }}}}@@ -163,15 +162,15 @@ const actions = {{ commit, rootGetters }: any,{userId,- rowStatus,+ rowStatusList,}: {userId: UserId;- rowStatus?: RowStatus;+ rowStatusList?: RowStatus[];}) {const path =`/api/project?userid=${userId}` +- (rowStatus ? "&rowstatus=" + rowStatus.toLowerCase() : "");+ (rowStatusList ? "&rowstatus=" + rowStatusList.join(",") : "");const data = (await axios.get(`${path}&include=projectMember`)).data;const projectList = data.data.map((project: ResourceObject) => {return convert(project, data.included, rootGetters);@@ -316,10 +315,8 @@ const mutations = {},upsertProjectList(state: ProjectState, projectList: Project[]) {- const idList = [];for (const project of projectList) {state.projectById.set(project.id, project);- idList.push(project.id);}},};diff --git a/frontend/src/views/Archive.vue b/frontend/src/views/Archive.vueindex 1152241552..212c0f59d6 100644--- a/frontend/src/views/Archive.vue+++ b/frontend/src/views/Archive.vue@@ -75,7 +75,7 @@ export default {store.dispatch("project/fetchProjectListByUser", {userId: currentUser.value.id,- rowStatus: "ARCHIVED",+ rowStatusList: ["ARCHIVED"],}).catch((error) => {console.error(error);@@ -83,13 +83,13 @@ export default {if (isDBAOrOwner(currentUser.value.role)) {store- .dispatch("instance/fetchInstanceList", "ARCHIVED")+ .dispatch("instance/fetchInstanceList", ["ARCHIVED"]).catch((error) => {console.error(error);});store- .dispatch("environment/fetchEnvironmentList", "ARCHIVED")+ .dispatch("environment/fetchEnvironmentList", ["ARCHIVED"]).catch((error) => {console.error(error);});@@ -99,18 +99,17 @@ export default {watchEffect(prepareList);const projectList = computed((): Project[] => {- return store.getters["project/projectListByUser"](- currentUser.value.id,- "ARCHIVED"- );+ return store.getters["project/projectListByUser"](currentUser.value.id, [+ "ARCHIVED",+ ]);});const instanceList = computed((): Instance[] => {- return store.getters["instance/instanceList"]("ARCHIVED");+ return store.getters["instance/instanceList"](["ARCHIVED"]);});const environmentList = computed(() => {- return store.getters["environment/environmentList"]("ARCHIVED");+ return store.getters["environment/environmentList"](["ARCHIVED"]);});const tabList = computed((): string[] => {diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vueindex 6bde7df9e0..aac8fed65e 100644--- a/frontend/src/views/EnvironmentDashboard.vue+++ b/frontend/src/views/EnvironmentDashboard.vue@@ -160,7 +160,7 @@ export default {);const environmentList = computed(() => {- return store.getters["environment/environmentList"]("NORMAL");+ return store.getters["environment/environmentList"]();});const tabItemList = computed((): BBTabItem[] => {diff --git a/frontend/src/views/InstanceDashboard.vue b/frontend/src/views/InstanceDashboard.vueindex d37f3f3372..877a9d5f83 100644--- a/frontend/src/views/InstanceDashboard.vue+++ b/frontend/src/views/InstanceDashboard.vue@@ -111,7 +111,7 @@ export default {};const instanceList = computed(() => {- return store.getters["instance/instanceList"]("NORMAL");+ return store.getters["instance/instanceList"]();});const filteredList = (list: Instance[]) => {diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vueindex 90db404b4b..1bb6d7890e 100644--- a/frontend/src/views/TaskDetail.vue+++ b/frontend/src/views/TaskDetail.vue@@ -293,7 +293,7 @@ export default {const currentUser = computed(() => store.getters["auth/currentUser"]());const environmentList = computed(() => {- return store.getters["environment/environmentList"]("NORMAL");+ return store.getters["environment/environmentList"]();});const isNew = computed(() => {