Skip to content
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

feat: Introduce docs button #1743

Merged
merged 7 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL should be configurable, I guess.

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
Loading