From 7d5a516f559edf40cb9450cb26da04d78eb156c1 Mon Sep 17 00:00:00 2001 From: jay-hodgson Date: Mon, 2 Dec 2024 10:12:43 -0800 Subject: [PATCH 1/3] PORTALS-3332: add team member count, and use it in the Challenge portal --- .../challengeportal/ChallengeDetailPageWrapper.tsx | 9 +++++---- .../src/synapse-client/SynapseClient.ts | 10 ++++++++++ .../src/synapse-queries/KeyFactory.ts | 3 +++ .../src/synapse-queries/team/useTeamMembers.ts | 13 +++++++++++++ .../synapse-react-client/src/utils/APIConstants.ts | 2 ++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/apps/synapse-portal-framework/src/components/challengeportal/ChallengeDetailPageWrapper.tsx b/apps/synapse-portal-framework/src/components/challengeportal/ChallengeDetailPageWrapper.tsx index 44c8af5a34..b6c8a86aba 100644 --- a/apps/synapse-portal-framework/src/components/challengeportal/ChallengeDetailPageWrapper.tsx +++ b/apps/synapse-portal-framework/src/components/challengeportal/ChallengeDetailPageWrapper.tsx @@ -34,16 +34,17 @@ const ChallengeDetailPageWrapper = () => { enabled: !!projectId, }, ) - const { data: teamMembers, isLoading: isTeamMembersLoading } = - SynapseQueries.useGetTeamMembers(challenge?.participantTeamId ?? '', { + + const { data: teamMemberCount, isLoading: isTeamMemberCountLoading } = + SynapseQueries.useGetTeamMemberCount(challenge?.participantTeamId ?? '', { enabled: !!challenge, }) - if (isEntityBundleLoading || isChallengeLoading || isTeamMembersLoading) { + if (isEntityBundleLoading || isChallengeLoading || isTeamMemberCountLoading) { return } const isChallengeActive = entityBundle?.annotations.annotations['Status']?.value[0] == 'Active' - const memberCount = teamMembers?.totalNumberOfResults + const memberCount = teamMemberCount?.count if (projectId !== undefined) { return ( // mimic card container layout to align with card fields diff --git a/packages/synapse-react-client/src/synapse-client/SynapseClient.ts b/packages/synapse-react-client/src/synapse-client/SynapseClient.ts index 5b1fd72832..e918b6622e 100644 --- a/packages/synapse-react-client/src/synapse-client/SynapseClient.ts +++ b/packages/synapse-react-client/src/synapse-client/SynapseClient.ts @@ -101,6 +101,7 @@ import { TERMS_OF_USE_INFO, TERMS_OF_USE_STATUS, PROJECT_STORAGE_USAGE, + TEAM_MEMBER_COUNT, } from '../utils/APIConstants' import { dispatchDownloadListChangeEvent } from '../utils/functions/dispatchDownloadListChangeEvent' import { BackendDestinationEnum, getEndpoint } from '../utils/functions' @@ -350,6 +351,7 @@ import appendFinalQueryParamKey from '../utils/appendFinalQueryParamKey' import xss from 'xss' import { xssOptions } from '../utils/functions/SanitizeHtmlUtils' import { TwoFactorAuthErrorResponse } from '@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse' +import { Count } from '@sage-bionetworks/synapse-client' const cookies = new UniversalCookies() @@ -1572,6 +1574,14 @@ export const getTeamMembers = ( return doGet(url, accessToken, BackendDestinationEnum.REPO_ENDPOINT) } +export const getTeamMemberCount = ( + accessToken: string | undefined, + teamId: string | number, +): Promise => { + const url = TEAM_MEMBER_COUNT(teamId) + return doGet(url, accessToken, BackendDestinationEnum.REPO_ENDPOINT) +} + /** * Add a member to the Team * https://rest-docs.synapse.org/rest/PUT/teamMember.html diff --git a/packages/synapse-react-client/src/synapse-queries/KeyFactory.ts b/packages/synapse-react-client/src/synapse-queries/KeyFactory.ts index bd1a6dfc19..4131d547fa 100644 --- a/packages/synapse-react-client/src/synapse-queries/KeyFactory.ts +++ b/packages/synapse-react-client/src/synapse-queries/KeyFactory.ts @@ -729,6 +729,9 @@ export class KeyFactory { public getTeamMembersQueryKey(teamId: string) { return this.getKey('team', teamId, 'membersList') } + public getTeamMemberCountQueryKey(teamId: string) { + return this.getKey('team', teamId, 'memberCount') + } public getIsUserMemberOfTeamQueryKey(teamId: string, userId: string) { return this.getKey('team', teamId, 'member', userId) diff --git a/packages/synapse-react-client/src/synapse-queries/team/useTeamMembers.ts b/packages/synapse-react-client/src/synapse-queries/team/useTeamMembers.ts index 6d2eff21e6..3620fd9f05 100644 --- a/packages/synapse-react-client/src/synapse-queries/team/useTeamMembers.ts +++ b/packages/synapse-react-client/src/synapse-queries/team/useTeamMembers.ts @@ -16,6 +16,7 @@ import { TeamMember, TeamMembershipStatus, } from '@sage-bionetworks/synapse-types' +import { Count } from '@sage-bionetworks/synapse-client' export function useGetTeamMembers( teamId: string | number, @@ -31,6 +32,18 @@ export function useGetTeamMembers( }) } +export function useGetTeamMemberCount( + teamId: string | number, + options?: Partial>, +) { + const { accessToken, keyFactory } = useSynapseContext() + return useQuery({ + ...options, + queryKey: keyFactory.getTeamMemberCountQueryKey(String(teamId)), + queryFn: () => SynapseClient.getTeamMemberCount(accessToken, teamId), + }) +} + export function useGetIsUserMemberOfTeam( teamId: string, userId: string, diff --git a/packages/synapse-react-client/src/utils/APIConstants.ts b/packages/synapse-react-client/src/utils/APIConstants.ts index cdbf8bbcfb..c5aa80ecc6 100644 --- a/packages/synapse-react-client/src/utils/APIConstants.ts +++ b/packages/synapse-react-client/src/utils/APIConstants.ts @@ -156,6 +156,8 @@ export const TEAM_ID_MEMBER_ID = ( ) => TEAM(teamId) + `/member/${memberId}` export const TEAM_MEMBERS = (teamId: string | number) => `${REPO}/teamMembers/${teamId}` +export const TEAM_MEMBER_COUNT = (teamId: string | number) => + `${REPO}/teamMembers/count/${teamId}` const notificationUnsubscribeEndpoint = 'https://www.synapse.org/SignedToken:' const teamEndpoint = 'https://www.synapse.org/Team:' From 6c19d2dbb0a62ce648e06919a9b3c3b7b73d1e4a Mon Sep 17 00:00:00 2001 From: jay-hodgson Date: Mon, 2 Dec 2024 11:02:36 -0800 Subject: [PATCH 2/3] from code review --- .../src/synapse-client/SynapseClient.ts | 10 ---------- .../src/synapse-queries/team/useTeamMembers.ts | 9 ++++++--- .../synapse-react-client/src/utils/APIConstants.ts | 2 -- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/synapse-react-client/src/synapse-client/SynapseClient.ts b/packages/synapse-react-client/src/synapse-client/SynapseClient.ts index e918b6622e..5b1fd72832 100644 --- a/packages/synapse-react-client/src/synapse-client/SynapseClient.ts +++ b/packages/synapse-react-client/src/synapse-client/SynapseClient.ts @@ -101,7 +101,6 @@ import { TERMS_OF_USE_INFO, TERMS_OF_USE_STATUS, PROJECT_STORAGE_USAGE, - TEAM_MEMBER_COUNT, } from '../utils/APIConstants' import { dispatchDownloadListChangeEvent } from '../utils/functions/dispatchDownloadListChangeEvent' import { BackendDestinationEnum, getEndpoint } from '../utils/functions' @@ -351,7 +350,6 @@ import appendFinalQueryParamKey from '../utils/appendFinalQueryParamKey' import xss from 'xss' import { xssOptions } from '../utils/functions/SanitizeHtmlUtils' import { TwoFactorAuthErrorResponse } from '@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse' -import { Count } from '@sage-bionetworks/synapse-client' const cookies = new UniversalCookies() @@ -1574,14 +1572,6 @@ export const getTeamMembers = ( return doGet(url, accessToken, BackendDestinationEnum.REPO_ENDPOINT) } -export const getTeamMemberCount = ( - accessToken: string | undefined, - teamId: string | number, -): Promise => { - const url = TEAM_MEMBER_COUNT(teamId) - return doGet(url, accessToken, BackendDestinationEnum.REPO_ENDPOINT) -} - /** * Add a member to the Team * https://rest-docs.synapse.org/rest/PUT/teamMember.html diff --git a/packages/synapse-react-client/src/synapse-queries/team/useTeamMembers.ts b/packages/synapse-react-client/src/synapse-queries/team/useTeamMembers.ts index 3620fd9f05..4a1fa5d302 100644 --- a/packages/synapse-react-client/src/synapse-queries/team/useTeamMembers.ts +++ b/packages/synapse-react-client/src/synapse-queries/team/useTeamMembers.ts @@ -33,14 +33,17 @@ export function useGetTeamMembers( } export function useGetTeamMemberCount( - teamId: string | number, + teamId: string, options?: Partial>, ) { - const { accessToken, keyFactory } = useSynapseContext() + const { keyFactory, synapseClient } = useSynapseContext() return useQuery({ ...options, queryKey: keyFactory.getTeamMemberCountQueryKey(String(teamId)), - queryFn: () => SynapseClient.getTeamMemberCount(accessToken, teamId), + queryFn: () => + synapseClient.teamServicesClient.getRepoV1TeamMembersCountId({ + id: teamId, + }), }) } diff --git a/packages/synapse-react-client/src/utils/APIConstants.ts b/packages/synapse-react-client/src/utils/APIConstants.ts index c5aa80ecc6..cdbf8bbcfb 100644 --- a/packages/synapse-react-client/src/utils/APIConstants.ts +++ b/packages/synapse-react-client/src/utils/APIConstants.ts @@ -156,8 +156,6 @@ export const TEAM_ID_MEMBER_ID = ( ) => TEAM(teamId) + `/member/${memberId}` export const TEAM_MEMBERS = (teamId: string | number) => `${REPO}/teamMembers/${teamId}` -export const TEAM_MEMBER_COUNT = (teamId: string | number) => - `${REPO}/teamMembers/count/${teamId}` const notificationUnsubscribeEndpoint = 'https://www.synapse.org/SignedToken:' const teamEndpoint = 'https://www.synapse.org/Team:' From e1f426e24d768c345c97298227ec25aa8fe6060c Mon Sep 17 00:00:00 2001 From: Victor B <83256374+MasterPastures@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:39:14 -0500 Subject: [PATCH 3/3] Update resources.ts for ADKP data release 24.11 versioned FileView to syn11346063.64 and updated this file accordingly --- apps/portals/adknowledgeportal/src/config/resources.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/portals/adknowledgeportal/src/config/resources.ts b/apps/portals/adknowledgeportal/src/config/resources.ts index cd28212c2a..9c9fdb8034 100644 --- a/apps/portals/adknowledgeportal/src/config/resources.ts +++ b/apps/portals/adknowledgeportal/src/config/resources.ts @@ -1,7 +1,7 @@ export const computationalSql = 'Select * from syn20337467' -export const dataSql = 'SELECT * FROM syn11346063.63' +export const dataSql = 'SELECT * FROM syn11346063.64' export const dataOnStudiesPageSql = - "SELECT id, name, metadataType, dataType, assay FROM syn11346063.63 WHERE `resourceType` = 'metadata'" + "SELECT id, name, metadataType, dataType, assay FROM syn11346063.64 WHERE `resourceType` = 'metadata'" export const peopleSql = 'SELECT * FROM syn13897207' export const projectsSql = 'SELECT * FROM syn17024229 ORDER BY isFeatured DESC' export const publicationsSql = 'SELECT * FROM syn20448807'