1- import { JSX , useContext , Switch , Match , createMemo } from "solid-js" ;
1+ import {
2+ JSX ,
3+ useContext ,
4+ Switch ,
5+ Match ,
6+ createMemo ,
7+ Show ,
8+ createSignal ,
9+ } from "solid-js" ;
210import { OrgName } from "../components/OrgName" ;
311import { OrgTabs } from "../components/OrgTabs" ;
412
513import { UserContext } from "../contexts/UserContext" ;
14+ import { Portal } from "solid-js/web" ;
15+ import { NavbarOrganizationSelector } from "./NavbarOrganizationSelector" ;
16+ import NewDatasetModal from "../components/NewDatasetModal" ;
17+ import { NavbarDatasetSelector } from "./NavbarDatasetSelector" ;
618
719interface DashboardLayoutProps {
820 children ?: JSX . Element ;
@@ -11,6 +23,14 @@ interface DashboardLayoutProps {
1123export const OrganizationLayout = ( props : DashboardLayoutProps ) => {
1224 const userContext = useContext ( UserContext ) ;
1325
26+ const [ newDatasetModalOpen , setNewDatasetModalOpen ] =
27+ createSignal < boolean > ( false ) ;
28+
29+ const orgDatasets = createMemo ( ( ) => {
30+ const datasets = userContext . orgDatasets ?.( ) ;
31+ return datasets || [ ] ;
32+ } ) ;
33+
1434 const currentUserRole = createMemo ( ( ) => {
1535 return (
1636 userContext . user ( ) . user_orgs . find ( ( val ) => {
@@ -20,47 +40,84 @@ export const OrganizationLayout = (props: DashboardLayoutProps) => {
2040 } ) ;
2141
2242 return (
23- < div class = "flex grow flex-col bg-neutral-100 text-black" >
24- < Switch >
25- < Match when = { userContext . user ( ) . orgs . length === 0 } >
26- < div class = "flex flex-1 items-center justify-center overflow-y-auto" >
27- < div class = "flex flex-col items-center" >
28- < h1 class = "text-3xl" >
29- You are currently not part of any organization
30- </ h1 >
31- < p > Create a new organization using the button in the sidebar.</ p >
43+ < >
44+ < Portal mount = { document . body } >
45+ < NewDatasetModal
46+ isOpen = { newDatasetModalOpen }
47+ closeModal = { ( ) => {
48+ setNewDatasetModalOpen ( false ) ;
49+ } }
50+ />
51+ </ Portal >
52+ { /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */ }
53+ < Portal mount = { document . querySelector ( "#organization-slot" ) ! } >
54+ < div class = "flex flex-row content-center items-center" >
55+ < NavbarOrganizationSelector />
56+ < span class = "ml-2 font-bold text-neutral-600" > /</ span >
57+ </ div >
58+ </ Portal >
59+ { /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */ }
60+ < Portal mount = { document . querySelector ( "#dataset-slot" ) ! } >
61+ < div class = "ml-1 flex flex-row" >
62+ < Show when = { orgDatasets ( ) . length > 0 } >
63+ < NavbarDatasetSelector />
64+ </ Show >
65+ < Show when = { orgDatasets ( ) . length == 0 } >
66+ < button
67+ class = "flex content-center items-center rounded bg-magenta-500 px-3 py-1 text-sm font-semibold text-white"
68+ onClick = { ( ) => setNewDatasetModalOpen ( true ) }
69+ >
70+ Create Dataset +
71+ </ button >
72+ </ Show >
73+ </ div >
74+ </ Portal >
75+ < div class = "flex grow flex-col bg-neutral-100 text-black" >
76+ < Switch >
77+ < Match when = { userContext . user ( ) . orgs . length === 0 } >
78+ < div class = "flex flex-1 items-center justify-center overflow-y-auto" >
79+ < div class = "flex flex-col items-center" >
80+ < h1 class = "text-3xl" >
81+ You are currently not part of any organization
82+ </ h1 >
83+ < p >
84+ Create a new organization using the profile button on the
85+ right side of the navigation bar.
86+ </ p >
87+ </ div >
3288 </ div >
33- </ div >
34- </ Match >
35- < Match when = { currentUserRole ( ) < 1 } >
36- < div class = "mt-4 flex h-full w-full items- center justify-center overflow-y-auto " >
37- < div class = "text-center " >
38- < h1 class = "text-3xl font-semibold text-neutral-800" >
39- You do not have access to this page
40- </ h1 >
41- < p class = "mt-4 max-w-screen-2xl px-4 text-neutral-700" >
42- You must be an admin or owner to access this page. If you
43- believe this is an error, please contact one of your
44- organization's users with a role of admin or owner and ask them
45- to grant you access.
46- </ p >
89+ </ Match >
90+ < Match when = { currentUserRole ( ) < 1 } >
91+ < div class = "mt-4 flex h-full w-full items-center justify-center overflow-y-auto" >
92+ < div class = "text- center" >
93+ < h1 class = "text-3xl font-semibold text-neutral-800 " >
94+ You do not have access to this page
95+ </ h1 >
96+ < p class = "mt-4 max-w-screen-2xl px-4 text-neutral-700" >
97+ You must be an admin or owner to access this page. If you
98+ believe this is an error, please contact one of your
99+ organization's users with a role of admin or owner and ask
100+ them to grant you access.
101+ </ p >
102+ </ div >
47103 </ div >
48- </ div >
49- </ Match >
50- < Match
51- when = {
52- currentUserRole ( ) >= 1 && ( userContext . user ( ) . orgs . length ?? 0 ) > 0
53- }
54- >
55- < div class = "w-full overflow-y-auto px-8" >
56- < div class = "mb-2 mt-6 flex flex-col space-y-3 border-b" >
57- < OrgName />
58- < OrgTabs />
104+ </ Match >
105+ < Match
106+ when = {
107+ currentUserRole ( ) >= 1 &&
108+ ( userContext . user ( ) . orgs . length ?? 0 ) > 0
109+ }
110+ >
111+ < div class = "w-full overflow-y-auto px-8" >
112+ < div class = "mb-2 mt-6 flex flex-col space-y-3 border-b" >
113+ < OrgName />
114+ < OrgTabs />
115+ </ div >
116+ < div > { props . children } </ div >
59117 </ div >
60- < div > { props . children } </ div >
61- </ div >
62- </ Match >
63- </ Switch >
64- </ div >
118+ </ Match >
119+ </ Switch >
120+ </ div >
121+ </ >
65122 ) ;
66123} ;
0 commit comments