refactor: updated dashboard gql queries and components to use the new infra type of the updated schema (#3455)

This commit is contained in:
Joel Jacob Stephen
2023-11-01 23:40:19 +05:30
committed by GitHub
parent a215860782
commit 9dcbc4a126
19 changed files with 33 additions and 28 deletions

View File

@@ -23,9 +23,14 @@ declare module '@vue/runtime-core' {
HoppSmartItem: typeof import('@hoppscotch/ui')['HoppSmartItem']; HoppSmartItem: typeof import('@hoppscotch/ui')['HoppSmartItem'];
HoppSmartModal: typeof import('@hoppscotch/ui')['HoppSmartModal']; HoppSmartModal: typeof import('@hoppscotch/ui')['HoppSmartModal'];
HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture']; HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture'];
HoppSmartPlaceholder: typeof import('@hoppscotch/ui')['HoppSmartPlaceholder'];
HoppSmartSpinner: typeof import('@hoppscotch/ui')['HoppSmartSpinner']; HoppSmartSpinner: typeof import('@hoppscotch/ui')['HoppSmartSpinner'];
HoppSmartTab: typeof import('@hoppscotch/ui')['HoppSmartTab'];
IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default'];
IconLucideChevronDown: typeof import('~icons/lucide/chevron-down')['default']; IconLucideChevronDown: typeof import('~icons/lucide/chevron-down')['default'];
IconLucideHelpCircle: typeof import('~icons/lucide/help-circle')['default'];
IconLucideInbox: typeof import('~icons/lucide/inbox')['default']; IconLucideInbox: typeof import('~icons/lucide/inbox')['default'];
IconLucideUser: typeof import('~icons/lucide/user')['default'];
TeamsAdd: typeof import('./components/teams/Add.vue')['default']; TeamsAdd: typeof import('./components/teams/Add.vue')['default'];
TeamsDetails: typeof import('./components/teams/Details.vue')['default']; TeamsDetails: typeof import('./components/teams/Details.vue')['default'];
TeamsInvite: typeof import('./components/teams/Invite.vue')['default']; TeamsInvite: typeof import('./components/teams/Invite.vue')['default'];

View File

@@ -79,7 +79,7 @@ const t = useI18n();
const toast = useToast(); const toast = useToast();
const props = defineProps<{ const props = defineProps<{
team: TeamInfoQuery['admin']['teamInfo']; team: TeamInfoQuery['infra']['teamInfo'];
teamName: string; teamName: string;
showRenameInput: boolean; showRenameInput: boolean;
}>(); }>();

View File

@@ -213,11 +213,11 @@ const t = useI18n();
// Get Users List // Get Users List
const { data } = useQuery({ query: MetricsDocument }); const { data } = useQuery({ query: MetricsDocument });
const usersPerPage = computed(() => data.value?.admin.usersCount || 10000); const usersPerPage = computed(() => data.value?.infra.usersCount || 10000);
const { list: usersList } = usePagedQuery( const { list: usersList } = usePagedQuery(
UsersListDocument, UsersListDocument,
(x) => x.admin.allUsers, (x) => x.infra.allUsers,
(x) => x.uid, (x) => x.uid,
usersPerPage.value, usersPerPage.value,
{ cursor: undefined, take: usersPerPage.value } { cursor: undefined, take: usersPerPage.value }

View File

@@ -187,7 +187,7 @@ const emit = defineEmits<{
const showInvite = ref(false); const showInvite = ref(false);
// Get Team Details // Get Team Details
const team = ref<TeamInfoQuery['admin']['teamInfo'] | undefined>(); const team = ref<TeamInfoQuery['infra']['teamInfo'] | undefined>();
const fetching = ref(true); const fetching = ref(true);
const route = useRoute(); const route = useRoute();
const { client } = useClientHandle(); const { client } = useClientHandle();
@@ -201,8 +201,8 @@ const getTeamInfo = async () => {
if (result.error) { if (result.error) {
return toast.error(`${t('teams.load_info_error')}`); return toast.error(`${t('teams.load_info_error')}`);
} }
if (result.data?.admin.teamInfo) { if (result.data?.infra.teamInfo) {
team.value = result.data.admin.teamInfo; team.value = result.data.infra.teamInfo;
} }
fetching.value = false; fetching.value = false;
}; };

View File

@@ -72,9 +72,9 @@ const fetching = ref(true);
const error = ref(false); const error = ref(false);
const { client } = useClientHandle(); const { client } = useClientHandle();
const route = useRoute(); const route = useRoute();
const team = ref<TeamInfoQuery['admin']['teamInfo'] | undefined>(); const team = ref<TeamInfoQuery['infra']['teamInfo'] | undefined>();
const pendingInvites = ref< const pendingInvites = ref<
TeamInfoQuery['admin']['teamInfo']['teamInvitations'] | undefined TeamInfoQuery['infra']['teamInfo']['teamInvitations'] | undefined
>(); >();
const getTeamInfo = async () => { const getTeamInfo = async () => {
@@ -88,8 +88,8 @@ const getTeamInfo = async () => {
return toast.error(`${t('teams.load_info_error')}`); return toast.error(`${t('teams.load_info_error')}`);
} }
if (result.data?.admin.teamInfo) { if (result.data?.infra.teamInfo) {
team.value = result.data.admin.teamInfo; team.value = result.data.infra.teamInfo;
pendingInvites.value = team.value.teamInvitations; pendingInvites.value = team.value.teamInvitations;
} }
fetching.value = false; fetching.value = false;

View File

@@ -92,7 +92,7 @@ import { TeamListQuery } from '~/helpers/backend/graphql';
const tippyActions = ref<TippyComponent | null>(null); const tippyActions = ref<TippyComponent | null>(null);
defineProps<{ defineProps<{
teamList: TeamListQuery['admin']['allTeams']; teamList: TeamListQuery['infra']['allTeams'];
}>(); }>();
defineEmits<{ defineEmits<{

View File

@@ -143,7 +143,7 @@ import { useI18n } from '~/composables/i18n';
const t = useI18n(); const t = useI18n();
defineProps<{ defineProps<{
usersList: UsersListQuery['admin']['allUsers']; usersList: UsersListQuery['infra']['allUsers'];
}>(); }>();
defineEmits<{ defineEmits<{

View File

@@ -1,5 +1,5 @@
query InvitedUsers { query InvitedUsers {
admin { infra {
invitedUsers { invitedUsers {
adminUid adminUid
adminEmail adminEmail

View File

@@ -1,5 +1,5 @@
query Metrics { query Metrics {
admin { infra {
usersCount usersCount
teamsCount teamsCount
teamRequestsCount teamRequestsCount

View File

@@ -1,5 +1,5 @@
query TeamInfo($teamID: ID!) { query TeamInfo($teamID: ID!) {
admin { infra {
teamInfo(teamID: $teamID) { teamInfo(teamID: $teamID) {
id id
name name

View File

@@ -1,5 +1,5 @@
query TeamList($cursor: ID, $take: Int) { query TeamList($cursor: ID, $take: Int) {
admin { infra {
allTeams(cursor: $cursor, take: $take) { allTeams(cursor: $cursor, take: $take) {
id id
name name

View File

@@ -1,5 +1,5 @@
query UserInfo($uid: ID!) { query UserInfo($uid: ID!) {
admin { infra {
userInfo(userUid: $uid) { userInfo(userUid: $uid) {
uid uid
displayName displayName

View File

@@ -1,6 +1,6 @@
# Write your query or mutation here # Write your query or mutation here
query UsersList($cursor: ID, $take: Int) { query UsersList($cursor: ID, $take: Int) {
admin { infra {
allUsers(cursor: $cursor, take: $take) { allUsers(cursor: $cursor, take: $take) {
uid uid
displayName displayName

View File

@@ -57,5 +57,5 @@ const t = useI18n();
// Get Metrics Data // Get Metrics Data
const { fetching, error, data } = useQuery({ query: MetricsDocument }); const { fetching, error, data } = useQuery({ query: MetricsDocument });
const metrics = computed(() => data?.value?.admin); const metrics = computed(() => data?.value?.infra);
</script> </script>

View File

@@ -91,7 +91,7 @@ const currentTabName = computed(() => {
}); });
// Get the details of the team // Get the details of the team
const team = ref<TeamInfoQuery['admin']['teamInfo'] | undefined>(); const team = ref<TeamInfoQuery['infra']['teamInfo'] | undefined>();
const teamName = ref(''); const teamName = ref('');
const route = useRoute(); const route = useRoute();
const fetching = ref(true); const fetching = ref(true);
@@ -105,8 +105,8 @@ const getTeamInfo = async () => {
if (result.error) { if (result.error) {
return toast.error(`${t('team.load_info_error')}`); return toast.error(`${t('team.load_info_error')}`);
} }
if (result.data?.admin.teamInfo) { if (result.data?.infra.teamInfo) {
team.value = result.data.admin.teamInfo; team.value = result.data.infra.teamInfo;
teamName.value = team.value.name; teamName.value = team.value.name;
} }
fetching.value = false; fetching.value = false;

View File

@@ -77,11 +77,11 @@ const t = useI18n();
const toast = useToast(); const toast = useToast();
// Get Users List // Get Users List
const { data } = useQuery({ query: MetricsDocument }); const { data } = useQuery({ query: MetricsDocument });
const usersPerPage = computed(() => data.value?.admin.usersCount || 10000); const usersPerPage = computed(() => data.value?.infra.usersCount || 10000);
const { list: usersList } = usePagedQuery( const { list: usersList } = usePagedQuery(
UsersListDocument, UsersListDocument,
(x) => x.admin.allUsers, (x) => x.infra.allUsers,
(x) => x.uid, (x) => x.uid,
usersPerPage.value, usersPerPage.value,
{ cursor: undefined, take: usersPerPage.value } { cursor: undefined, take: usersPerPage.value }
@@ -100,7 +100,7 @@ const {
hasNextPage, hasNextPage,
} = usePagedQuery( } = usePagedQuery(
TeamListDocument, TeamListDocument,
(x) => x.admin.allTeams, (x) => x.infra.allTeams,
(x) => x.id, (x) => x.id,
teamsPerPage, teamsPerPage,
{ cursor: undefined, take: teamsPerPage } { cursor: undefined, take: teamsPerPage }

View File

@@ -179,7 +179,7 @@ onMounted(async () => {
if (result.error) { if (result.error) {
toast.error(`${t('users.load_info_error')}`); toast.error(`${t('users.load_info_error')}`);
} }
user.value = result.data?.admin.userInfo ?? {}; user.value = result.data?.infra.userInfo ?? {};
fetching.value = false; fetching.value = false;
}); });

View File

@@ -112,7 +112,7 @@ const {
hasNextPage, hasNextPage,
} = usePagedQuery( } = usePagedQuery(
UsersListDocument, UsersListDocument,
(x) => x.admin.allUsers, (x) => x.infra.allUsers,
(x) => x.uid, (x) => x.uid,
usersPerPage, usersPerPage,
{ cursor: undefined, take: usersPerPage } { cursor: undefined, take: usersPerPage }

View File

@@ -101,5 +101,5 @@ const getCreatedTime = (date: string) => format(new Date(date), 'hh:mm a');
// Get Invited Users // Get Invited Users
const { fetching, error, data } = useQuery({ query: InvitedUsersDocument }); const { fetching, error, data } = useQuery({ query: InvitedUsersDocument });
const invitedUsers = computed(() => data?.value?.admin.invitedUsers); const invitedUsers = computed(() => data?.value?.infra.invitedUsers);
</script> </script>