Skip to content

Commit

Permalink
navbar: Init solutions navbar dev environment
Browse files Browse the repository at this point in the history
It provides a web component navbar that solutions UIs can reuse to benefit from :
 - a centralized authentication method
 - a theme provider
 - a language provider
  • Loading branch information
JBWatenbergScality committed Feb 10, 2021
1 parent 2498a7a commit 2b78ff4
Show file tree
Hide file tree
Showing 13 changed files with 19,496 additions and 0 deletions.
24 changes: 24 additions & 0 deletions solutions-ui-navbar/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[ignore]
.*/node_modules/module-deps/.*
.*/build/.*

[include]
src/.*

[libs]

[lints]
all=error
untyped-import=off
unclear-type=off
sketchy-null=off
unsafe-getters-setters=warn

[options]
esproposal.optional_chaining=enable
react.runtime=automatic

[strict]

[untyped]
.*/node_modules/react-select/.*
2 changes: 2 additions & 0 deletions solutions-ui-navbar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
5 changes: 5 additions & 0 deletions solutions-ui-navbar/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
56 changes: 56 additions & 0 deletions solutions-ui-navbar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# solutions-navbar

Common navbar that can be integrated in metalk8s solution UI to provide the following features :

- Authentication : token negociation, token renewal, claims provider
- Theming : provide the selected theme to solution UIs
- I18n : provide a language selector and expose selected language to solution UIs

## Contribute

```js
$ npm run start
```

## Build

```js
$ npm run build
```

## Use

```html
<script src="./dist/main.js"></script>
<solutions-navbar
oidc-provider-url="https://oidc.provider/"
scopes="openid mail scope"

/>
```

### Attributes

- oidc-provider-url : string, required, the component will suffix it with .well-known/openid-configuration to retrieve OIDC configuration
- scopes : string, required, scopes negiciated with the oidc provider
- client-id : string, required

- redirect-url : string, customized redirect uri
- options : {[url: string]: {en: string, fr: string}} -- eg : {"/": {en: "Overview", fr: "Vue generale"}, "/platform": {en: "Platform", fr: "Infrastructure"}, ...} - by default we display the full navbar in static mode, this attribute can be used if we want to extends the menu in a specific context

## Methods

- logOut(): void - force logOut, might be called when an UI receive a 401 or 403 status code for example
- getClaims(): Promise<Claims>
- getIdToken(): Promise<string> - jwtToken
- getLanguage(): "en" | "fr"
- getTheme(): Theme
- getOptions(): {[url: string]: {en: string, fr: string}}

## Events

- solutions--authenticated, payload: {token, claims: {roles, instanceIds, firstName, lastName, email, scopes, ...}} --- also called when the token is renewed
- solutions--logged-out, payload : {}
- solutions--theme-changed, payload: {theme}
- solutions--language-changed, payload: {language: "en" | "fr"}

5 changes: 5 additions & 0 deletions solutions-ui-navbar/babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": ["@babel/preset-env", "@babel/preset-flow", ["@babel/preset-react", {
"runtime": "automatic"
}]]
}
12 changes: 12 additions & 0 deletions solutions-ui-navbar/index-template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app"></div>
</body>
</html>

4 changes: 4 additions & 0 deletions solutions-ui-navbar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ReactDOM from "react-dom";
import Mdx from "./src/index.mdx";

ReactDOM.render(<Mdx />, document.getElementById("app"));
Loading

0 comments on commit 2b78ff4

Please sign in to comment.