Skip to content

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

Adjust Member Layout

Tianzhou Chen5a5872e29d6c
diff --git a/frontend/src/assets/css/tailwind.css b/frontend/src/assets/css/tailwind.css
index c4fe3c1ba4..1b012ce15e 100644
--- a/frontend/src/assets/css/tailwind.css
+++ b/frontend/src/assets/css/tailwind.css
@@ -62,6 +62,10 @@
@apply select-none inline-flex border border-control-border rounded-md text-control bg-white hover:bg-control-bg-hover disabled:bg-control-bg disabled:opacity-50 disabled:cursor-not-allowed px-4 py-2 text-sm leading-5 font-medium focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-2;
}
+.btn-secondary {
+ @apply select-none inline-flex text-main hover:text-control-hover disabled:opacity-50 disabled:cursor-not-allowed text-sm leading-5 font-normal focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-2;
+}
+
.btn-select {
@apply text-sm select-none text-main bg-white border border-control-border disabled:bg-control-bg disabled:opacity-50 disabled:cursor-not-allowed rounded-md shadow-sm text-left cursor-default focus:outline-none focus:ring-1 focus:ring-control focus:border-control;
}
@@ -103,7 +107,7 @@
}
.radio-set {
- @apply h-9 flex flex-row items-center space-x-2;
+ @apply h-9 items-center space-x-2;
}
.radio {
diff --git a/frontend/src/bbkit/BBSelect.vue b/frontend/src/bbkit/BBSelect.vue
index 7cb03f4fbb..928a7fa476 100644
--- a/frontend/src/bbkit/BBSelect.vue
+++ b/frontend/src/bbkit/BBSelect.vue
@@ -1,6 +1,6 @@
<template>
<div
- class="relative"
+ class="relative flex flex-shrink-0"
v-click-inside-outside="
(_, inside) => {
if (!inside) {
diff --git a/frontend/src/components/MemberInvite.vue b/frontend/src/components/MemberInvite.vue
index efdc7a78cd..b48452a723 100644
--- a/frontend/src/components/MemberInvite.vue
+++ b/frontend/src/components/MemberInvite.vue
@@ -1,270 +1,181 @@
<template>
- <div class="w-full space-y-6">
+ <div class="w-full space-y-4">
<div class="space-y-2">
- <div class="space-y-1">
- <p id="invite_members_helper" class="sr-only">Add by email address</p>
- <div
- class="flex flex-col space-y-2 sm:flex-row sm:space-x-4 sm:space-y-0"
- >
+ <div
+ v-for="(invite, index) in state.inviteList"
+ :key="index"
+ class="py-0.5 select-none"
+ >
+ <p id="invite_members_helper" class="sr-only">
+ Invite by email address
+ </p>
+ <div class="flex flex-row space-x-4">
<div class="flex-grow">
<input
type="email"
name="invite_members"
- id="invite_members"
+ autocomplete="off"
class="textfield w-full lowercase"
placeholder="[email protected]"
- v-model="state.inviteEmail"
- ref="inviteEmailTextField"
+ v-model="invite.email"
aria-describedby="invite_members_helper"
/>
</div>
- <fieldset>
- <div class="radio-set">
- <div class="radio">
- <input
- name="invite_role"
- type="radio"
- class="btn"
- value="OWNER"
- v-model="state.inviteRole"
- />
- <label class="label"> Owner </label>
- </div>
- <div class="radio">
- <input
- name="invite_role"
- type="radio"
- class="btn"
- value="DBA"
- v-model="state.inviteRole"
- />
- <label class="label"> DBA </label>
- </div>
- <div class="radio">
- <input
- name="invite_role"
- type="radio"
- class="btn"
- value="DEVELOPER"
- v-model="state.inviteRole"
- />
- <label class="label"> Developer </label>
- </div>
+ <div class="sm:hidden w-36">
+ <RoleSelect
+ :selectedRole="invite.role"
+ @change-role="
+ (role) => {
+ invite.role = role;
+ }
+ "
+ />
+ </div>
+ <div class="hidden sm:flex sm:flex-row radio-set">
+ <div class="radio">
+ <input
+ :name="`invite_role${index}`"
+ tabindex="-1"
+ type="radio"
+ class="btn"
+ value="OWNER"
+ v-model="invite.role"
+ />
+ <label class="label"> Owner </label>
</div>
- </fieldset>
-
- <span class="flex justify-end">
- <button
- type="button"
- class="btn-normal"
- :disabled="!isValidEmail(state.inviteEmail)"
- @click.prevent="addInvite"
- >
- <!-- Heroicon name: solid/plus -->
- <svg
- class="-ml-2 mr-1 h-5 w-5 text-gray-400"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 20 20"
- fill="currentColor"
- aria-hidden="true"
- >
- <path
- fill-rule="evenodd"
- d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z"
- clip-rule="evenodd"
- />
- </svg>
- <span>Add</span>
- </button>
- </span>
- </div>
- </div>
-
- <div class="border-b border-gray-200 py-1 select-none">
- <ul class="divide-y divide-gray-200">
- <li
- v-for="(invite, index) in state.inviteList"
- :key="index"
- class="py-4 flex"
- >
- <div
- class="w-full flex flex-col space-y-2 sm:flex-row sm:justify-between sm:space-y-0"
- >
- <div class="flex items-center justify-between">
- <div class="flex items-center space-x-2">
- <BBAvatar :username="invite.email" />
- <span class="text-sm text-gray-500">{{ invite.email }}</span>
- </div>
-
- <button
- class="btn-icon"
- type="button"
- @click.prevent="deleteInvite(invite)"
- >
- <svg
- class="btn-icon sm:hidden w-4 h-4"
- fill="currentColor"
- viewBox="0 0 20 20"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- fill-rule="evenodd"
- d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
- clip-rule="evenodd"
- ></path>
- </svg>
- </button>
- </div>
-
- <div class="flex flex-row items-center space-x-2">
- <fieldset>
- <div class="radio-set">
- <div class="radio">
- <input
- type="radio"
- class="btn"
- value="OWNER"
- v-model="invite.role"
- />
- <label class="label"> Owner </label>
- </div>
- <div class="radio">
- <input
- type="radio"
- class="btn"
- value="DBA"
- v-model="invite.role"
- />
- <label class="label"> DBA </label>
- </div>
- <div class="radio">
- <input
- type="radio"
- class="btn"
- value="DEVELOPER"
- v-model="invite.role"
- />
- <label class="label"> Developer </label>
- </div>
- </div>
- </fieldset>
-
- <button
- class="btn-icon"
- type="button"
- @click.prevent="deleteInvite(invite)"
- >
- <svg
- class="btn-icon hidden sm:block w-4 h-4"
- fill="currentColor"
- viewBox="0 0 20 20"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- fill-rule="evenodd"
- d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
- clip-rule="evenodd"
- ></path>
- </svg>
- </button>
- </div>
+ <div class="radio">
+ <input
+ :name="`invite_role${index}`"
+ tabindex="-1"
+ type="radio"
+ class="btn"
+ value="DBA"
+ v-model="invite.role"
+ />
+ <label class="label"> DBA </label>
+ </div>
+ <div class="radio">
+ <input
+ :name="`invite_role${index}`"
+ tabindex="-1"
+ type="radio"
+ class="btn"
+ value="DEVELOPER"
+ v-model="invite.role"
+ />
+ <label class="label"> Developer </label>
</div>
- </li>
- </ul>
+ </div>
+ </div>
</div>
</div>
- <div class="flex justify-end">
+ <div class="flex justify-between">
+ <span class="flex items-center">
+ <button type="button" class="btn-secondary" @click.prevent="addInvite">
+ + Add More
+ </button>
+ </span>
+
<button
type="button"
class="btn-primary"
- :disabled="state.inviteList.length == 0"
+ :disabled="!hasValidInvite()"
@click.prevent="sendInvite"
>
- Invite
+ <svg
+ class="mr-2 h-5 w-5"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"
+ ></path>
+ </svg>
+ Send Invites
</button>
</div>
</div>
</template>
<script lang="ts">
-import { computed, onMounted, onUnmounted, reactive, ref, Ref } from "vue";
+import { computed, reactive } from "vue";
import { useStore } from "vuex";
-import cloneDeep from "lodash-es/cloneDeep";
-import { RoleType, RoleMappingNew } from "../types";
+import RoleSelect from "../components/RoleSelect.vue";
+import { RoleMappingNew } from "../types";
import { isValidEmail } from "../utils";
interface LocalState {
inviteList: RoleMappingNew[];
- inviteEmail: Ref<string>;
- inviteRole: Ref<RoleType>;
}
export default {
name: "MemberInvite",
+ components: { RoleSelect },
props: {},
setup(props, ctx) {
const store = useStore();
- const state = reactive<LocalState>({
- inviteList: [],
- inviteEmail: ref(""),
- inviteRole: ref("OWNER"),
- });
- const inviteEmailTextField = ref();
const currentUser = computed(() => store.getters["auth/currentUser"]());
- const keyboardHandler = (e: KeyboardEvent) => {
- if (e.code == "Enter") {
- if (inviteEmailTextField.value === document.activeElement) {
- addInvite();
- }
- }
- };
-
- onMounted(() => {
- document.addEventListener("keydown", keyboardHandler);
+ const state = reactive<LocalState>({
+ inviteList: [],
});
- onUnmounted(() => {
- document.removeEventListener("keydown", keyboardHandler);
- });
+ for (let i = 0; i < 3; i++) {
+ state.inviteList.push({
+ email: "",
+ role: "DEVELOPER",
+ updaterId: currentUser.value.id,
+ });
+ }
const addInvite = () => {
- if (isValidEmail(state.inviteEmail)) {
- state.inviteList.push(
- cloneDeep({
- email: state.inviteEmail,
- role: state.inviteRole,
- updaterId: currentUser.value.id,
- })
- );
- state.inviteEmail = "";
- }
+ state.inviteList.push({
+ email: "",
+ role: "DEVELOPER",
+ updaterId: currentUser.value.id,
+ });
};
- const deleteInvite = (invite: RoleMappingNew) => {
- const i = state.inviteList.indexOf(invite);
- if (i > -1) {
- state.inviteList.splice(i, 1);
+ const hasValidInvite = () => {
+ let hasValidEmail = false;
+ for (const invite of state.inviteList) {
+ if (invite.email) {
+ if (isValidEmail(invite.email)) {
+ hasValidEmail = true;
+ } else {
+ return false;
+ }
+ }
}
+ return hasValidEmail;
};
const sendInvite = () => {
- console.log(state.inviteList);
for (const invite of state.inviteList) {
- store.dispatch("roleMapping/createdRoleMapping", invite);
+ if (isValidEmail(invite.email)) {
+ store.dispatch("roleMapping/createdRoleMapping", invite);
+ }
}
state.inviteList = [];
+ state.inviteList.push({
+ email: "",
+ role: "DEVELOPER",
+ updaterId: currentUser.value.id,
+ });
};
return {
state,
- inviteEmailTextField,
addInvite,
- deleteInvite,
+ hasValidInvite,
sendInvite,
- isValidEmail,
};
},
};
diff --git a/frontend/src/components/MemberTable.vue b/frontend/src/components/MemberTable.vue
index 6e9e54f1fd..1635fe1220 100644
--- a/frontend/src/components/MemberTable.vue
+++ b/frontend/src/components/MemberTable.vue
@@ -8,12 +8,15 @@
<template v-slot:header>
<BBTableHeaderCell
:leftPadding="4"
- class="w-24 table-cell"
+ class="w-auto table-cell"
:title="columnList[0].title"
/>
<BBTableHeaderCell class="w-8 table-cell" :title="columnList[1].title" />
- <BBTableHeaderCell class="w-48 table-cell" :title="columnList[2].title" />
- <BBTableHeaderCell class="w-4 table-cell" :title="columnList[3].title" />
+ <BBTableHeaderCell class="w-72 table-cell" :title="columnList[2].title" />
+ <BBTableHeaderCell
+ class="w-auto table-cell"
+ :title="columnList[3].title"
+ />
</template>
<template v-slot:body="{ rowData: roleMapping }">
<BBTableCell :leftPadding="4" class="table-cell">
@@ -34,7 +37,7 @@
</span>
</div>
</BBTableCell>
- <BBTableCell class="w-8">
+ <BBTableCell class="">
<RoleSelect
:selectedRole="roleMapping.role"
@change-role="
@@ -44,24 +47,20 @@
"
/>
</BBTableCell>
- <BBTableCell class="w-48 table-cell">
- <div class="flex flex-row items-center">
- {{ humanizeTs(roleMapping.lastUpdatedTs) }}
- <span class="ml-1"
- >by
- <router-link
- :to="`/u/${roleMapping.principal.id}`"
- class="normal-link"
- >{{ roleMapping.principal.name }}
- </router-link></span
- >
+ <BBTableCell class="table-cell">
+ <div class="flex flex-row items-center space-x-1">
+ <span>
+ {{ humanizeTs(roleMapping.lastUpdatedTs) }}
+ </span>
+ <router-link
+ :to="`/u/${roleMapping.principal.id}`"
+ class="normal-link"
+ >by {{ roleMapping.principal.name }}
+ </router-link>
</div>
</BBTableCell>
<BBTableCell>
- <button
- class="w-4 btn-icon"
- @click.prevent="deleteRole(roleMapping.id)"
- >
+ <button class="btn-icon" @click.prevent="deleteRole(roleMapping.id)">
<svg
class="w-4 h-4"
fill="none"
diff --git a/frontend/src/store/modules/principal.ts b/frontend/src/store/modules/principal.ts
index 0abb165b21..7379a16790 100644
--- a/frontend/src/store/modules/principal.ts
+++ b/frontend/src/store/modules/principal.ts
@@ -27,6 +27,13 @@ const getters = {
principalById: (state: PrincipalState) => (
principalId: PrincipalId
): Principal => {
+ if (!principalId) {
+ return {
+ id: "-1",
+ name: "<<ID Missing>>",
+ email: "",
+ };
+ }
for (const principal of state.principalList) {
if (principal.id == principalId) {
return principal;
@@ -34,7 +41,7 @@ const getters = {
}
return {
id: principalId,
- name: "Unknown User " + principalId,
+ name: principalId,
email: "",
};
},