-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #361 from OpenCatalogi/feautre/OP-91/headerRefactor
feautre/OP-91/headerRefactor
- Loading branch information
Showing
10 changed files
with
383 additions
and
109 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Send } from "../apiService"; | ||
import { AxiosInstance } from "axios"; | ||
|
||
export default class HeaderContent { | ||
private _instance: AxiosInstance; | ||
|
||
constructor(_instance: AxiosInstance) { | ||
this._instance = _instance; | ||
} | ||
|
||
public getContent = async (fileName: string): Promise<any> => { | ||
const { data } = await Send(this._instance, "GET", fileName); | ||
|
||
return data; | ||
}; | ||
} |
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,25 @@ | ||
import * as React from "react"; | ||
import { useQuery } from "react-query"; | ||
import APIService from "../apiService/apiService"; | ||
import APIContext from "../apiService/apiContext"; | ||
import { getFileNameFromUrl } from "../services/FileNameFromUrl"; | ||
import { DEFAULT_HEADER_CONTENT_URL } from "../templates/templateParts/header/HeaderTemplate"; | ||
|
||
export const useHeaderContent = () => { | ||
const API: APIService | null = React.useContext(APIContext); | ||
|
||
const fileName = getFileNameFromUrl( | ||
process.env.GATSBY_HEADER_CONTENT !== undefined && process.env.GATSBY_HEADER_CONTENT.length !== 0 | ||
? process.env.GATSBY_HEADER_CONTENT | ||
: DEFAULT_HEADER_CONTENT_URL, | ||
); | ||
|
||
const getContent = () => | ||
useQuery<any, Error>(["contents", fileName], () => API?.HeaderContent.getContent(fileName), { | ||
onError: (error) => { | ||
console.warn(error.message); | ||
}, | ||
}); | ||
|
||
return { getContent }; | ||
}; |
174 changes: 174 additions & 0 deletions
174
pwa/src/templates/templateParts/header/HeaderContent.json
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,174 @@ | ||
[ | ||
{ | ||
"label": "Home", | ||
"type": "internal", | ||
|
||
"current": { | ||
"pathname": "/", | ||
"operator": "equals" | ||
}, | ||
"handleClick": { | ||
"link": "/" | ||
} | ||
}, | ||
{ | ||
"label": "Categories", | ||
"type": "internal", | ||
"current": { | ||
"pathname": "/categories", | ||
"operator": "includes" | ||
}, | ||
"handleClick": { | ||
"link": "/categories" | ||
} | ||
}, | ||
{ | ||
"label": "Applications", | ||
"type": "internal", | ||
"current": { | ||
"pathname": "/applications", | ||
"operator": "includes" | ||
}, | ||
"handleClick": { | ||
"link": "/applications" | ||
} | ||
}, | ||
{ | ||
"label": "Components", | ||
"current": { | ||
"pathname": "/components", | ||
"operator": "includes" | ||
}, | ||
"subItems": [ | ||
{ | ||
"label": "All components", | ||
"type": "internal", | ||
"current": { | ||
"pathname": "/components", | ||
"operator": "includes" | ||
}, | ||
"handleClick": { | ||
"link": "/components" | ||
} | ||
}, | ||
{ | ||
"label": "Processes", | ||
"type": "internal", | ||
"current": { | ||
"pathname": "/components", | ||
"operator": "includes", | ||
"filterCondition": { | ||
"filter": "embedded.nl.embedded.commonground.layerType", | ||
"value": "process", | ||
"isObject": true | ||
} | ||
}, | ||
"handleClick": { | ||
"link": "/components", | ||
"type": "internal", | ||
"setFilter": { | ||
"filter": "embedded.nl.embedded.commonground.layerType", | ||
"value": "process", | ||
"isObject": true | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Data models", | ||
"type": "internal", | ||
"current": { | ||
"pathname": "/components", | ||
"operator": "includes", | ||
"filterCondition": { | ||
"filter": "embedded.nl.embedded.commonground.layerType", | ||
"value": "data", | ||
"isObject": true | ||
} | ||
}, | ||
"handleClick": { | ||
"link": "/components", | ||
"setFilter": { | ||
"filter": "embedded.nl.embedded.commonground.layerType", | ||
"value": "data", | ||
"isObject": true | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "API's", | ||
"type": "internal", | ||
"current": { | ||
"pathname": "/components", | ||
"operator": "includes", | ||
"filterCondition": { | ||
"filter": "embedded.nl.embedded.commonground.layerType", | ||
"value": "service", | ||
"isObject": true | ||
} | ||
}, | ||
"handleClick": { | ||
"link": "/components", | ||
"setFilter": { | ||
"filter": "embedded.nl.embedded.commonground.layerType", | ||
"value": "service", | ||
"isObject": true | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"label": "Organizations", | ||
"type": "internal", | ||
"current": { | ||
"pathname": "/organizations", | ||
"operator": "includes" | ||
}, | ||
"handleClick": { | ||
"link": "/organizations" | ||
} | ||
}, | ||
{ | ||
"label": "Initiatives", | ||
"type": "internal", | ||
"current": "pathname === \"/components\" && filters.developmentStatus === \"concept\"", | ||
"handleClick": { | ||
"link": "/components", | ||
"setFilter": { | ||
"filter": "developmentStatus", | ||
"value": "concept" | ||
} | ||
} | ||
}, | ||
{ | ||
"label": "Documentatie", | ||
"current": { | ||
"pathname": "/documentation", | ||
"operator": "includes" | ||
}, | ||
"subItems": [ | ||
{ | ||
"label": "About", | ||
"type": "internal", | ||
"current": { | ||
"pathname": "/documentation/about", | ||
"operator": "equals" | ||
}, | ||
"handleClick": { | ||
"link": "/documentation/about" | ||
} | ||
}, | ||
{ | ||
"label": "Use", | ||
"type": "internal", | ||
"current": { | ||
"pathname": "/documentation/usage", | ||
"operator": "equals" | ||
}, | ||
"handleClick": { | ||
"link": "/documentation/usage" | ||
} | ||
} | ||
] | ||
} | ||
] |
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
Oops, something went wrong.