From cb4ad87f08f41461912c59ca1dbd5d8ebee8824b Mon Sep 17 00:00:00 2001 From: Anwarul Islam Date: Fri, 2 May 2025 21:22:13 +0600 Subject: [PATCH] feat(common): platform ui definition for team edit and invite (#5037) Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com> --- .../src/components/app/Header.vue | 43 ++++++++++--- .../src/components/teams/Edit.vue | 16 ++++- .../src/components/teams/Invite.vue | 1 + .../src/components/teams/index.vue | 62 +++++++++++++------ .../src/composables/graphql.ts | 17 ++++- packages/hoppscotch-common/src/platform/ui.ts | 10 +++ 6 files changed, 120 insertions(+), 29 deletions(-) diff --git a/packages/hoppscotch-common/src/components/app/Header.vue b/packages/hoppscotch-common/src/components/app/Header.vue index 4d528bf0..43f4e501 100644 --- a/packages/hoppscotch-common/src/components/app/Header.vue +++ b/packages/hoppscotch-common/src/components/app/Header.vue @@ -260,13 +260,31 @@ @dismiss="dismissBanner" /> - - + + + + + + + + + ({ teamID: props.editingTeamID, }, pollDuration: 10000, + pollLoadingEnabled: false, defer: true, updateSubs: computed(() => { if (props.editingTeamID) { diff --git a/packages/hoppscotch-common/src/components/teams/Invite.vue b/packages/hoppscotch-common/src/components/teams/Invite.vue index d0cc48d9..1c7978b9 100644 --- a/packages/hoppscotch-common/src/components/teams/Invite.vue +++ b/packages/hoppscotch-common/src/components/teams/Invite.vue @@ -499,6 +499,7 @@ const pendingInvites = useGQLQuery< teamID: props.editingTeamID, }), pollDuration: 10000, + pollLoadingEnabled: false, updateSubs: computed(() => !props.editingTeamID ? [] diff --git a/packages/hoppscotch-common/src/components/teams/index.vue b/packages/hoppscotch-common/src/components/teams/index.vue index 85c7206f..b7bf4076 100644 --- a/packages/hoppscotch-common/src/components/teams/index.vue +++ b/packages/hoppscotch-common/src/components/teams/index.vue @@ -43,24 +43,49 @@ - - + + @@ -72,6 +97,7 @@ import { useColorMode } from "@composables/theming" import { WorkspaceService } from "~/services/workspace.service" import { useService } from "dioc/vue" import IconPlus from "~icons/lucide/plus" +import { platform } from "~/platform" const t = useI18n() diff --git a/packages/hoppscotch-common/src/composables/graphql.ts b/packages/hoppscotch-common/src/composables/graphql.ts index 0e4f933c..a7ae6008 100644 --- a/packages/hoppscotch-common/src/composables/graphql.ts +++ b/packages/hoppscotch-common/src/composables/graphql.ts @@ -35,6 +35,13 @@ type UseQueryOptions = { updateSubs?: MaybeRef[]> defer?: boolean pollDuration?: number | undefined + + /** + * Determines the behavior of the loading state during polling. + * If true, the loading state toggles each time the poller runs; + * if false, it is set to true only once when the poller starts. + */ + pollLoadingEnabled?: boolean } export const useGQLQuery = < @@ -58,6 +65,8 @@ export const useGQLQuery = < const pollDuration: Ref = ref(args.pollDuration ?? null) + const pollLoadingEnabled: Ref = ref(args.pollLoadingEnabled ?? true) + const request: Ref> = ref( createRequest( args.query, @@ -101,6 +110,10 @@ export const useGQLQuery = < ) const rerunQuery = () => { + if (pollLoadingEnabled.value) { + loading.value = true + } + source.value = !isPaused.value ? client.value?.executeQuery(request.value, { requestPolicy: "network-only", @@ -122,7 +135,9 @@ export const useGQLQuery = < watchSyncEffect((onInvalidate) => { if (source.value) { - loading.value = true + if (pollLoadingEnabled.value) { + loading.value = true + } isStale.value = false const invalidateStops = args.updateSubs!.map((sub) => { diff --git a/packages/hoppscotch-common/src/platform/ui.ts b/packages/hoppscotch-common/src/platform/ui.ts index 3122ac8c..b1996606 100644 --- a/packages/hoppscotch-common/src/platform/ui.ts +++ b/packages/hoppscotch-common/src/platform/ui.ts @@ -59,6 +59,16 @@ export type UIPlatformDef = { */ additionalSidebarHeaderItem?: Component + /** + * Custom invite component to be shown in the team invite page + */ + additionalTeamInviteComponent?: Component + + /** + * Custom edit component to be shown in the team edit page + */ + additionalTeamEditComponent?: Component + /** * More info shown in the danger zone section while attempting user deletion * Sample use case includes displaying the instance information on cloud instances