Skip to content

Commit

Permalink
Global button for opening Implementer Tools (#482)
Browse files Browse the repository at this point in the history
* Added global implementer tools button

* Shifted the global implementer tools button to the bottom
  • Loading branch information
vasharma05 authored Jul 21, 2022
1 parent 85c8423 commit 6836764
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { cleanup, render, screen } from "@testing-library/react";
import React from "react";
import "@testing-library/jest-dom";
import GlobalImplementerToolsButton from "./global-implementer-tools.component";

describe("Testing the global implementer tools button", () => {
afterEach(cleanup);
it("should render global Implementer tools", () => {
render(<GlobalImplementerToolsButton />);
const button = screen.getByTestId("globalImplementerToolsButton");
expect(button).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import { useTranslation } from "react-i18next";
import ChevronUp from "@carbon/icons-react/es/chevron--up/16";
import ChevronDown from "@carbon/icons-react/es/chevron--down/16";
import { UserHasAccess, useStore } from "@openmrs/esm-framework";
import { implementerToolsStore, togglePopup } from "./store";
import styles from "./implementer-tools.styles.scss";

const GlobalImplementerToolsButton: React.FC = () => {
const { t } = useTranslation();
const { isOpen } = useStore(implementerToolsStore);

return (
<UserHasAccess privilege="coreapps.systemAdministration">
<div
className={styles.chevronImplementerToolsButton}
data-testid="globalImplementerToolsButton"
>
<div onClick={togglePopup} role="button" tabIndex={0}>
{isOpen ? <ChevronDown /> : <ChevronUp />}
</div>
</div>
</UserHasAccess>
);
};

export default GlobalImplementerToolsButton;
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,25 @@
.toolStyles {
background-color: transparent;
}

// Chevron button - implementer-tools component

.chevronImplementerToolsButton {
position: fixed;
bottom: 0;
left: calc(50vw - $spacing-05);
z-index: 9999;

div {
background-color: $ui-02;
width: $spacing-07;
display: flex;
justify-content: center;
cursor: pointer;
transition: all 0.1s ease-in-out;
}

div:hover {
padding: $spacing-03 0;
}
}
7 changes: 7 additions & 0 deletions packages/apps/esm-implementer-tools-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ function setupOpenMRS() {
options
),
},
{
route: () => true,
load: getAsyncLifecycle(
() => import("./global-implementer-tools.component"),
options
),
},
],
extensions: [
{
Expand Down

0 comments on commit 6836764

Please sign in to comment.