Update policy back link to return to selected team (#3190)

This commit is contained in:
Luke Heath 2021-12-03 10:13:40 -06:00 committed by GitHub
parent 17bd4d5110
commit 4c19c9c8b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 5 deletions

View file

@ -0,0 +1 @@
* Update policy back link to return to selected team

View file

@ -1,5 +1,4 @@
import React, { useCallback, useContext, useEffect, useState } from "react";
import { Link } from "react-router";
import { useQuery } from "react-query";
import { useDispatch } from "react-redux";
import { noop } from "lodash";
@ -261,7 +260,7 @@ const ManagePolicyPage = (managePoliciesPageProps: {
if (userTeams && !userTeams.find((t) => t.id === teamId)) {
if (isOnGlobalTeam) {
// For global users, default to zero (i.e. all teams).
if (teamId !== 0) {
if (teamId === undefined) {
handleTeamSelect(0);
return;
}

View file

@ -140,9 +140,14 @@ const QueryEditor = ({
return null;
}
const backPath = policyTeamId ? `?team_id=${policyTeamId}` : "";
return (
<div className={`${baseClass}__form body-wrap`}>
<Link to={PATHS.MANAGE_POLICIES} className={`${baseClass}__back-link`}>
<Link
to={`${PATHS.MANAGE_POLICIES}/${backPath}`}
className={`${baseClass}__back-link`}
>
<img src={BackChevron} alt="back chevron" id="back-chevron" />
<span>Back to policies</span>
</Link>

View file

@ -44,7 +44,7 @@ const QueryEditor = ({
goToSelectTargets,
onOpenSchemaSidebar,
renderLiveQueryWarning,
}: IQueryEditorProps) => {
}: IQueryEditorProps): JSX.Element | null => {
const dispatch = useDispatch();
const { currentUser } = useContext(AppContext);

View file

@ -32,7 +32,7 @@ const RunQuery = ({
queryIdForEdit,
setSelectedTargets,
goToQueryEditor,
}: IRunQueryProps) => {
}: IRunQueryProps): JSX.Element | null => {
const dispatch = useDispatch();
const [isQueryFinished, setIsQueryFinished] = useState<boolean>(false);