11import { useCollectionSync } from '@furystack/entity-sync-client'
22import { createComponent , NestedRouteLink , Shade } from '@furystack/shades'
3- import { Button , Loader , PageContainer , PageHeader , Paper } from '@furystack/shades-common-components'
4- import { Service , Stack } from 'common'
3+ import { Button , Icon , icons , Loader , PageContainer , PageHeader , Paper } from '@furystack/shades-common-components'
4+ import { GitHubRepository , Service , Stack } from 'common'
55
6+ import { RepositoryTable } from '../../components/repository-table.js'
67import { ServiceTable } from '../../components/service-table.js'
78import { StackSelector } from '../../components/stack-selector.js'
89
@@ -24,6 +25,11 @@ export const Dashboard = Shade({
2425 } )
2526 const services = servicesState . status === 'synced' || servicesState . status === 'cached' ? servicesState . data : [ ]
2627
28+ const reposState = useCollectionSync ( options , GitHubRepository , {
29+ filter : activeStackName ? { stackName : { $eq : activeStackName } } : undefined ,
30+ } )
31+ const repos = reposState . status === 'synced' || reposState . status === 'cached' ? reposState . data : [ ]
32+
2733 const isLoading = stacksState . status === 'connecting'
2834
2935 if ( isLoading ) {
@@ -72,6 +78,15 @@ export const Dashboard = Shade({
7278 selectedStack = { activeStackName }
7379 onSelect = { ( name ) => setSelectedStackName ( name ) }
7480 />
81+ { activeStackName ? (
82+ < Button
83+ variant = "outlined"
84+ onclick = { ( ) => history . pushState ( null , '' , `/stacks/${ activeStackName } /edit` ) }
85+ startIcon = { < Icon icon = { icons . edit } size = "small" /> }
86+ >
87+ Edit Stack
88+ </ Button >
89+ ) : null }
7590 { activeStackName ? (
7691 < Button
7792 variant = "contained"
@@ -84,6 +99,16 @@ export const Dashboard = Shade({
8499 }
85100 />
86101 < Paper >
102+ < div
103+ style = { {
104+ display : 'flex' ,
105+ justifyContent : 'space-between' ,
106+ alignItems : 'center' ,
107+ marginBottom : '12px' ,
108+ } }
109+ >
110+ < h3 style = { { margin : '0' , fontSize : '16px' } } > Services</ h3 >
111+ </ div >
87112 { services . length === 0 ? (
88113 < div style = { { textAlign : 'center' , padding : '32px' } } >
89114 < p style = { { opacity : '0.5' , marginBottom : '16px' } } > No services in this stack yet.</ p >
@@ -104,6 +129,44 @@ export const Dashboard = Shade({
104129 />
105130 ) }
106131 </ Paper >
132+ < Paper style = { { marginTop : '16px' } } >
133+ < div
134+ style = { {
135+ display : 'flex' ,
136+ justifyContent : 'space-between' ,
137+ alignItems : 'center' ,
138+ marginBottom : '12px' ,
139+ } }
140+ >
141+ < h3 style = { { margin : '0' , fontSize : '16px' } } > Repositories</ h3 >
142+ { activeStackName ? (
143+ < Button
144+ variant = "outlined"
145+ onclick = { ( ) => history . pushState ( null , '' , `/repositories/create/${ activeStackName } ` ) }
146+ >
147+ Add Repository
148+ </ Button >
149+ ) : null }
150+ </ div >
151+ { repos . length === 0 ? (
152+ < div style = { { textAlign : 'center' , padding : '32px' } } >
153+ < p style = { { opacity : '0.5' , marginBottom : '16px' } } > No repositories in this stack yet.</ p >
154+ { activeStackName ? (
155+ < Button
156+ variant = "outlined"
157+ onclick = { ( ) => history . pushState ( null , '' , `/repositories/create/${ activeStackName } ` ) }
158+ >
159+ Add Repository
160+ </ Button >
161+ ) : null }
162+ </ div >
163+ ) : (
164+ < RepositoryTable
165+ repositories = { repos }
166+ onEdit = { ( repoId : string ) => history . pushState ( null , '' , `/repositories/${ repoId } ` ) }
167+ />
168+ ) }
169+ </ Paper >
107170 </ PageContainer >
108171 )
109172 } ,
0 commit comments