@@ -30,6 +30,7 @@ import { AppDetails, AuthenticationContext } from './types'
3030import { PaneDefinition } from 'pane-registry'
3131import * as debug from '../debug'
3232import { graph , namedNode , NamedNode , Namespace , serialize , st , Statement , sym , UpdateManager } from 'rdflib'
33+ import { textInputStyle , buttonStyle , commentStyle } from '../style'
3334
3435export { solidAuthClient }
3536
@@ -658,6 +659,7 @@ export function registrationControl (
658659export function registrationList ( context : AuthenticationContext , options : {
659660 private ?: boolean
660661 public ?: boolean
662+ type ?: NamedNode
661663} ) : Promise < AuthenticationContext > {
662664 const dom = context . dom as HTMLDocument
663665 const div = context . div as HTMLElement
@@ -689,16 +691,13 @@ export function registrationList (context: AuthenticationContext, options: {
689691
690692 for ( let i = 0 ; i < sts . length ; i ++ ) {
691693 const statement : Statement = sts [ i ]
694+ if ( options . type ) { // now check terms:forClass
695+ if ( ! kb . holds ( statement . subject , ns . solid ( 'forClass' ) , options . type , statement . why ) ) {
696+ continue // skip irrelevant ones
697+ }
698+ }
692699 // const cla = statement.subject
693700 const inst = statement . object
694- // if (false) {
695- // const tr = table.appendChild(dom.createElement('tr'))
696- // const anchor = tr.appendChild(dom.createElement('a'))
697- // anchor.setAttribute('href', inst.uri)
698- // anchor.textContent = utils.label(inst)
699- // } else {
700- // }
701-
702701 table . appendChild ( widgets . personTR ( dom , ns . solid ( 'instance' ) , inst , {
703702 deleteFunction : function ( _x ) {
704703 kb . updater . update ( [ statement ] , [ ] , function ( uri , ok , errorBody ) {
@@ -710,7 +709,7 @@ export function registrationList (context: AuthenticationContext, options: {
710709 } )
711710 }
712711 } ) )
713- }
712+ } // registrationList
714713
715714 /*
716715 //const containers = kb.each(theClass, ns.solid('instanceContainer'));
@@ -915,7 +914,7 @@ function signInOrSignUpBox (
915914 debug . log ( 'widgets.signInOrSignUpBox' )
916915 box . setUserCallback = setUserCallback
917916 box . setAttribute ( 'class' , magicClassName )
918- box . style = 'display:flex;'
917+ ; ( box as any ) . style = 'display:flex;' // @@ fix all typecasts like this
919918
920919 // Sign in button with PopUP
921920 const signInPopUpButton = dom . createElement ( 'input' ) // multi
@@ -1204,29 +1203,22 @@ export function selectWorkspace (
12041203 let newBase = null
12051204
12061205 // A workspace specifically defined in the private preference file:
1207- let w = kb
1208- . statementsMatching (
1209- id ,
1210- ns . space ( 'workspace' ) , // Only trust preference file here
1211- undefined ,
1212- preferencesFile
1213- )
1214- . map ( function ( st ) {
1215- return st . object
1216- } )
1206+ let w = kb . each ( id , ns . space ( 'workspace' ) , undefined , preferencesFile ) // Only trust preference file here
12171207
12181208 // A workspace in a storage in the public profile:
12191209 const storages = kb . each ( id , ns . space ( 'storage' ) ) // @@ No provenance requirement at the moment
1220- storages . map ( function ( s ) {
1221- w = w . concat ( kb . each ( s , ns . ldp ( 'contains' ) ) )
1222- } )
1210+ if ( w . length === 0 && storages ) {
1211+ say ( `You don't seem to have any workspaces. You have ${ storages . length } storage spaces.` )
1212+ storages . map ( function ( s ) {
1213+ w = w . concat ( kb . each ( s , ns . ldp ( 'contains' ) ) )
1214+ } ) . filter ( file => [ 'public' , 'private' ] . includes ( file . id ( ) . toLowerCase ( ) ) )
1215+ }
12231216
12241217 if ( w . length === 1 ) {
12251218 say ( `Workspace used: ${ w [ 0 ] . uri } ` ) // @@ allow user to see URI
12261219 newBase = figureOutBase ( w [ 0 ] )
12271220 // callbackWS(w[0], newBase)
12281221 } else if ( w . length === 0 ) {
1229- say ( `You don't seem to have any workspaces. You have ${ storages . length } storage spaces.` )
12301222 }
12311223
12321224 // Prompt for ws selection or creation
@@ -1243,10 +1235,13 @@ export function selectWorkspace (
12431235 box . appendChild ( dom . createElement ( 'hr' ) ) // @@
12441236
12451237 const p = box . appendChild ( dom . createElement ( 'p' ) )
1246- p . textContent = `Where would you like to store the data for the ${ noun } ? Give the URL of the directory where you would like the data stored.`
1238+ ; ( p as any ) . style = commentStyle
1239+ p . textContent = `Where would you like to store the data for the ${ noun } ?
1240+ Give the URL of the directory where you would like the data stored.`
12471241 // @@ TODO Remove the need to cast baseField to any
12481242 const baseField : any = box . appendChild ( dom . createElement ( 'input' ) )
12491243 baseField . setAttribute ( 'type' , 'text' )
1244+ ; ( baseField as any ) . style = textInputStyle
12501245 baseField . size = 80 // really a string
12511246 baseField . label = 'base URL'
12521247 baseField . autocomplete = 'on'
@@ -1260,6 +1255,7 @@ export function selectWorkspace (
12601255 box . appendChild ( dom . createElement ( 'br' ) ) // @@
12611256
12621257 const button = box . appendChild ( dom . createElement ( 'button' ) )
1258+ ; ( button as any ) . style = buttonStyle
12631259 button . textContent = `Start new ${ noun } at this URI`
12641260 button . addEventListener ( 'click' , function ( _event ) {
12651261 let newBase = baseField . value
@@ -1294,10 +1290,8 @@ export function selectWorkspace (
12941290 tr . appendChild ( col1 )
12951291 }
12961292 col2 = dom . createElement ( 'td' )
1297- style = kb . any ( ws , ns . ui ( 'style' ) )
1298- if ( style ) {
1299- style = style . value
1300- } else {
1293+ style = kb . anyValue ( ws , ns . ui ( 'style' ) )
1294+ if ( ! style ) {
13011295 // Otherwise make up arbitrary colour
13021296 const hash = function ( x ) {
13031297 return x . split ( '' ) . reduce ( function ( a , b ) {
0 commit comments