diff --git a/.github/workflows/pre-merge.yml b/.github/workflows/pre-merge.yml index af38676a..ce8a7194 100644 --- a/.github/workflows/pre-merge.yml +++ b/.github/workflows/pre-merge.yml @@ -15,10 +15,11 @@ env: END_SESSION_URL: ${{secrets.END_SESSION_URL}} REFRESH_TOKEN_URL: ${{secrets.REFRESH_TOKEN_URL}} NEXT_PUBLIC_BACKEND_URL: ${{secrets.NEXT_PUBLIC_BACKEND_URL_DS}} + BACKEND_URL: ${{secrets.BACKEND_URL}} BACKEND_GRAPHQL_URL: ${{secrets.BACKEND_GRAPHQL_URL_DS}} NEXT_PUBLIC_ENABLE_ACCESSMODEL: ${{secrets.NEXT_PUBLIC_ENABLE_ACCESSMODEL_DS}} NEXT_PUBLIC_BACKEND_GRAPHQL_URL: ${{secrets.NEXT_PUBLIC_BACKEND_GRAPHQL_URL_DS}} - + jobs: build: runs-on: ubuntu-latest diff --git a/app/[locale]/dashboard/[entityType]/[entitySlug]/layout.tsx b/app/[locale]/dashboard/[entityType]/[entitySlug]/layout.tsx index d05cf6eb..fd8d5b62 100644 --- a/app/[locale]/dashboard/[entityType]/[entitySlug]/layout.tsx +++ b/app/[locale]/dashboard/[entityType]/[entitySlug]/layout.tsx @@ -3,12 +3,15 @@ import React from 'react'; import { notFound, useParams } from 'next/navigation'; import { SidebarNavItem } from '@/types'; +import { useQuery } from '@tanstack/react-query'; +import { GraphQL } from '@/lib/api'; import { cn } from '@/lib/utils'; import BreadCrumbs from '@/components/BreadCrumbs'; import { DashboardNav } from '../../components/dashboard-nav'; import { MobileDashboardNav } from '../../components/mobile-dashboard-nav'; import styles from '../../components/styles.module.scss'; +import { getDataSpaceDetailsQryDoc, getOrgDetailsQryDoc } from './schema'; interface DashboardLayoutProps { children?: React.ReactNode; @@ -18,6 +21,17 @@ export default function OrgDashboardLayout({ children }: DashboardLayoutProps) { const [isOpened, setIsOpened] = React.useState(false); const params = useParams<{ entityType: string; entitySlug: string }>(); + const EntityDetailsQryRes: { data: any; isLoading: boolean; error: any } = + useQuery([`entity_details_${params.entityType}`], () => + GraphQL( + params.entityType === 'organization' + ? getOrgDetailsQryDoc + : getDataSpaceDetailsQryDoc, + {}, + { filters: { slug: params.entitySlug } } + ) + ); + if ( process.env.NEXT_PUBLIC_DATASPACE_FEATURE_ENABLED !== 'true' && params.entityType === 'dataspace' @@ -56,7 +70,11 @@ export default function OrgDashboardLayout({ children }: DashboardLayoutProps) { }, { href: '', - label: `${params.entitySlug}`, + label: + (params.entityType === 'organization' + ? EntityDetailsQryRes.data?.organisations[0] + : EntityDetailsQryRes.data?.dataspaces[0] + )?.name || params.entitySlug, }, ]} /> @@ -66,7 +84,14 @@ export default function OrgDashboardLayout({ children }: DashboardLayoutProps) { ' bg-surfaceDefault p-4 md:flex' )} > - +
{ const params = useParams<{ entityType: string }>(); - const allOrganizationsList: { + const allEntitiesList: { data: any; isLoading: boolean; error: any; isError: boolean; - } = useQuery([`all_organizations_list_page`], () => + } = useQuery([`all_enitites_list_${params.entityType}`], () => GraphQL( - allOrganizationsListingDoc, + params.entityType === 'organization' + ? allOrganizationsListingDoc + : allDataSpacesListingDoc, { // Entity Headers if present }, - { - options: { - skip: params.entityType !== 'organization', - }, - } - ) - ); - - const allDataSpacesList: { - data: any; - isLoading: boolean; - error: any; - isError: boolean; - } = useQuery([`all_dataspaces_list_page`], () => - GraphQL( - allDataSpacesListingDoc, - { - // Entity Headers if present - }, - { - options: { - skip: params.entityType !== 'dataspace', - }, - } + [] ) ); @@ -88,48 +68,21 @@ const Page = () => {
- {allDataSpacesList.isLoading || allOrganizationsList.isLoading ? ( + {allEntitiesList.isLoading ? ( ) : (
{[ ...(params.entityType === 'organization' - ? allOrganizationsList.data.organisations - : allDataSpacesList.data.dataspaces), - ]?.map((orgItem) => ( -
- -
- {'Organization -
- - {/* - Manage Datasets - - - Manage Consumers - */} - -
- {orgItem.name} -
-
+ ? allEntitiesList.data.organisations + : allEntitiesList.data.dataspaces), + ]?.map((entityItem) => ( + ))}
@@ -146,3 +99,50 @@ const Page = () => { }; export default Page; + +const EntityCard = ({ key, entityItem, params }: any) => { + const [isImageValid, setIsImageValid] = useState(() => { + return entityItem.logo ? true : false; + }); + return ( +
+
+ +
+ {isImageValid ? ( + {`${entityItem.name} { + setIsImageValid(false); + }} + className="object-contain" + /> + ) : ( + {`fallback + )} +
+ +
+
+ + {entityItem.name} + +
+
+ ); +}; diff --git a/app/[locale]/dashboard/components/dashboard-nav.tsx b/app/[locale]/dashboard/components/dashboard-nav.tsx index c8b8cf41..a242d693 100644 --- a/app/[locale]/dashboard/components/dashboard-nav.tsx +++ b/app/[locale]/dashboard/components/dashboard-nav.tsx @@ -1,6 +1,6 @@ 'use client'; -import React from 'react'; +import { useEffect, useState } from 'react'; import Image from 'next/image'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; @@ -17,11 +17,26 @@ interface DashboardNavProps { } export function DashboardNav({ items, - entitySlug, -}: DashboardNavProps & { entitySlug?: string }) { - const [isCollapsed, setIsCollapsed] = React.useState(false); + entityDetails, +}: DashboardNavProps & { entityDetails?: any }) { + const [isCollapsed, setIsCollapsed] = useState(false); + + const [isImageValid, setIsImageValid] = useState(() => { + return entityDetails?.logo ? true : false; + }); const path = usePathname(); + useEffect(() => { + if ( + entityDetails && + (typeof entityDetails.logo === 'undefined' || entityDetails.logo === null) + ) { + setIsImageValid(false); + } else { + setIsImageValid(true); + } + }, [entityDetails]); + useMetaKeyPress('b', () => setIsCollapsed((e) => !e)); if (items && !items.length) { @@ -39,17 +54,31 @@ export function DashboardNav({ )} >