Skip to content

Commit

Permalink
TASK-389 Close issue drawer when exiting edit mode (#285)
Browse files Browse the repository at this point in the history
* Bug fixed. Cypress passing.

* Added isEditMode watcher for auto drawer closing.
  • Loading branch information
net-runner authored Mar 17, 2021
1 parent a892f88 commit b0adc43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/e2e/table/load-schedule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { ShiftCode } from "../../../../src/common-models/shift-info.model";
import { WorkerType } from "../../../../src/common-models/worker-info.model";
import { FoundationInfoRowType, ScheduleName } from "../../../support/commands";
import { FoundationInfoRowType } from "../../../support/commands";
//#region Test data
interface CheckFoundationInfoReadCorrectly {
scheduleName: "childrens_extraworkers.xlsx" | "extraworkers_childrens.xlsx";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import React from "react";
import React, { useEffect } from "react";
import DrawerHeader from "./drawer-header.component";
import { Box } from "@material-ui/core";
import { makeStyles, Theme } from "@material-ui/core/styles";
import { useJiraLikeDrawer } from "./jira-like-drawer-context";
import ScssVars from "../../../assets/styles/styles/custom/_variables.module.scss";
import { useSelector } from "react-redux";
import { ApplicationStateModel } from "../../../state/models/application-state.model";

export interface StyleProps {
width: number;
Expand All @@ -25,12 +27,19 @@ const useStyles = makeStyles<Theme, StyleProps>({
});

export default function JiraLikeDrawer(width): JSX.Element {
const isEditMode = useSelector(
(state: ApplicationStateModel) => state.actualState.mode === "edit"
);
const classes = useStyles(width);
const { title, open, setOpen, childrenComponent } = useJiraLikeDrawer();

useEffect(() => {
if (!isEditMode) setOpen(false);
}, [isEditMode, setOpen]);

return (
<Box>
{title && open && setOpen && childrenComponent && (
{title && open && setOpen && childrenComponent && isEditMode && (
<Box className={classes.drawer}>
<DrawerHeader title={title} setOpen={setOpen}>
{childrenComponent}
Expand Down

0 comments on commit b0adc43

Please sign in to comment.