Fix: "Manage users" button should close modal on settings page (#6)

This commit is contained in:
Tejaaswini Narendra 2020-07-02 08:40:24 +05:30 committed by GitHub
parent 15efdc4dbd
commit 6fff99530f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import React, { useEffect } from "react";
import styled from "styled-components";
import { useLocation } from "react-router-dom";
import TagListField from "components/editorComponents/form/fields/TagListField";
import { reduxForm, SubmissionError } from "redux-form";
import SelectField from "components/editorComponents/form/fields/SelectField";
@ -124,7 +125,12 @@ const InviteUsersForm = (props: any) => {
fetchUser,
fetchAllRoles,
valid,
onCancel,
} = props;
const currentPath = useLocation().pathname;
const pathRegex = /(?:\/org\/)\w+(?:\/settings)/;
useEffect(() => {
fetchUser(props.orgId);
fetchAllRoles(props.orgId);
@ -184,7 +190,9 @@ const InviteUsersForm = (props: any) => {
filled
intent="primary"
onClick={() => {
history.push(`/org/${props.orgId}/settings`);
pathRegex.test(currentPath)
? onCancel()
: history.push(`/org/${props.orgId}/settings`);
}}
/>
</StyledForm>