From 4d719f425b4fab7417f9dd06dbb6560696974c66 Mon Sep 17 00:00:00 2001 From: Fran McDade Date: Mon, 6 Jan 2025 17:49:04 +1000 Subject: [PATCH] chore: updated findable-ui to latest v20.0.0 (#511) (#515) --------- Co-authored-by: Fran McDade --- .../cellxgeneInProgress.tsx | 15 +- .../integrationLeadsFromAtlases.tsx | 13 +- .../Forms/components/Refresh/refresh.tsx | 12 +- app/hooks/useDeleteData.ts | 4 +- app/hooks/useFetchData.ts | 4 +- .../useFetchSourceStudiesSourceDatasets.ts | 4 +- app/hooks/useForm/useForm.ts | 4 +- app/hooks/useFormManager/useFormManager.ts | 6 +- app/providers/authorization.tsx | 10 +- app/services/__mocks__/user-profile.ts | 23 --- app/services/user-profile.ts | 6 +- .../cellxgeneInProgressView.tsx | 16 +- .../integrationLeadsFromAtlasesView.tsx | 16 +- app/views/RefreshView/refreshView.tsx | 16 +- .../hooks/useSetLinkedAtlasSourceDatasets.ts | 4 +- .../hooks/useDeleteSourceStudy.ts | 4 +- package-lock.json | 139 +++++++++++++++++- package.json | 3 +- pages/_app.tsx | 6 +- site-config/common/authentication.ts | 15 ++ .../local/authentication/authentication.ts | 19 ++- .../local/index/atlasEntityConfig.ts | 9 +- .../local/index/userEntityConfig.ts | 9 +- .../prod/authentication/authentication.ts | 19 ++- 24 files changed, 263 insertions(+), 113 deletions(-) delete mode 100644 app/services/__mocks__/user-profile.ts create mode 100644 site-config/common/authentication.ts diff --git a/app/components/Forms/components/CellxGeneInProgress/cellxgeneInProgress.tsx b/app/components/Forms/components/CellxGeneInProgress/cellxgeneInProgress.tsx index dbfa47be..f16d1cdf 100644 --- a/app/components/Forms/components/CellxGeneInProgress/cellxgeneInProgress.tsx +++ b/app/components/Forms/components/CellxGeneInProgress/cellxgeneInProgress.tsx @@ -1,17 +1,14 @@ import { ButtonPrimary } from "@databiosphere/findable-ui/lib/components/common/Button/components/ButtonPrimary/buttonPrimary"; -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; +import { useToken } from "@databiosphere/findable-ui/lib/hooks/authentication/token/useToken"; import { TextField } from "@mui/material"; import { useCallback, useRef, useState } from "react"; import { TASK_STATUS, TaskStatusesUpdatedByDOIResult, -} from "../../../../../app/apis/catalog/hca-atlas-tracker/common/entities"; -import { METHOD } from "../../../../../app/common/entities"; -import { - fetchResource, - isFetchStatusOk, -} from "../../../../../app/common/utils"; -import { FormResponseErrors } from "../../../../../app/hooks/useForm/common/entities"; +} from "../../../../apis/catalog/hca-atlas-tracker/common/entities"; +import { METHOD } from "../../../../common/entities"; +import { fetchResource, isFetchStatusOk } from "../../../../common/utils"; +import { FormResponseErrors } from "../../../../hooks/useForm/common/entities"; export const CellxGeneInProgressForm = (): JSX.Element => { const [isDisabled, setIsDisabled] = useState(false); @@ -21,7 +18,7 @@ export const CellxGeneInProgressForm = (): JSX.Element => { const textareaRef = useRef(); - const { token } = useAuthentication(); + const { token } = useToken(); const onSave = useCallback(() => { (async (): Promise => { diff --git a/app/components/Forms/components/IntegrationLeadsFromAtlases/integrationLeadsFromAtlases.tsx b/app/components/Forms/components/IntegrationLeadsFromAtlases/integrationLeadsFromAtlases.tsx index 38b05232..684753b8 100644 --- a/app/components/Forms/components/IntegrationLeadsFromAtlases/integrationLeadsFromAtlases.tsx +++ b/app/components/Forms/components/IntegrationLeadsFromAtlases/integrationLeadsFromAtlases.tsx @@ -1,19 +1,16 @@ import { ButtonPrimary } from "@databiosphere/findable-ui/lib/components/common/Button/components/ButtonPrimary/buttonPrimary"; -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; +import { useToken } from "@databiosphere/findable-ui/lib/hooks/authentication/token/useToken"; import { useCallback, useState } from "react"; -import { METHOD } from "../../../../../app/common/entities"; -import { - fetchResource, - isFetchStatusOk, -} from "../../../../../app/common/utils"; -import { FormResponseErrors } from "../../../../../app/hooks/useForm/common/entities"; +import { METHOD } from "../../../../common/entities"; +import { fetchResource, isFetchStatusOk } from "../../../../common/utils"; +import { FormResponseErrors } from "../../../../hooks/useForm/common/entities"; export const IntegrationLeadsFromAtlasesForm = (): JSX.Element => { const [isDisabled, setIsDisabled] = useState(false); const [responseErrors, setResponseErrors] = useState(); const [didUpdate, setDidUpdate] = useState(false); - const { token } = useAuthentication(); + const { token } = useToken(); const onSave = useCallback(() => { (async (): Promise => { diff --git a/app/components/Forms/components/Refresh/refresh.tsx b/app/components/Forms/components/Refresh/refresh.tsx index 906e8a4f..b12f943c 100644 --- a/app/components/Forms/components/Refresh/refresh.tsx +++ b/app/components/Forms/components/Refresh/refresh.tsx @@ -1,15 +1,15 @@ import { ButtonPrimary } from "@databiosphere/findable-ui/lib/components/common/Button/components/ButtonPrimary/buttonPrimary"; -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; +import { useToken } from "@databiosphere/findable-ui/lib/hooks/authentication/token/useToken"; import { useCallback, useEffect, useState } from "react"; -import { METHOD } from "../../../../../app/common/entities"; -import { fetchResource } from "../../../../../app/common/utils"; -import { FormResponseErrors } from "../../../../../app/hooks/useForm/common/entities"; +import { METHOD } from "../../../../common/entities"; +import { fetchResource } from "../../../../common/utils"; +import { FormResponseErrors } from "../../../../hooks/useForm/common/entities"; import { REFRESH_ACTIVITY, REFRESH_OUTCOME, RefreshServicesStatuses, RefreshStatus, -} from "../../../../../app/services/common/entities"; +} from "../../../../services/common/entities"; export const RefreshForm = (): JSX.Element => { const [statusIsDisabled, setStatusIsDisabled] = useState(false); @@ -22,7 +22,7 @@ export const RefreshForm = (): JSX.Element => { useState(); const [refreshStarted, setRefreshStarted] = useState(false); - const { token } = useAuthentication(); + const { token } = useToken(); const onReloadStatus = useCallback(() => { doApiRequest( diff --git a/app/hooks/useDeleteData.ts b/app/hooks/useDeleteData.ts index 499a2caf..29d95733 100644 --- a/app/hooks/useDeleteData.ts +++ b/app/hooks/useDeleteData.ts @@ -1,4 +1,4 @@ -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; +import { useToken } from "@databiosphere/findable-ui/lib/hooks/authentication/token/useToken"; import { useCallback } from "react"; import { METHOD } from "../common/entities"; import { fetchResource, isFetchStatusOk } from "../common/utils"; @@ -13,7 +13,7 @@ export const useDeleteData = ( method = METHOD.DELETE, options?: OnDeleteOptions ): UseDeleteData => { - const { token } = useAuthentication(); + const { token } = useToken(); const onDelete = useCallback( async (payload?: T): Promise => { diff --git a/app/hooks/useFetchData.ts b/app/hooks/useFetchData.ts index e00476fe..5fd4ef95 100644 --- a/app/hooks/useFetchData.ts +++ b/app/hooks/useFetchData.ts @@ -1,5 +1,5 @@ +import { useToken } from "@databiosphere/findable-ui/lib/hooks/authentication/token/useToken"; import { useAsync } from "@databiosphere/findable-ui/lib/hooks/useAsync"; -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; import { useCallback, useEffect } from "react"; import { METHOD } from "../common/entities"; import { fetchResource, isFetchStatusOk } from "../common/utils"; @@ -14,7 +14,7 @@ export const useFetchData = ( method: METHOD, shouldFetch = true ): UseFetchData => { - const { token } = useAuthentication(); + const { token } = useToken(); const { data, isSuccess, run } = useAsync(); const fetchData = useCallback(async (): Promise => { diff --git a/app/hooks/useFetchSourceStudiesSourceDatasets.ts b/app/hooks/useFetchSourceStudiesSourceDatasets.ts index 6ff9d2d0..86c029cf 100644 --- a/app/hooks/useFetchSourceStudiesSourceDatasets.ts +++ b/app/hooks/useFetchSourceStudiesSourceDatasets.ts @@ -1,4 +1,4 @@ -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; +import { useToken } from "@databiosphere/findable-ui/lib/hooks/authentication/token/useToken"; import { useCallback, useEffect, useState } from "react"; import { API } from "../apis/catalog/hca-atlas-tracker/common/api"; import { @@ -13,7 +13,7 @@ import { useFetchData } from "./useFetchData"; export const useFetchSourceStudiesSourceDatasets = ( pathParameter: PathParameter ): HCAAtlasTrackerSourceDataset[] | undefined => { - const { token } = useAuthentication(); + const { token } = useToken(); const [sourceStudiesSourceDatasets, setSourceStudiesSourceDatasets] = useState(); const { data: sourceStudies } = useFetchData< diff --git a/app/hooks/useForm/useForm.ts b/app/hooks/useForm/useForm.ts index 388bb6c5..206e310f 100644 --- a/app/hooks/useForm/useForm.ts +++ b/app/hooks/useForm/useForm.ts @@ -1,4 +1,4 @@ -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; +import { useToken } from "@databiosphere/findable-ui/lib/hooks/authentication/token/useToken"; import { yupResolver } from "@hookform/resolvers/yup"; import { useCallback, useEffect, useMemo, useState } from "react"; import { @@ -41,7 +41,7 @@ export const useForm = ( mapApiValues: MapApiValuesFn = (p): unknown => p, options: CustomUseFormOptions = {} ): UseForm => { - const { token } = useAuthentication(); + const { token } = useToken(); const values = useMemo( () => schema.cast(mapSchemaValues?.(apiData)), [apiData, mapSchemaValues, schema] diff --git a/app/hooks/useFormManager/useFormManager.ts b/app/hooks/useFormManager/useFormManager.ts index f352ea34..48ce3784 100644 --- a/app/hooks/useFormManager/useFormManager.ts +++ b/app/hooks/useFormManager/useFormManager.ts @@ -1,4 +1,4 @@ -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; +import { useAuth } from "@databiosphere/findable-ui/lib/providers/authentication/auth/hook"; import Router from "next/router"; import { useCallback, useEffect, useState } from "react"; import { FieldValues } from "react-hook-form"; @@ -34,7 +34,9 @@ export const useFormManager = ( } = {}, isDirty = formMethod?.formState.isDirty ?? false ): UseFormManager => { - const { isAuthenticated } = useAuthentication(); + const { + authState: { isAuthenticated }, + } = useAuth(); const { user } = useAuthorization(); const { canEdit } = useUserHasEditAuthorization(); const [pathRoute, setPathRoute] = diff --git a/app/providers/authorization.tsx b/app/providers/authorization.tsx index ba65b85a..fe68eb6f 100644 --- a/app/providers/authorization.tsx +++ b/app/providers/authorization.tsx @@ -1,5 +1,5 @@ import { Main as DXMain } from "@databiosphere/findable-ui/lib/components/Layout/components/Main/main"; -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; +import { useAuth } from "@databiosphere/findable-ui/lib/providers/authentication/auth/hook"; import { createContext, ReactNode, useEffect } from "react"; import { HCAAtlasTrackerActiveUser, @@ -21,7 +21,9 @@ interface Props { } export function AuthorizationProvider({ children }: Props): JSX.Element { - const { isAuthenticated } = useAuthentication(); + const { + authState: { isAuthenticated }, + } = useAuth(); const user = useFetchActiveUser(); const { disabled, role } = user || {}; const isAuthorized = isUserAuthorized(role, disabled); @@ -33,7 +35,9 @@ export function AuthorizationProvider({ children }: Props): JSX.Element { }, [role, disabled]); return ( - + {shouldRenderComponents(isAuthenticated, isAuthorized) ? ( children ) : ( diff --git a/app/services/__mocks__/user-profile.ts b/app/services/__mocks__/user-profile.ts deleted file mode 100644 index 231858d4..00000000 --- a/app/services/__mocks__/user-profile.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { UserProfile } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useFetchGoogleProfile"; -import { TEST_USERS } from "testing/constants"; - -export async function getProvidedUserProfile( - authorization: string | undefined -): Promise { - if (!authorization) return null; - const token = /^Bearer (.+)$/.exec(authorization)?.[1]; - if (!token) return null; - const user = TEST_USERS.find((u) => u.token === token); - if (!user) throw new Error("Invalid token"); - return { - email: user.email, - email_verified: true, - family_name: user.name, - given_name: user.name, - hd: "", - locale: "", - name: user.name, - picture: "", - sub: "", - }; -} diff --git a/app/services/user-profile.ts b/app/services/user-profile.ts index 2771526d..1f85e40a 100644 --- a/app/services/user-profile.ts +++ b/app/services/user-profile.ts @@ -1,11 +1,13 @@ -import { getAuthenticationRequestOptions } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/common/utils"; -import { UserProfile } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useFetchGoogleProfile"; +import { UserProfile as BaseUserProfile } from "@databiosphere/findable-ui/lib/providers/authentication/authentication/types"; +import { getAuthenticationRequestOptions } from "@databiosphere/findable-ui/lib/providers/authentication/terra/hooks/common/utils"; import ky from "ky"; const ENDPOINT = "https://www.googleapis.com/oauth2/v3/userinfo"; const userProfilesCache = new Map(); +export type UserProfile = BaseUserProfile & { email_verified: boolean }; + export async function getProvidedUserProfile( authorization: string | undefined ): Promise { diff --git a/app/views/CellxGeneInProgressView/cellxgeneInProgressView.tsx b/app/views/CellxGeneInProgressView/cellxgeneInProgressView.tsx index 3060964c..f3ddc1b2 100644 --- a/app/views/CellxGeneInProgressView/cellxgeneInProgressView.tsx +++ b/app/views/CellxGeneInProgressView/cellxgeneInProgressView.tsx @@ -1,13 +1,15 @@ -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; +import { useAuth } from "@databiosphere/findable-ui/lib/providers/authentication/auth/hook"; import { ContentView } from "@databiosphere/findable-ui/lib/views/ContentView/contentView"; -import { AccessPrompt } from "../../../app/components/common/Form/components/FormManager/components/AccessPrompt/accessPrompt"; -import { Divider } from "../../../app/components/Detail/components/TrackerForm/components/Divider/divider.styles"; -import { CellxGeneInProgressForm } from "../../../app/components/Forms/components/CellxGeneInProgress/cellxgeneInProgress"; -import { Content } from "../../../app/components/Layout/components/Content/content"; -import { LAYOUT_STYLE_NO_CONTRAST_DEFAULT } from "../../../app/content/common/constants"; +import { AccessPrompt } from "../../components/common/Form/components/FormManager/components/AccessPrompt/accessPrompt"; +import { Divider } from "../../components/Detail/components/TrackerForm/components/Divider/divider.styles"; +import { CellxGeneInProgressForm } from "../../components/Forms/components/CellxGeneInProgress/cellxgeneInProgress"; +import { Content } from "../../components/Layout/components/Content/content"; +import { LAYOUT_STYLE_NO_CONTRAST_DEFAULT } from "../../content/common/constants"; export const CellxGeneInProgressView = (): JSX.Element => { - const { isAuthenticated } = useAuthentication(); + const { + authState: { isAuthenticated }, + } = useAuth(); return ( { - const { isAuthenticated } = useAuthentication(); + const { + authState: { isAuthenticated }, + } = useAuth(); return ( { - const { isAuthenticated } = useAuthentication(); + const { + authState: { isAuthenticated }, + } = useAuth(); return ( { - const { token } = useAuthentication(); + const { token } = useToken(); const onSetLinked = useCallback( async (sourceDatasetId: string, linked: boolean): Promise => { diff --git a/app/views/SourceStudyView/hooks/useDeleteSourceStudy.ts b/app/views/SourceStudyView/hooks/useDeleteSourceStudy.ts index 5344f3cb..20608257 100644 --- a/app/views/SourceStudyView/hooks/useDeleteSourceStudy.ts +++ b/app/views/SourceStudyView/hooks/useDeleteSourceStudy.ts @@ -1,4 +1,4 @@ -import { useAuthentication } from "@databiosphere/findable-ui/lib/hooks/useAuthentication/useAuthentication"; +import { useToken } from "@databiosphere/findable-ui/lib/hooks/authentication/token/useToken"; import Router from "next/router"; import { useCallback } from "react"; import { API } from "../../../apis/catalog/hca-atlas-tracker/common/api"; @@ -18,7 +18,7 @@ export interface UseDeleteSourceStudy { export const useDeleteSourceStudy = ( pathParameter: PathParameter ): UseDeleteSourceStudy => { - const { token } = useAuthentication(); + const { token } = useToken(); const onDelete = useCallback(async (): Promise => { const res = await fetchResource( diff --git a/package-lock.json b/package-lock.json index df5c3cf2..d3c33359 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "hca-atlas-tracker", "version": "1.0.0", "dependencies": { - "@databiosphere/findable-ui": "19.0.0", + "@databiosphere/findable-ui": "20.0.0", "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", "@hookform/resolvers": "^3.3.4", @@ -23,6 +23,7 @@ "isomorphic-dompurify": "0.24.0", "ky": "^1.7.2", "next": "^14.1.0", + "next-auth": "^4.24.7", "next-compose-plugins": "^2.2.1", "react": "^18.3.1", "react-dom": "^18.3.1", @@ -1769,9 +1770,9 @@ } }, "node_modules/@databiosphere/findable-ui": { - "version": "19.0.0", - "resolved": "https://registry.npmjs.org/@databiosphere/findable-ui/-/findable-ui-19.0.0.tgz", - "integrity": "sha512-mPapPHhB4lB/2ndA0xICQMqMATjLTmIO85scBr/MRxv3fZuLGUB6YRQzPNi0XGSBQArjvVWcrmDTMZczTY0sIQ==", + "version": "20.0.0", + "resolved": "https://registry.npmjs.org/@databiosphere/findable-ui/-/findable-ui-20.0.0.tgz", + "integrity": "sha512-SkkTFw2MM7PdA2vLr+1FINwQ1Tiih/UAddGki5U3v7C+AR9SGxmxyma+dy299pX9r8r1YFfaVPDxIq9m5Pc4yA==", "engines": { "node": "20.10.0" }, @@ -1786,11 +1787,12 @@ "isomorphic-dompurify": "0.24.0", "ky": "^1.7.2", "next": "^14.1.0", + "next-auth": "^4.24.7", "react": "^18.3.1", "react-dom": "^18.3.1", "react-dropzone": "^14.2.3", "react-gtm-module": "2.0.11", - "react-idle-timer": "^5.6.2", + "react-idle-timer": "^5.7.2", "react-window": "1.8.9", "uuid": "8.3.2", "validate.js": "^0.13.1" @@ -3889,6 +3891,14 @@ "node": ">= 8" } }, + "node_modules/@panva/hkdf": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@panva/hkdf/-/hkdf-1.2.1.tgz", + "integrity": "sha512-6oclG6Y3PiDFcoyk8srjLfVKyMfVCKJ27JwNPViuXziFpmdz+MZnZN/aKY0JGXgYuO/VghU0jcOAZgWXZ1Dmrw==", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -7353,6 +7363,14 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, + "node_modules/cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/copy-to-clipboard": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.1.tgz", @@ -12459,6 +12477,14 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/jose": { + "version": "4.15.9", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.9.tgz", + "integrity": "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -13952,6 +13978,33 @@ } } }, + "node_modules/next-auth": { + "version": "4.24.7", + "resolved": "https://registry.npmjs.org/next-auth/-/next-auth-4.24.7.tgz", + "integrity": "sha512-iChjE8ov/1K/z98gdKbn2Jw+2vLgJtVV39X+rCP5SGnVQuco7QOr19FRNGMIrD8d3LYhHWV9j9sKLzq1aDWWQQ==", + "dependencies": { + "@babel/runtime": "^7.20.13", + "@panva/hkdf": "^1.0.2", + "cookie": "^0.5.0", + "jose": "^4.15.5", + "oauth": "^0.9.15", + "openid-client": "^5.4.0", + "preact": "^10.6.3", + "preact-render-to-string": "^5.1.19", + "uuid": "^8.3.2" + }, + "peerDependencies": { + "next": "^12.2.5 || ^13 || ^14", + "nodemailer": "^6.6.5", + "react": "^17.0.2 || ^18", + "react-dom": "^17.0.2 || ^18" + }, + "peerDependenciesMeta": { + "nodemailer": { + "optional": true + } + } + }, "node_modules/next-compose-plugins": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/next-compose-plugins/-/next-compose-plugins-2.2.1.tgz", @@ -15433,6 +15486,11 @@ "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.7.tgz", "integrity": "sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==" }, + "node_modules/oauth": { + "version": "0.9.15", + "resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz", + "integrity": "sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA==" + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -15441,6 +15499,14 @@ "node": ">=0.10.0" } }, + "node_modules/object-hash": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.2.0.tgz", + "integrity": "sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==", + "engines": { + "node": ">= 6" + } + }, "node_modules/object-inspect": { "version": "1.13.1", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", @@ -15557,6 +15623,14 @@ "integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==", "dev": true }, + "node_modules/oidc-token-hash": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/oidc-token-hash/-/oidc-token-hash-5.0.3.tgz", + "integrity": "sha512-IF4PcGgzAr6XXSff26Sk/+P4KZFJVuHAJZj3wgO3vX2bMdNVp/QXTP3P7CEm9V1IdG8lDLY3HhiqpsE/nOwpPw==", + "engines": { + "node": "^10.13.0 || >=12.0.0" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -15581,6 +15655,36 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/openid-client": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/openid-client/-/openid-client-5.7.1.tgz", + "integrity": "sha512-jDBPgSVfTnkIh71Hg9pRvtJc6wTwqjRkN88+gCFtYWrlP4Yx2Dsrow8uPi3qLr/aeymPF3o2+dS+wOpglK04ew==", + "dependencies": { + "jose": "^4.15.9", + "lru-cache": "^6.0.0", + "object-hash": "^2.2.0", + "oidc-token-hash": "^5.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/openid-client/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/openid-client/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", @@ -16092,6 +16196,31 @@ "integrity": "sha512-i/hbxIE9803Alj/6ytL7UHQxRvZkI9O4Sy+J3HGc4F4oo/2eQAjTSNJ0bfxyse3bH0nuVesCk+3IRLaMtG3H6w==", "dev": true }, + "node_modules/preact": { + "version": "10.25.4", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.25.4.tgz", + "integrity": "sha512-jLdZDb+Q+odkHJ+MpW/9U5cODzqnB+fy2EiHSZES7ldV5LK7yjlVzTp7R8Xy6W6y75kfK8iWYtFVH7lvjwrCMA==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + } + }, + "node_modules/preact-render-to-string": { + "version": "5.2.6", + "resolved": "https://registry.npmjs.org/preact-render-to-string/-/preact-render-to-string-5.2.6.tgz", + "integrity": "sha512-JyhErpYOvBV1hEPwIxc/fHWXPfnEGdRKxc8gFdAZ7XV4tlzyzG847XAyEZqoDnynP88akM4eaHcSOzNcLWFguw==", + "dependencies": { + "pretty-format": "^3.8.0" + }, + "peerDependencies": { + "preact": ">=10" + } + }, + "node_modules/preact-render-to-string/node_modules/pretty-format": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-3.8.0.tgz", + "integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew==" + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", diff --git a/package.json b/package.json index f41327a8..1f906636 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "migrate": "ts-node -O '{\"module\": \"commonjs\"}' ./scripts/migration-runner.ts -j ts" }, "dependencies": { - "@databiosphere/findable-ui": "19.0.0", + "@databiosphere/findable-ui": "20.0.0", "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", "@hookform/resolvers": "^3.3.4", @@ -31,6 +31,7 @@ "isomorphic-dompurify": "0.24.0", "ky": "^1.7.2", "next": "^14.1.0", + "next-auth": "^4.24.7", "next-compose-plugins": "^2.2.1", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/pages/_app.tsx b/pages/_app.tsx index 006c4735..39a4ea4c 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -8,9 +8,9 @@ import { Floating } from "@databiosphere/findable-ui/lib/components/Layout/compo import { Footer } from "@databiosphere/findable-ui/lib/components/Layout/components/Footer/footer"; import { Header as DXHeader } from "@databiosphere/findable-ui/lib/components/Layout/components/Header/header"; import { Main as DXMain } from "@databiosphere/findable-ui/lib/components/Layout/components/Main/main"; -import { AuthProvider } from "@databiosphere/findable-ui/lib/providers/authentication"; import { ConfigProvider as DXConfigProvider } from "@databiosphere/findable-ui/lib/providers/config"; import { ExploreStateProvider } from "@databiosphere/findable-ui/lib/providers/exploreState"; +import { GoogleSignInAuthenticationProvider } from "@databiosphere/findable-ui/lib/providers/googleSignInAuthentication/provider"; import { LayoutStateProvider } from "@databiosphere/findable-ui/lib/providers/layoutState"; import { SystemStatusProvider } from "@databiosphere/findable-ui/lib/providers/systemStatus"; import { createAppTheme } from "@databiosphere/findable-ui/lib/theme/theme"; @@ -56,7 +56,7 @@ function MyApp({ Component, pageProps }: AppPropsWithComponent): JSX.Element { - + - + diff --git a/site-config/common/authentication.ts b/site-config/common/authentication.ts new file mode 100644 index 00000000..676edb20 --- /dev/null +++ b/site-config/common/authentication.ts @@ -0,0 +1,15 @@ +import { OAuthProvider } from "@databiosphere/findable-ui/lib/config/entities"; +import { GoogleProfile } from "@databiosphere/findable-ui/lib/providers/googleSignInAuthentication/profile/types"; + +export const OAUTH_GOOGLE_SIGN_IN: Pick< + OAuthProvider, + "authorization" | "userinfo" +> = { + authorization: { + params: { + scope: + "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid", + }, + }, + userinfo: "https://www.googleapis.com/oauth2/v3/userinfo", +}; diff --git a/site-config/hca-atlas-tracker/local/authentication/authentication.ts b/site-config/hca-atlas-tracker/local/authentication/authentication.ts index 47936cad..45fc8f0d 100644 --- a/site-config/hca-atlas-tracker/local/authentication/authentication.ts +++ b/site-config/hca-atlas-tracker/local/authentication/authentication.ts @@ -1,14 +1,19 @@ import { AuthenticationConfig } from "@databiosphere/findable-ui/lib/config/entities"; +import { GOOGLE_SIGN_IN_PROVIDER } from "@databiosphere/findable-ui/lib/providers/googleSignInAuthentication/service/constants"; import * as MDX from "../../../../app/components/common/MDXContent"; +import { OAUTH_GOOGLE_SIGN_IN } from "../../../common/authentication"; + +const CLIENT_ID = + "602867726547-8fggua16ofh4inipdvgnil9brmt3c75b.apps.googleusercontent.com"; export const authenticationConfig: AuthenticationConfig = { - googleGISAuthConfig: { - clientId: - "602867726547-8fggua16ofh4inipdvgnil9brmt3c75b.apps.googleusercontent.com", - googleProfileEndpoint: "https://www.googleapis.com/oauth2/v3/userinfo", - scope: - "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid", - }, + providers: [ + { + ...GOOGLE_SIGN_IN_PROVIDER, + ...OAUTH_GOOGLE_SIGN_IN, + clientId: CLIENT_ID, + }, + ], termsOfService: MDX.LoginTermsOfService({}), text: MDX.LoginText({}), title: "Sign in to your account", diff --git a/site-config/hca-atlas-tracker/local/index/atlasEntityConfig.ts b/site-config/hca-atlas-tracker/local/index/atlasEntityConfig.ts index 702133b4..d8e6e192 100644 --- a/site-config/hca-atlas-tracker/local/index/atlasEntityConfig.ts +++ b/site-config/hca-atlas-tracker/local/index/atlasEntityConfig.ts @@ -1,3 +1,4 @@ +import { ACCESSOR_KEYS } from "@databiosphere/findable-ui/lib/components/TableCreator/common/constants"; import { ComponentConfig, EntityConfig, @@ -11,7 +12,6 @@ import { getAtlasId, } from "../../../../app/apis/catalog/hca-atlas-tracker/common/utils"; import * as C from "../../../../app/components"; -import { COLUMN_VISIBILITY } from "../../../../app/components/Table/features/constants"; import { mapSelectCategoryValue } from "../../../../app/config/utils"; import { formatDateToQuarterYear } from "../../../../app/utils/date-fns"; import * as V from "../../../../app/viewModelBuilders/catalog/hca-atlas-tracker/common/viewModelBuilders"; @@ -208,7 +208,12 @@ export const atlasEntityConfig: EntityConfig = { id: HCA_ATLAS_TRACKER_CATEGORY_KEY.NAME, }, tableOptions: { - initialState: { columnVisibility: COLUMN_VISIBILITY.ROW_POSITION }, + initialState: { + columnVisibility: { + [ACCESSOR_KEYS.ROW_POSITION]: true, + [ACCESSOR_KEYS.SELECT]: false, + }, + }, }, } as ListConfig, listView: { diff --git a/site-config/hca-atlas-tracker/local/index/userEntityConfig.ts b/site-config/hca-atlas-tracker/local/index/userEntityConfig.ts index eddb0ab0..f361dde3 100644 --- a/site-config/hca-atlas-tracker/local/index/userEntityConfig.ts +++ b/site-config/hca-atlas-tracker/local/index/userEntityConfig.ts @@ -1,3 +1,4 @@ +import { ACCESSOR_KEYS } from "@databiosphere/findable-ui/lib/components/TableCreator/common/constants"; import { ComponentConfig, EntityConfig, @@ -8,7 +9,6 @@ import { EXPLORE_MODE } from "@databiosphere/findable-ui/lib/hooks/useExploreMod import { HCAAtlasTrackerUser } from "../../../../app/apis/catalog/hca-atlas-tracker/common/entities"; import { getUserId } from "../../../../app/apis/catalog/hca-atlas-tracker/common/utils"; import * as C from "../../../../app/components"; -import { COLUMN_VISIBILITY } from "../../../../app/components/Table/features/constants"; import * as V from "../../../../app/viewModelBuilders/catalog/hca-atlas-tracker/common/viewModelBuilders"; import { HCA_ATLAS_TRACKER_CATEGORY_KEY, @@ -129,7 +129,12 @@ export const userEntityConfig: EntityConfig = { id: HCA_ATLAS_TRACKER_CATEGORY_KEY.FULL_NAME, }, tableOptions: { - initialState: { columnVisibility: COLUMN_VISIBILITY.ROW_POSITION }, + initialState: { + columnVisibility: { + [ACCESSOR_KEYS.ROW_POSITION]: true, + [ACCESSOR_KEYS.SELECT]: false, + }, + }, }, } as ListConfig, listView: { diff --git a/site-config/hca-atlas-tracker/prod/authentication/authentication.ts b/site-config/hca-atlas-tracker/prod/authentication/authentication.ts index 47936cad..45fc8f0d 100644 --- a/site-config/hca-atlas-tracker/prod/authentication/authentication.ts +++ b/site-config/hca-atlas-tracker/prod/authentication/authentication.ts @@ -1,14 +1,19 @@ import { AuthenticationConfig } from "@databiosphere/findable-ui/lib/config/entities"; +import { GOOGLE_SIGN_IN_PROVIDER } from "@databiosphere/findable-ui/lib/providers/googleSignInAuthentication/service/constants"; import * as MDX from "../../../../app/components/common/MDXContent"; +import { OAUTH_GOOGLE_SIGN_IN } from "../../../common/authentication"; + +const CLIENT_ID = + "602867726547-8fggua16ofh4inipdvgnil9brmt3c75b.apps.googleusercontent.com"; export const authenticationConfig: AuthenticationConfig = { - googleGISAuthConfig: { - clientId: - "602867726547-8fggua16ofh4inipdvgnil9brmt3c75b.apps.googleusercontent.com", - googleProfileEndpoint: "https://www.googleapis.com/oauth2/v3/userinfo", - scope: - "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid", - }, + providers: [ + { + ...GOOGLE_SIGN_IN_PROVIDER, + ...OAUTH_GOOGLE_SIGN_IN, + clientId: CLIENT_ID, + }, + ], termsOfService: MDX.LoginTermsOfService({}), text: MDX.LoginText({}), title: "Sign in to your account",