-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor HelpComponent #418
Changes from 25 commits
bcec867
8549b9a
ca2c9e4
bb37a34
77e3a5f
ffd6138
ef1e947
aa31c0c
0d30ce6
1e24dd5
3f0a14a
d1658e2
4a48f94
52fd367
a05eba9
7d7268a
22c7064
eefa988
907fd87
a65b5a7
ed09f83
bc5a3e9
cc898d9
ce2609b
43c37b7
0b0db5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,16 @@ | ||
# ASAB WebUI HelpButton component | ||
|
||
Display information for your desired screen in modal. | ||
Display documentation for your desired screen in modal. The documentation can be found [here](https://docs.teskalabs.com/logman.io/user/) | ||
|
||
If you want to add this component, you need to call the `addHelpButton` method. This method takes only 1 parameter: | ||
>- `path` (string) e.g.: `"Exports/Detail"` or `"Dashboards/SomeDashboardName"`, ... | ||
>- `path` (string) e.g.: `"export"` or `"dashboards"`, ... | ||
`Path/to/help-content` - is a path you set up in Library. **`Help` folder is excluded from this path.** Content file's extension can be omitted. | ||
It will be sufficient to indicate the **correct** part of the documentation (parts of the documentation are in the sidebar), specify the path that comes after this part `https://docs.teskalabs.com/logman.io/user/` | ||
|
||
#### Example code | ||
|
||
```javascript | ||
export function Container(props) { | ||
props.app.addHelpButton("Path/to/help-content"); | ||
props.app.addHelpButton("https://docs.teskalabs.com/path/to/documentation"); | ||
} | ||
``` | ||
|
||
|
||
### Add help-content to Library | ||
|
||
1. Create `Help` folder in Library. | ||
2. Inside, create a new subfolder (e.g. `Dashboards`, `Clients`, `Credentials`,..) | ||
- Naming should match sidebar item's name (as in examples above) | ||
3. Inside newly created subfolder, create a _json_ file named after the page where you want the HelpButton component to appear (e.g. `DashboardsName.json`). | ||
4. This _json_ file carries the content which appears in modal (content supports markdown). | ||
|
||
#### Specific example | ||
|
||
``` | ||
- Library | ||
- Help | ||
- Dashboards | ||
- DashboardsName.json | ||
``` | ||
|
||
#### `DashboardsName.json` content example | ||
```json | ||
{ | ||
"content": "Help content" | ||
} | ||
``` | ||
|
||
#### Usage inside component | ||
```javascript | ||
export function DashboardsName(props) { | ||
... | ||
props.app.addHelpButton("Dashboards/DashboardsName"); | ||
... | ||
} | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,12 @@ import HeaderService from '../services/HeaderService'; | |
import SidebarService from './Sidebar/service'; | ||
import ThemeService from '../theme/ThemeService'; | ||
import BrandingService from '../services/BrandingService'; | ||
import HelpService from "../services/HelpService"; | ||
import TitleService from "../services/TitleService"; | ||
|
||
import AccessDeniedCard from '../modules/tenant/access/AccessDeniedCard'; | ||
import UnauthorizedAccessScreen from '../modules/auth/components/UnauthorizedAccessScreen'; | ||
|
||
import {ADD_ALERT, SET_ADVANCED_MODE, HELP_CONTENT, SET_BREADCRUMB_NAME} from '../actions'; | ||
import {ADD_ALERT, SET_ADVANCED_MODE, SET_HELP_PATH, SET_BREADCRUMB_NAME} from '../actions'; | ||
|
||
|
||
class Application extends Component { | ||
|
@@ -92,8 +91,7 @@ class Application extends Component { | |
this.SidebarService = new SidebarService(this, "SidebarService"); | ||
this.ThemeService = new ThemeService(this, "ThemeService"); | ||
this.BrandingService = new BrandingService(this, "BrandingService"); | ||
this.HelpService = new HelpService(this, "HelpService"); | ||
this.TitleService = new TitleService(this, "TitleService") | ||
this.TitleService = new TitleService(this, "TitleService"); | ||
|
||
this.ReduxService.addReducer("alerts", alertsReducer); | ||
this.ReduxService.addReducer("advmode", advancedModeReducer); | ||
|
@@ -447,14 +445,17 @@ class Application extends Component { | |
|
||
addHelpButton(path) { | ||
useEffect(() => { | ||
this.HelpService.setData(path); | ||
this.Store.dispatch({ | ||
type: SET_HELP_PATH, | ||
path: path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aringocode Alright, sorry for requesting changes all over again :D Here the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Pe5h4 ok, i renamed it |
||
}); | ||
return () => { | ||
this.Store.dispatch({ | ||
type: HELP_CONTENT, | ||
content: "" | ||
type: SET_HELP_PATH, | ||
path: "" | ||
}) | ||
} | ||
}, []) | ||
}, []); | ||
} | ||
|
||
// Method for overloading breadcrumb name | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,48 @@ | ||
import React, { useState } from 'react'; | ||
import { useTranslation } from "react-i18next"; | ||
import { useSelector } from 'react-redux'; | ||
import React, {useState, useEffect} from 'react'; | ||
import {useTranslation} from "react-i18next"; | ||
import {useSelector} from 'react-redux'; | ||
|
||
import { Modal, NavLink, Card, CardHeader, CardBody, Button } from 'reactstrap'; | ||
import {Modal, NavLink, Card, CardHeader, CardBody, Button} from 'reactstrap'; | ||
|
||
|
||
export default function HelpButton() { | ||
const { t } = useTranslation(); | ||
|
||
const [modal, setModal] = useState(false); | ||
|
||
const content = useSelector(state => state?.header.content); | ||
if ((content == undefined) || (content == "")) return null; | ||
|
||
const toggle = () => setModal(!modal); | ||
|
||
return ( | ||
<> | ||
<NavLink | ||
className="help-button" | ||
onClick={toggle} | ||
title={t("Show help info")} | ||
href="#" | ||
> | ||
<i>?</i> | ||
</NavLink> | ||
|
||
<Modal isOpen={modal} toggle={toggle} className="center help-modal-card"> | ||
<Card> | ||
<CardHeader className="border-bottom"> | ||
<div className="card-header-title"> | ||
<i className="cil-info pr-2" /> | ||
{t("HelpButton|Help")} | ||
</div> | ||
<Button outline color="primary" onClick={toggle}> | ||
<i className="cil-x"/> | ||
</Button> | ||
</CardHeader> | ||
<CardBody> | ||
<div>{content}</div> | ||
{/*TODO: uncomment and use when the documentation is ready to be displayed in the iframe*/} | ||
{/*<iframe className="help-iframe" src="" title=""/>*/} | ||
</CardBody> | ||
</Card> | ||
</Modal> | ||
</> | ||
); | ||
const {t} = useTranslation(); | ||
|
||
const [modal, setModal] = useState(false); | ||
|
||
const path = useSelector(state => state?.header.path); | ||
if ((path == undefined) || (path == "")) return null; | ||
|
||
const toggle = () => setModal(!modal); | ||
|
||
return ( | ||
<> | ||
<NavLink | ||
className="help-button" | ||
onClick={toggle} | ||
title={t("Show help info")} | ||
href="#" | ||
> | ||
<i>?</i> | ||
</NavLink> | ||
|
||
<Modal isOpen={modal} toggle={toggle} className="center help-modal-card"> | ||
<Card> | ||
<CardHeader className="border-bottom"> | ||
<div className="card-header-title"> | ||
<i className="cil-info pr-2" /> | ||
{t("HelpButton|Help")} | ||
</div> | ||
<Button outline color="primary" onClick={toggle}> | ||
<i className="cil-x"/> | ||
</Button> | ||
</CardHeader> | ||
<CardBody> | ||
<iframe className="help-iframe" src={path} /> | ||
</CardBody> | ||
</Card> | ||
</Modal> | ||
</> | ||
); | ||
} | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aringoaway should be somethng like
helpContentPath: path