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'];
HoppSmartModal: typeof import('@hoppscotch/ui')['HoppSmartModal'];
HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture'];
HoppSmartPlaceholder: typeof import('@hoppscotch/ui')['HoppSmartPlaceholder'];
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'];
IconLucideHelpCircle: typeof import('~icons/lucide/help-circle')['default'];
IconLucideInbox: typeof import('~icons/lucide/inbox')['default'];
IconLucideUser: typeof import('~icons/lucide/user')['default'];
TeamsAdd: typeof import('./components/teams/Add.vue')['default'];
TeamsDetails: typeof import('./components/teams/Details.vue')['default'];
TeamsInvite: typeof import('./components/teams/Invite.vue')['default'];

View File

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

View File

@@ -213,11 +213,11 @@ const t = useI18n();
// Get Users List
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(
UsersListDocument,
(x) => x.admin.allUsers,
(x) => x.infra.allUsers,
(x) => x.uid,
usersPerPage.value,
{ cursor: undefined, take: usersPerPage.value }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -77,11 +77,11 @@ const t = useI18n();
const toast = useToast();
// Get Users List
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(
UsersListDocument,
(x) => x.admin.allUsers,
(x) => x.infra.allUsers,
(x) => x.uid,
usersPerPage.value,
{ cursor: undefined, take: usersPerPage.value }
@@ -100,7 +100,7 @@ const {
hasNextPage,
} = usePagedQuery(
TeamListDocument,
(x) => x.admin.allTeams,
(x) => x.infra.allTeams,
(x) => x.id,
teamsPerPage,
{ cursor: undefined, take: teamsPerPage }

View File

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

View File

@@ -112,7 +112,7 @@ const {
hasNextPage,
} = usePagedQuery(
UsersListDocument,
(x) => x.admin.allUsers,
(x) => x.infra.allUsers,
(x) => x.uid,
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
const { fetching, error, data } = useQuery({ query: InvitedUsersDocument });
const invitedUsers = computed(() => data?.value?.admin.invitedUsers);
const invitedUsers = computed(() => data?.value?.infra.invitedUsers);
</script>