Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Add EnvironmentSelect component
Tianzhou Chenc2b71d339770
diff --git a/frontend/src/components/EnvironmentSelect.vue b/frontend/src/components/EnvironmentSelect.vuenew file mode 100644index 0000000000..7535eee1aa--- /dev/null+++ b/frontend/src/components/EnvironmentSelect.vue@@ -0,0 +1,70 @@+<template>+ <select+ class="block w-full focus:ring-accent focus:border-accent border-gray-300 rounded-md"+ @change="+ (e) => {+ $emit('select-environment-id', e.target.value);+ }+ "+ >+ <option+ v-for="(environment, index) in state.environmentList"+ :key="index"+ :value="environment.id"+ :selected="environment.id == state.selectedId"+ >+ {{ environment.attributes.name }}+ </option>+ </select>+</template>++<script lang="ts">+import { watchEffect, reactive } from "vue";+import { useStore } from "vuex";+import { Environment } from "../types";++interface LocalState {+ environmentList: Environment[];+ selectedId?: string;+}++export default {+ name: "EnvironmentSelect",+ emits: ["select-environment-id"],+ components: {},+ props: {+ selectedId: {+ type: String,+ },+ },+ setup(props, ctx) {+ const state = reactive<LocalState>({+ environmentList: [],+ selectedId: props.selectedId,+ });+ const store = useStore();++ const prepareEnvironmentList = () => {+ store+ .dispatch("environment/fetchEnvironmentList")+ .then((list: Environment[]) => {+ // Usually env is ordered by ascending importantance, thus we rervese the order to put+ // more important ones first.+ state.environmentList = list.reverse();+ if (!state.selectedId && state.environmentList.length > 0) {+ state.selectedId = state.environmentList[0].id;+ }+ })+ .catch((error) => {+ console.log(error);+ });+ };++ watchEffect(prepareEnvironmentList);++ return {+ state,+ };+ },+};+</script>