Skip to content

Commit

Permalink
feat: Introduce docs button (#1743)
Browse files Browse the repository at this point in the history
* feat: adds a new documentation button

* chore: omits old docs button position

* docs: imporves linting

* docs: removes extra spaces

* chore: improves code quality

* docs: updates a function name

* chore: further improves code quality
  • Loading branch information
faouziH21 committed Aug 29, 2024
1 parent a61cb18 commit c292538
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 10 deletions.
35 changes: 35 additions & 0 deletions src/components/DocumentationButton/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';

import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons';
import {
FontAwesomeIcon
} from '@fortawesome/react-fontawesome';

import SimpleButton, { SimpleButtonProps } from '@terrestris/react-geo/dist/Button/SimpleButton/SimpleButton';

export type DocumentationButtonProps = SimpleButtonProps;

const defaultClassName = 'documentationbutton';
export const DocumentationButton: React.FC<DocumentationButtonProps> = ({
className
}) => {

const finalClassName = className
? `${defaultClassName} ${className}`
: defaultClassName;

return (
<SimpleButton
onClick={() => window.open('/gis-docs', '_blank')}
className={finalClassName}
icon={
<FontAwesomeIcon
icon={faCircleQuestion}
/>
}
>
</SimpleButton>
);
};

export default DocumentationButton;
37 changes: 33 additions & 4 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';

import ClientConfiguration from 'clientConfig';

import DocumentationButton from '../../components/DocumentationButton';
import {
useAppSelector
} from '../../hooks/useAppSelector';
Expand Down Expand Up @@ -81,8 +84,26 @@ export const Header: React.FC<HeaderProps> = ({
return items;
};

const getRightItems = () => {
const items = [
const getDocsButton = () => {
if (ClientConfiguration.documentationButtonVisible) {
return (
<div
key="documentation-button"
aria-label="documentation-button"
>
<DocumentationButton
key="documentation-button"
type="link"
>
</DocumentationButton>

</div>
);
}
};

const getUserMenu = () => {
return (
<div
key="user-menu"
aria-label="user-menu"
Expand All @@ -91,10 +112,18 @@ export const Header: React.FC<HeaderProps> = ({
key="user-menu"
/>
</div>
];
);
};

insertPlugins('right', items);
const getRightItems = () => {
const items = [
getDocsButton(),
getUserMenu()
].filter((item) => {
return item !== undefined;
});

insertPlugins('right', items);
return items;
};

Expand Down
13 changes: 7 additions & 6 deletions src/components/UserMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,17 @@ export const UserMenu: React.FC<UserProps> = (): JSX.Element => {
username,
divider,
settings,
info
info,
divider,
logout
] : [
username,
divider,
info
info,
divider,
logout
];
if (ClientConfiguration.documentationButtonVisible) {
itemsForLoggedInUser.push(docs);
}
itemsForLoggedInUser.push(divider, logout);

items.push(...itemsForLoggedInUser);
}

Expand Down

0 comments on commit c292538

Please sign in to comment.