fix: sh-admin dashboard bugs and UI polish (#56)
This commit is contained in:
@@ -1,31 +1,32 @@
|
||||
<template>
|
||||
<header
|
||||
class="flex items-center justify-between border-b border-gray-600 px-6 py-4 bg-neutral-900 shadow-lg"
|
||||
class="flex items-center justify-between border-b border-divider px-6 py-4 bg-primary shadow-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<button
|
||||
<HoppButtonSecondary
|
||||
v-tippy="{ theme: 'tooltip' }"
|
||||
title="Open navigation"
|
||||
:icon="IconMenu"
|
||||
class="transform !md:hidden mr-2"
|
||||
@click="isOpen = true"
|
||||
class="text-gray-200 focus:outline-none md:hidden mr-2"
|
||||
>
|
||||
<icon-lucide-menu class="text-gray-300 w-6" />
|
||||
</button>
|
||||
|
||||
<div class="mr-3 mt-2 xs:hidden md:block">
|
||||
<button @click="expandSidebar">
|
||||
<icon-lucide-sidebar-open
|
||||
v-if="isExpanded"
|
||||
class="text-gray-300 w-6"
|
||||
/>
|
||||
<icon-lucide-sidebar-close v-else class="text-gray-300 w-6" />
|
||||
</button>
|
||||
</div>
|
||||
/>
|
||||
<HoppButtonSecondary
|
||||
v-tippy="{ theme: 'tooltip' }"
|
||||
:title="isExpanded ? 'Collapse sidebar' : 'Expand sidebar'"
|
||||
:icon="isExpanded ? IconSidebarClose : IconSidebarOpen"
|
||||
class="transform"
|
||||
@click="expandSidebar"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center">
|
||||
<div v-if="currentUser" class="relative">
|
||||
<button
|
||||
@click="dropdownOpen = !dropdownOpen"
|
||||
class="relative z-10 block w-8 h-8 overflow-hidden rounded-full shadow focus:outline-none"
|
||||
<tippy
|
||||
interactive
|
||||
trigger="click"
|
||||
theme="popover"
|
||||
arrow
|
||||
:on-shown="() => tippyActions!.focus()"
|
||||
>
|
||||
<ProfilePicture
|
||||
v-if="currentUser.photoURL"
|
||||
@@ -42,29 +43,19 @@
|
||||
:title="currentUser.displayName ?? currentUser.email ?? 'No Name'"
|
||||
:initial="currentUser.displayName ?? currentUser.email"
|
||||
/>
|
||||
</button>
|
||||
|
||||
<div
|
||||
v-show="dropdownOpen"
|
||||
@click="dropdownOpen = false"
|
||||
class="fixed inset-0 z-10 w-full h-full"
|
||||
></div>
|
||||
|
||||
<transition
|
||||
enter-active-class="transition duration-150 ease-out transform"
|
||||
enter-from-class="scale-95 opacity-0"
|
||||
enter-to-class="scale-100 opacity-100"
|
||||
leave-active-class="transition duration-150 ease-in transform"
|
||||
leave-from-class="scale-100 opacity-100"
|
||||
leave-to-class="scale-95 opacity-0"
|
||||
>
|
||||
<div
|
||||
v-show="dropdownOpen"
|
||||
class="absolute right-0 z-20 w-48 py-2 mt-2 bg-zinc-800 rounded-md shadow-xl"
|
||||
>
|
||||
<AppLogout ref="logout" />
|
||||
</div>
|
||||
</transition>
|
||||
<template #content="{ hide }">
|
||||
<div
|
||||
ref="tippyActions"
|
||||
class="flex flex-col focus:outline-none"
|
||||
tabindex="0"
|
||||
@keyup.escape="hide()"
|
||||
>
|
||||
<div>
|
||||
<AppLogout ref="logout" @click="hide()" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</tippy>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@@ -72,9 +63,13 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { TippyComponent } from 'vue-tippy';
|
||||
import { useReadonlyStream } from '~/composables/stream';
|
||||
import { useSidebar } from '~/composables/useSidebar';
|
||||
import { auth } from '~/helpers/auth';
|
||||
import IconMenu from '~icons/lucide/menu';
|
||||
import IconSidebarOpen from '~icons/lucide/sidebar-open';
|
||||
import IconSidebarClose from '~icons/lucide/sidebar-close';
|
||||
|
||||
const { isOpen, isExpanded } = useSidebar();
|
||||
|
||||
@@ -87,5 +82,6 @@ const expandSidebar = () => {
|
||||
isExpanded.value = !isExpanded.value;
|
||||
};
|
||||
|
||||
const dropdownOpen = ref(false);
|
||||
// Template refs
|
||||
const tippyActions = ref<TippyComponent | null>(null);
|
||||
</script>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div
|
||||
:class="isOpen ? 'block' : 'hidden'"
|
||||
@click="isOpen = false"
|
||||
class="fixed inset-0 z-20 transition-opacity bg-black opacity-50 lg:hidden"
|
||||
class="fixed inset-0 z-20 transition-opacity bg-primary opacity-50 lg:hidden"
|
||||
></div>
|
||||
<!-- End Backdrop -->
|
||||
|
||||
@@ -12,60 +12,45 @@
|
||||
:class="isOpen ? '' : '!-translate-x-full ease-in'"
|
||||
class="sidebar-container transform !md:translate-x-0 ease-out"
|
||||
>
|
||||
<div :class="isExpanded ? 'w-64' : 'w-full'">
|
||||
<div class="flex items-center justify-start mt-6 ml-6">
|
||||
<div :class="isExpanded ? 'w-xs' : 'w-full'">
|
||||
<div class="flex items-center justify-start px-4 my-4">
|
||||
<div class="flex items-center">
|
||||
<HoppSmartLink class="flex items-center space-x-4" to="/dashboard">
|
||||
<img src="/cover.jpg" alt="hoppscotch-logo" class="h-7" />
|
||||
|
||||
<span
|
||||
v-if="isExpanded"
|
||||
class="mx-2 text-xl font-semibold text-gray-200"
|
||||
>Hoppscotch</span
|
||||
<span v-if="isExpanded" class="font-semibold text-accentContrast"
|
||||
>HOPPSCOTCH</span
|
||||
>
|
||||
</HoppSmartLink>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="mt-10">
|
||||
<router-link
|
||||
class="flex items-center px-6 py-4 duration-200 border-l-4"
|
||||
:class="[route.name === '/dashboard' ? activeClass : inactiveClass]"
|
||||
to="/dashboard"
|
||||
<nav class="my-5">
|
||||
<HoppSmartLink
|
||||
v-for="(navigation, index) in primaryNavigations"
|
||||
:key="`navigation-${index}`"
|
||||
v-tippy="{
|
||||
theme: 'tooltip',
|
||||
placement: 'right',
|
||||
content: !isExpanded ? navigation.label : null,
|
||||
}"
|
||||
:to="navigation.to"
|
||||
tabindex="0"
|
||||
:exact="navigation.exact"
|
||||
class="nav-link"
|
||||
:class="
|
||||
!isExpanded
|
||||
? 'flex items-center justify-center'
|
||||
: 'flex items-center'
|
||||
"
|
||||
>
|
||||
<icon-lucide-layout-dashboard
|
||||
class="text-xl"
|
||||
:class="route.name === '/dashboard' ? 'white' : 'gray'"
|
||||
/>
|
||||
|
||||
<span v-if="isExpanded" class="mx-4 font-semibold">Dashboard</span>
|
||||
</router-link>
|
||||
|
||||
<router-link
|
||||
class="flex items-center px-6 py-4 duration-200 border-l-4 rounded-sm"
|
||||
:class="[route.name === 'User' ? activeClass : inactiveClass]"
|
||||
to="/users"
|
||||
>
|
||||
<icon-lucide-user
|
||||
class="text-xl"
|
||||
:class="route.path === '/users' ? 'white' : 'gray'"
|
||||
/>
|
||||
|
||||
<span v-if="isExpanded" class="mx-4 font-semibold">Users</span>
|
||||
</router-link>
|
||||
|
||||
<router-link
|
||||
class="flex items-center px-6 py-4 duration-200 border-l-4 rounded-sm"
|
||||
:class="[route.name === '/teams' ? activeClass : inactiveClass]"
|
||||
to="/teams"
|
||||
>
|
||||
<icon-lucide-users
|
||||
class="text-xl"
|
||||
:class="route.name === '/teams' ? 'white' : 'gray'"
|
||||
/>
|
||||
|
||||
<span v-if="isExpanded" class="mx-4 font-semibold">Teams</span>
|
||||
</router-link>
|
||||
<div v-if="navigation.icon">
|
||||
<component :is="navigation.icon" class="svg-icons" />
|
||||
</div>
|
||||
<span v-if="isExpanded" class="nav-title">
|
||||
{{ navigation.label }}
|
||||
</span>
|
||||
</HoppSmartLink>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
@@ -75,23 +60,88 @@
|
||||
<script setup lang="ts">
|
||||
import { HoppSmartLink } from '@hoppscotch/ui';
|
||||
import { useSidebar } from '../../composables/useSidebar';
|
||||
import { useRoute } from 'vue-router';
|
||||
import IconDashboard from '~icons/lucide/layout-dashboard';
|
||||
import IconUser from '~icons/lucide/user';
|
||||
import IconUsers from '~icons/lucide/users';
|
||||
|
||||
const { isOpen, isExpanded } = useSidebar();
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
const activeClass =
|
||||
'bg-gray-600 bg-opacity-25 text-gray-100 border-gray-100 border-emerald-600';
|
||||
const inactiveClass =
|
||||
'border-gray-900 text-gray-500 hover:bg-gray-600 hover:bg-opacity-25 hover:text-gray-100';
|
||||
const primaryNavigations = [
|
||||
{
|
||||
label: 'Dashboard',
|
||||
icon: IconDashboard,
|
||||
to: '/dashboard',
|
||||
exact: true,
|
||||
},
|
||||
{
|
||||
label: 'Users',
|
||||
icon: IconUser,
|
||||
to: '/users',
|
||||
exact: false,
|
||||
},
|
||||
{
|
||||
label: 'Teams',
|
||||
icon: IconUsers,
|
||||
to: '/teams',
|
||||
exact: false,
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
<style scoped lang="scss">
|
||||
.sidebar-container {
|
||||
@apply fixed md:static md:translate-x-0 md:inset-0 inset-y-0 left-0 z-30;
|
||||
@apply transition duration-300;
|
||||
@apply flex overflow-y-auto bg-primary border-r border-divider;
|
||||
}
|
||||
|
||||
@apply flex overflow-y-auto bg-neutral-900 border-r border-gray-600;
|
||||
.nav-link {
|
||||
@apply relative;
|
||||
@apply p-4;
|
||||
@apply flex flex-1;
|
||||
@apply items-center;
|
||||
@apply space-x-4;
|
||||
@apply hover: (bg-primaryDark text-secondaryDark);
|
||||
@apply focus-visible: text-secondaryDark;
|
||||
@apply after:absolute;
|
||||
@apply after:inset-x-0;
|
||||
@apply after:md: inset-x-auto;
|
||||
@apply after:md: inset-y-0;
|
||||
@apply after:bottom-0;
|
||||
@apply after:md: bottom-auto;
|
||||
@apply after:md: left-0;
|
||||
@apply after:z-2;
|
||||
@apply after:h-0.5;
|
||||
@apply after:md: h-full;
|
||||
@apply after:w-full;
|
||||
@apply after:md: w-0.5;
|
||||
@apply after:content-DEFAULT;
|
||||
@apply focus: after: bg-divider;
|
||||
|
||||
.svg-icons {
|
||||
@apply opacity-75;
|
||||
}
|
||||
|
||||
&.router-link-active {
|
||||
@apply text-secondaryDark;
|
||||
@apply bg-primaryLight;
|
||||
@apply hover: text-secondaryDark;
|
||||
@apply after:bg-accent;
|
||||
|
||||
.svg-icons {
|
||||
@apply opacity-100;
|
||||
}
|
||||
}
|
||||
|
||||
&.exact-active-link {
|
||||
@apply text-secondaryDark;
|
||||
@apply bg-primaryLight;
|
||||
@apply hover: text-secondaryDark;
|
||||
@apply after:bg-accent;
|
||||
|
||||
.svg-icons {
|
||||
@apply opacity-100;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<div
|
||||
class="flex items-center sm:px-15 px-8 justify-center !sm:justify-start py-6 bg-primaryLight rounded-md shadow-sm h-50 space-x-6"
|
||||
>
|
||||
<component :is="icon" class="text-5xl" :class="color" />
|
||||
|
||||
<div class="space-y-2">
|
||||
<h4 class="text-4xl font-semibold text-accentContrast">
|
||||
{{ count }}
|
||||
</h4>
|
||||
<div class="text-gray-400 font-bold">
|
||||
{{ label }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { Component } from 'vue';
|
||||
|
||||
defineProps<{
|
||||
count: number;
|
||||
label: string;
|
||||
icon: Component;
|
||||
color: string;
|
||||
}>();
|
||||
</script>
|
||||
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<HoppSmartModal
|
||||
v-if="show"
|
||||
dialog
|
||||
title="Invite User"
|
||||
@close="$emit('hide-modal')"
|
||||
>
|
||||
<template #body>
|
||||
<div class="flex flex-col">
|
||||
<input
|
||||
id="inviteUserEmail"
|
||||
v-model="email"
|
||||
v-focus
|
||||
class="input floating-input"
|
||||
placeholder=" "
|
||||
type="text"
|
||||
autocomplete="off"
|
||||
@keyup.enter="sendInvite"
|
||||
/>
|
||||
<label for="inviteUserEmail">Email Address</label>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<span class="flex space-x-2">
|
||||
<HoppButtonPrimary
|
||||
label="Send Invite"
|
||||
:loading="loadingState"
|
||||
@click="sendInvite"
|
||||
/>
|
||||
<HoppButtonSecondary label="Cancel" outline filled @click="hideModal" />
|
||||
</span>
|
||||
</template>
|
||||
</HoppSmartModal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useToast } from '~/composables/toast';
|
||||
|
||||
const toast = useToast();
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
show: boolean;
|
||||
loadingState: boolean;
|
||||
}>(),
|
||||
{
|
||||
show: false,
|
||||
loadingState: false,
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'hide-modal'): void;
|
||||
(event: 'send-invite', email: string): void;
|
||||
}>();
|
||||
|
||||
const email = ref('');
|
||||
|
||||
const sendInvite = () => {
|
||||
if (email.value.trim() === '') {
|
||||
toast.error('Please enter a valid email address');
|
||||
return;
|
||||
}
|
||||
emit('send-invite', email.value);
|
||||
};
|
||||
|
||||
const hideModal = () => {
|
||||
emit('hide-modal');
|
||||
};
|
||||
</script>
|
||||
170
packages/hoppscotch-sh-admin/src/components/users/Table.vue
Normal file
170
packages/hoppscotch-sh-admin/src/components/users/Table.vue
Normal file
@@ -0,0 +1,170 @@
|
||||
<template>
|
||||
<table class="w-full">
|
||||
<thead>
|
||||
<tr class="text-secondary border-b border-dividerDark text-sm text-left">
|
||||
<th class="px-3 pb-3">User ID</th>
|
||||
<th class="px-3 pb-3">Name</th>
|
||||
<th class="px-3 pb-3">Email</th>
|
||||
<th class="px-3 pb-3">Date</th>
|
||||
<th class="px-3 pb-3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="divide-y divide-divider">
|
||||
<tr
|
||||
v-for="user in usersList"
|
||||
:key="user.uid"
|
||||
class="text-secondaryDark hover:bg-divider hover:cursor-pointer rounded-xl"
|
||||
>
|
||||
<td
|
||||
@click="$emit('goToUserDetails', user.uid)"
|
||||
class="py-2 px-3 max-w-30"
|
||||
>
|
||||
<div class="flex">
|
||||
<span class="truncate">
|
||||
{{ user.uid }}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td @click="$emit('goToUserDetails', user.uid)" class="py-2 px-3">
|
||||
<div v-if="user.displayName" class="flex items-center space-x-3">
|
||||
<span>
|
||||
{{ user.displayName }}
|
||||
</span>
|
||||
<span
|
||||
v-if="user.isAdmin"
|
||||
class="text-xs font-medium px-3 py-0.5 rounded-full bg-green-900 text-green-300"
|
||||
>
|
||||
Admin
|
||||
</span>
|
||||
</div>
|
||||
<div v-else class="flex items-center space-x-3">
|
||||
<span> (Unnamed user) </span>
|
||||
<span
|
||||
v-if="user.isAdmin"
|
||||
class="text-xs font-medium px-3 py-0.5 rounded-full bg-green-900 text-green-300"
|
||||
>
|
||||
Admin
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td @click="$emit('goToUserDetails', user.uid)" class="py-2 px-3">
|
||||
<span>
|
||||
{{ user.email }}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td @click="$emit('goToUserDetails', user.uid)" class="py-2 px-3">
|
||||
<div class="flex items-center">
|
||||
<div class="flex flex-col">
|
||||
{{ getCreatedDate(user.createdOn) }}
|
||||
<div class="text-gray-400 text-tiny">
|
||||
{{ getCreatedTime(user.createdOn) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<div class="relative">
|
||||
<span>
|
||||
<tippy
|
||||
interactive
|
||||
trigger="click"
|
||||
theme="popover"
|
||||
:on-shown="() => tippyActions!.focus()"
|
||||
>
|
||||
<HoppButtonSecondary
|
||||
v-tippy="{ theme: 'tooltip' }"
|
||||
:icon="IconMoreHorizontal"
|
||||
/>
|
||||
<template #content="{ hide }">
|
||||
<div
|
||||
ref="tippyActions"
|
||||
class="flex flex-col focus:outline-none"
|
||||
tabindex="0"
|
||||
@keyup.escape="hide()"
|
||||
>
|
||||
<HoppSmartItem
|
||||
v-if="!user.isAdmin"
|
||||
:icon="IconUserCheck"
|
||||
:label="'Make Admin'"
|
||||
class="!hover:bg-emerald-600"
|
||||
@click="
|
||||
() => {
|
||||
$emit('makeUserAdmin', user.uid);
|
||||
hide();
|
||||
}
|
||||
"
|
||||
/>
|
||||
<HoppSmartItem
|
||||
v-else
|
||||
:icon="IconUserMinus"
|
||||
:label="'Remove Admin Status'"
|
||||
class="!hover:bg-emerald-600"
|
||||
@click="
|
||||
() => {
|
||||
$emit('makeAdminToUser', user.uid);
|
||||
hide();
|
||||
}
|
||||
"
|
||||
/>
|
||||
<HoppSmartItem
|
||||
v-if="!user.isAdmin"
|
||||
:icon="IconTrash"
|
||||
:label="'Delete User'"
|
||||
class="!hover:bg-red-600"
|
||||
@click="
|
||||
() => {
|
||||
$emit('deleteUser', user.uid);
|
||||
hide();
|
||||
}
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</tippy>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { format } from 'date-fns';
|
||||
import { ref } from 'vue';
|
||||
import IconTrash from '~icons/lucide/trash';
|
||||
import IconUserMinus from '~icons/lucide/user-minus';
|
||||
import IconUserCheck from '~icons/lucide/user-check';
|
||||
import IconMoreHorizontal from '~icons/lucide/more-horizontal';
|
||||
import { UsersListQuery } from '~/helpers/backend/graphql';
|
||||
import { TippyComponent } from 'vue-tippy';
|
||||
|
||||
defineProps<{
|
||||
usersList: UsersListQuery['admin']['allUsers'];
|
||||
}>();
|
||||
|
||||
defineEmits<{
|
||||
(event: 'goToUserDetails', uid: string): void;
|
||||
(event: 'makeUserAdmin', uid: string): void;
|
||||
(event: 'makeAdminToUser', uid: string): void;
|
||||
(event: 'deleteUser', uid: string): void;
|
||||
}>();
|
||||
|
||||
// Get Proper Date Formats
|
||||
const getCreatedDate = (date: string) => format(new Date(date), 'dd-MM-yyyy');
|
||||
const getCreatedTime = (date: string) => format(new Date(date), 'hh:mm a');
|
||||
|
||||
// Template refs
|
||||
const tippyActions = ref<TippyComponent | null>(null);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.tippy-box[data-theme~='popover'] .tippy-content {
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user