Merge pull request #2398 from automatisch/AUT-1341
feat: preserve query params when navigating back to flow page from flow editor
This commit is contained in:
@@ -8,7 +8,7 @@ import Snackbar from '@mui/material/Snackbar';
|
|||||||
import Stack from '@mui/material/Stack';
|
import Stack from '@mui/material/Stack';
|
||||||
import Tooltip from '@mui/material/Tooltip';
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Link, useParams } from 'react-router-dom';
|
import { Link, useLocation, useParams } from 'react-router-dom';
|
||||||
import { ReactFlowProvider } from 'reactflow';
|
import { ReactFlowProvider } from 'reactflow';
|
||||||
|
|
||||||
import Can from 'components/Can';
|
import Can from 'components/Can';
|
||||||
@@ -32,6 +32,7 @@ const useNewFlowEditor = process.env.REACT_APP_USE_NEW_FLOW_EDITOR === 'true';
|
|||||||
|
|
||||||
export default function EditorLayout() {
|
export default function EditorLayout() {
|
||||||
const { flowId } = useParams();
|
const { flowId } = useParams();
|
||||||
|
const { state } = useLocation();
|
||||||
const formatMessage = useFormatMessage();
|
const formatMessage = useFormatMessage();
|
||||||
const enqueueSnackbar = useEnqueueSnackbar();
|
const enqueueSnackbar = useEnqueueSnackbar();
|
||||||
const { mutateAsync: updateFlow } = useUpdateFlow(flowId);
|
const { mutateAsync: updateFlow } = useUpdateFlow(flowId);
|
||||||
@@ -81,7 +82,7 @@ export default function EditorLayout() {
|
|||||||
<IconButton
|
<IconButton
|
||||||
size="small"
|
size="small"
|
||||||
component={Link}
|
component={Link}
|
||||||
to={URLS.FLOWS}
|
to={state?.from || URLS.FLOWS}
|
||||||
data-test="editor-go-back-button"
|
data-test="editor-go-back-button"
|
||||||
>
|
>
|
||||||
<ArrowBackIosNewIcon fontSize="small" />
|
<ArrowBackIosNewIcon fontSize="small" />
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import MenuItem from '@mui/material/MenuItem';
|
|||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { Link, useNavigate, useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
import Can from 'components/Can';
|
import Can from 'components/Can';
|
||||||
import FlowFolderChangeDialog from 'components/FlowFolderChangeDialog';
|
import FlowFolderChangeDialog from 'components/FlowFolderChangeDialog';
|
||||||
@@ -17,6 +17,7 @@ import useFormatMessage from 'hooks/useFormatMessage';
|
|||||||
import useIsCurrentUserAdmin from 'hooks/useIsCurrentUserAdmin';
|
import useIsCurrentUserAdmin from 'hooks/useIsCurrentUserAdmin';
|
||||||
|
|
||||||
function ContextMenu(props) {
|
function ContextMenu(props) {
|
||||||
|
const location = useLocation();
|
||||||
const { flowId, onClose, anchorEl, onDuplicateFlow, appKey } = props;
|
const { flowId, onClose, anchorEl, onDuplicateFlow, appKey } = props;
|
||||||
|
|
||||||
const [showFlowFolderChangeDialog, setShowFlowFolderChangeDialog] =
|
const [showFlowFolderChangeDialog, setShowFlowFolderChangeDialog] =
|
||||||
@@ -120,6 +121,9 @@ function ContextMenu(props) {
|
|||||||
disabled={!allowed}
|
disabled={!allowed}
|
||||||
component={Link}
|
component={Link}
|
||||||
to={URLS.FLOW(flowId)}
|
to={URLS.FLOW(flowId)}
|
||||||
|
state={{
|
||||||
|
from: `${location.pathname}${location.search}${location.hash}`,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{formatMessage('flow.view')}
|
{formatMessage('flow.view')}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
import Card from '@mui/material/Card';
|
import Card from '@mui/material/Card';
|
||||||
import IconButton from '@mui/material/IconButton';
|
import IconButton from '@mui/material/IconButton';
|
||||||
import CardActionArea from '@mui/material/CardActionArea';
|
import CardActionArea from '@mui/material/CardActionArea';
|
||||||
@@ -34,6 +34,7 @@ function getFlowStatusColor(status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function FlowRow(props) {
|
function FlowRow(props) {
|
||||||
|
const location = useLocation();
|
||||||
const formatMessage = useFormatMessage();
|
const formatMessage = useFormatMessage();
|
||||||
const contextButtonRef = React.useRef(null);
|
const contextButtonRef = React.useRef(null);
|
||||||
const [anchorEl, setAnchorEl] = React.useState(null);
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
||||||
@@ -63,6 +64,9 @@ function FlowRow(props) {
|
|||||||
component={Link}
|
component={Link}
|
||||||
to={URLS.FLOW(flow.id)}
|
to={URLS.FLOW(flow.id)}
|
||||||
data-test="card-action-area"
|
data-test="card-action-area"
|
||||||
|
state={{
|
||||||
|
from: `${location.pathname}${location.search}${location.hash}`,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Apps direction="row" gap={1} sx={{ gridArea: 'apps' }}>
|
<Apps direction="row" gap={1} sx={{ gridArea: 'apps' }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user