-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add first-pass model for state tree (#20)
- Loading branch information
1 parent
017c993
commit 660b639
Showing
4 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { JSONSchema7 } from 'json-schema' | ||
|
||
// meta.citations | ||
interface Citation { | ||
name: string | ||
URL: string | ||
email: string | ||
} | ||
|
||
// meta.contributors | ||
interface User { | ||
id: string | ||
fullName: string | ||
email: string | ||
} | ||
|
||
interface Meta { | ||
accessURL: string | ||
accrualPeriodicity: string | ||
citations: Citation[] | ||
contributors: User[] | ||
description: string | ||
downloadURL: string | ||
homeURL: string | ||
identifier: string | ||
keywords: string[] | ||
language: string[] | ||
license: { | ||
type: string | ||
URL: string | ||
} | ||
readmeURL: string | ||
title: string | ||
theme: string[] | ||
version: string | ||
} | ||
|
||
export interface Commit { | ||
path: string | ||
message: string | ||
author: string | ||
timestamp: Date | ||
} | ||
|
||
export default interface Dataset { | ||
meta?: Meta | ||
schema?: JSONSchema7 | ||
body?: object | [] | ||
commit?: Commit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { RouterState } from 'react-router-redux' | ||
import Dataset, { Commit } from './dataset' | ||
|
||
enum ApiConnection { | ||
neverConnected = 0, | ||
connected = 1, | ||
connectionFailure = -1 | ||
} | ||
|
||
enum ModalType { | ||
CreateDataset, | ||
AddDataset, | ||
} | ||
|
||
type Modal = | ||
| { | ||
type: ModalType.CreateDataset | ||
dirPath?: string | ||
bodyPath?: string | ||
} | ||
| { | ||
type: ModalType.AddDataset | ||
initialURL?: string | null | ||
} | ||
|
||
interface UI { | ||
apiConnection: ApiConnection | ||
showDatasetList: boolean | ||
errorMessage: string | null | ||
message: string | null | ||
hasAcceptedTOS: boolean | ||
hasSetPeername: boolean | ||
modal: Modal | ||
showDiff: boolean | ||
sidebarWidth: boolean | ||
} | ||
|
||
// currently selected dataset, tab, dataset component, commit, etc | ||
interface Selections { | ||
peername: string | ||
name: string | null | ||
activeTab: string | ||
component: string | ||
commit: string | ||
} | ||
|
||
// info about the current value of a list being paginated | ||
interface PageInfo { | ||
isFetching: boolean | ||
pageCount: number | ||
fetchedAll: boolean | ||
error: string | ||
} | ||
|
||
// dataset summary info to show in dataset list | ||
interface DatasetSummary { | ||
title: string | ||
peername: string | ||
name: string | ||
hash: string | ||
isLinked: boolean | ||
changed: boolean | ||
} | ||
|
||
// list of local datasets | ||
interface MyDatasets { | ||
pageInfo: PageInfo | ||
value: DatasetSummary[] | ||
filter: string // filter string from ui | ||
} | ||
|
||
// info about a dataset component as compared the same component in previous commit | ||
interface ComponentStatus { | ||
filepath: string | ||
status: 'changed' | 'unchanged' | 'removed' | 'added' | ||
errors: object[] | ||
warnings: object[] | ||
} | ||
|
||
interface Pages { | ||
[key: string]: PageInfo | ||
} | ||
|
||
interface DatasetComparison { | ||
path: string | ||
prevPath: string | ||
peername: string | ||
name: string | ||
pages: Pages | ||
diff: object | ||
value: Dataset | ||
status: { | ||
meta: ComponentStatus | ||
schema: ComponentStatus | ||
body: ComponentStatus | ||
} | ||
} | ||
|
||
interface WorkingDataset extends DatasetComparison { | ||
history: { | ||
pageInfo: PageInfo | ||
value: Commit[] | ||
} | ||
} | ||
|
||
export default interface Store { | ||
session: string | ||
ui: UI | ||
selections: Selections | ||
myDatasets: MyDatasets | ||
workingDataset: WorkingDataset | ||
workingHistory: DatasetComparison | ||
router: RouterState | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters