From cdbc580adab553bc8fc44e55b4d2d4302f4839a0 Mon Sep 17 00:00:00 2001 From: Joel Jacob Stephen <70131076+JoelJacobStephen@users.noreply.github.com> Date: Thu, 22 Jun 2023 09:37:51 +0300 Subject: [PATCH] feat: introducing smart table to hopp ui --- .../hoppscotch-sh-admin/src/components.d.ts | 3 +- .../src/components/teams/Table.vue | 2 +- .../src/components/users/Table.vue | 247 +++++++++--------- .../src/components/users/Tables.vue | 117 +++++++++ .../src/pages/teams/index.vue | 69 ++++- .../src/pages/users/index.vue | 108 +++++++- .../src/components/smart/Table.vue | 108 ++++++++ .../src/components/smart/index.ts | 1 + 8 files changed, 506 insertions(+), 149 deletions(-) create mode 100644 packages/hoppscotch-sh-admin/src/components/users/Tables.vue create mode 100644 packages/hoppscotch-ui/src/components/smart/Table.vue diff --git a/packages/hoppscotch-sh-admin/src/components.d.ts b/packages/hoppscotch-sh-admin/src/components.d.ts index 0ad19898b..cdd81e0f8 100644 --- a/packages/hoppscotch-sh-admin/src/components.d.ts +++ b/packages/hoppscotch-sh-admin/src/components.d.ts @@ -19,12 +19,12 @@ declare module '@vue/runtime-core' { HoppSmartAnchor: typeof import('@hoppscotch/ui')['HoppSmartAnchor']; HoppSmartAutoComplete: typeof import('@hoppscotch/ui')['HoppSmartAutoComplete']; HoppSmartConfirmModal: typeof import('@hoppscotch/ui')['HoppSmartConfirmModal']; - HoppSmartInput: typeof import('@hoppscotch/ui')['HoppSmartInput']; HoppSmartItem: typeof import('@hoppscotch/ui')['HoppSmartItem']; HoppSmartModal: typeof import('@hoppscotch/ui')['HoppSmartModal']; HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture']; HoppSmartSpinner: typeof import('@hoppscotch/ui')['HoppSmartSpinner']; HoppSmartTab: typeof import('@hoppscotch/ui')['HoppSmartTab']; + HoppSmartTable: typeof import('@hoppscotch/ui')['HoppSmartTable']; IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default']; IconLucideChevronDown: typeof import('~icons/lucide/chevron-down')['default']; IconLucideHelpCircle: typeof import('~icons/lucide/help-circle')['default']; @@ -39,5 +39,6 @@ declare module '@vue/runtime-core' { Tippy: typeof import('vue-tippy')['Tippy']; UsersInviteModal: typeof import('./components/users/InviteModal.vue')['default']; UsersTable: typeof import('./components/users/Table.vue')['default']; + UsersTables: typeof import('./components/users/Tables.vue')['default']; } } diff --git a/packages/hoppscotch-sh-admin/src/components/teams/Table.vue b/packages/hoppscotch-sh-admin/src/components/teams/Table.vue index 421c79137..ba86c71eb 100644 --- a/packages/hoppscotch-sh-admin/src/components/teams/Table.vue +++ b/packages/hoppscotch-sh-admin/src/components/teams/Table.vue @@ -63,7 +63,7 @@ - - - {{ t('users.id') }} - {{ t('users.name') }} - {{ t('users.email') }} - {{ t('users.date') }} - - - - - - - + + + -
- - {{ user.uid }} - -
- + + + + + + + - + + + + + + + - - - + - - - -
{{ t('users.id') }}{{ t('users.name') }}{{ t('users.email') }}{{ t('users.date') }}
-
+
+
+ + {{ user.uid }} + +
+
+
+ + {{ user.displayName }} + + + {{ t('users.admin') }} + +
+
+ {{ t('users.unnamed') }} + + {{ t('users.admin') }} + +
+
- {{ user.displayName }} + {{ user.email }} - - {{ t('users.admin') }} - - -
- {{ t('users.unnamed') }} - - {{ t('users.admin') }} - -
-
- - {{ user.email }} - - -
-
- {{ getCreatedDate(user.createdOn) }} -
- {{ getCreatedTime(user.createdOn) }} +
+
+
+ {{ getCreatedDate(user.createdOn) }} +
+ {{ getCreatedTime(user.createdOn) }} +
- -
-
- - - - - - -
-
+ +
+ + + + + + +
+ + + + + + + diff --git a/packages/hoppscotch-sh-admin/src/pages/teams/index.vue b/packages/hoppscotch-sh-admin/src/pages/teams/index.vue index 42bdb9cf5..b5f6e9ab1 100644 --- a/packages/hoppscotch-sh-admin/src/pages/teams/index.vue +++ b/packages/hoppscotch-sh-admin/src/pages/teams/index.vue @@ -21,13 +21,42 @@
{{ t('teams.load_list_error') }}
- + :list="teamList" + :headings="headings" + @goToDetails="goToTeamDetails" + padding="px-6 py-3" + item-style="!hover:bg-red-600" + > + +
{ + return list.value.map((team) => { + return { + id: team.id || '', + name: team.name || '', + members: team.members.length, + }; + }); +}); + +const headings = ['Team ID', 'Team Name', 'Number of Members']; + // Create Team const createTeamMutation = useMutation(CreateTeamDocument); const showCreateTeamModal = ref(false); @@ -143,9 +186,7 @@ const createTeam = async (newTeamName: string, ownerEmail: string) => { // Go To Individual Team Details Page const router = useRouter(); -const goToTeamDetails = (teamId: string) => { - router.push('/teams/' + teamId); -}; +const goToTeamDetails = (team: any) => router.push('/teams/' + team.id); // Reload Teams Page when routed back to the teams page const route = useRoute(); @@ -159,9 +200,9 @@ const teamDeletion = useMutation(RemoveTeamDocument); const confirmDeletion = ref(false); const deleteTeamID = ref(null); -const deleteTeam = (id: string) => { +const deleteTeam = (team: any) => { confirmDeletion.value = true; - deleteTeamID.value = id; + deleteTeamID.value = team.id; }; const deleteTeamMutation = async (id: string | null) => { @@ -175,7 +216,7 @@ const deleteTeamMutation = async (id: string | null) => { if (result.error) { toast.error(`${t('state.delete_team_failure')}`); } else { - teamList.value = teamList.value.filter((team) => team.id !== id); + list.value = list.value.filter((team) => team.id !== id); toast.success(`${t('state.delete_team_success')}`); } }); diff --git a/packages/hoppscotch-sh-admin/src/pages/users/index.vue b/packages/hoppscotch-sh-admin/src/pages/users/index.vue index 8355fdd3c..f22c52c5e 100644 --- a/packages/hoppscotch-sh-admin/src/pages/users/index.vue +++ b/packages/hoppscotch-sh-admin/src/pages/users/index.vue @@ -31,7 +31,7 @@
{{ t('users.load_list_error') }}
- + /> --> + + + +
{{ t('users.no_users') }}
@@ -82,7 +140,8 @@ + + diff --git a/packages/hoppscotch-ui/src/components/smart/index.ts b/packages/hoppscotch-ui/src/components/smart/index.ts index 157124566..81d04c985 100644 --- a/packages/hoppscotch-ui/src/components/smart/index.ts +++ b/packages/hoppscotch-ui/src/components/smart/index.ts @@ -16,6 +16,7 @@ export { default as HoppSmartSlideOver } from "./SlideOver.vue" export { default as HoppSmartSpinner } from "./Spinner.vue" export { default as HoppSmartTab } from "./Tab.vue" export { default as HoppSmartTabs } from "./Tabs.vue" +export { default as HoppSmartTable } from "./Table.vue" export { default as HoppSmartToggle } from "./Toggle.vue" export { default as HoppSmartWindow } from "./Window.vue" export { default as HoppSmartWindows } from "./Windows.vue"