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 4 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;
25 changes: 25 additions & 0 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 @@ -97,6 +100,25 @@ export const Header: React.FC<HeaderProps> = ({

return items;
};
const getDocsButton = () => {
const items = [
<div
key="documentation-button"
aria-label="documentation-button"
>
<DocumentationButton
key="documentation-button"
type="link"
>
</DocumentationButton>

</div>
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need a wrapping <div>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

other components used a wrapping <div> hence I chose to also wrap it in a div.

];
insertPlugins('right', items);
if (ClientConfiguration.documentationButtonVisible) {
Copy link
Member

@marcjansen marcjansen Aug 26, 2024

Choose a reason for hiding this comment

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

I'd move the check to the top of the function:

if (!ClientConfiguration.documentationButtonVisible) {
  return;
}

Copy link
Contributor Author

@faouziH21 faouziH21 Aug 29, 2024

Choose a reason for hiding this comment

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

check c7a82c5

return items;
}
};

return (
<div
Expand All @@ -120,6 +142,9 @@ export const Header: React.FC<HeaderProps> = ({
<div
className="item-container right-items"
>
{
getDocsButton()
}
{
getRightItems()
}
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