-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#83: unify selectors: defining a content type's set of queries (with …
…optional variable-getter, either as an object or an array), props-processors and page-components in one place. Single export/import.
- Loading branch information
Showing
12 changed files
with
142 additions
and
129 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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import {Context} from "../pages/[[...contentPath]]"; | ||
|
||
import {appKey} from "../enonic-connection-config"; | ||
|
||
import PersonPage from "../components/pagetypes/Person"; | ||
import MoviePage from "../components/pagetypes/Movie"; | ||
import ListPage from "../components/pagetypes/List"; | ||
|
||
import personQuery from "./queries/getPerson"; | ||
import movieQuery from "./queries/getMovie"; | ||
import listQuery, {getListVariables} from "./queries/getList"; | ||
|
||
import processPersonProps from "./propsProcessors/processPerson"; | ||
import processMovieProps from "./propsProcessors/processMovie"; | ||
import processFolderProps from "./propsProcessors/processFolder"; | ||
|
||
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////// Types: | ||
|
||
export type PropsProcessor = (content: any, context?: Context) => any | ||
|
||
export type VariablesGetter = (path: string, context?: Context) => { | ||
path: string, | ||
[variables: string]: any | ||
}; | ||
|
||
export type PageComponent = (content:any) => JSX.Element | ||
|
||
export type SelectedQueryMaybeVariablesFunc = string | | ||
{ query:string, variables:VariablesGetter } | | ||
[ string, VariablesGetter ] | ||
|
||
export type TypeSelection = { | ||
query?: SelectedQueryMaybeVariablesFunc, | ||
props?: PropsProcessor, | ||
page?: PageComponent | ||
|
||
} | ||
|
||
export type Selector = { | ||
[fullContentType:string]: TypeSelection | ||
} | ||
|
||
|
||
///////////////////////////////////////////////////////////////////////// Selector: | ||
|
||
const selector: Selector = { | ||
|
||
[`${appKey}:person`]: { | ||
query: personQuery, | ||
props: processPersonProps, | ||
page: PersonPage | ||
}, | ||
|
||
[`${appKey}:movie`]: { | ||
query: movieQuery, | ||
props: processMovieProps, | ||
page: MoviePage | ||
}, | ||
|
||
'base:folder': { | ||
query: [ listQuery, getListVariables ], | ||
props: processFolderProps, | ||
page: ListPage | ||
} | ||
}; | ||
|
||
|
||
export default selector; |
Oops, something went wrong.