Merge pull request #1809 from automatisch/AUT-914
fix: invalidate app connections upon reconnecting a connection
This commit is contained in:
@@ -7,6 +7,7 @@ import MenuItem from '@mui/material/MenuItem';
|
|||||||
import * as URLS from 'config/urls';
|
import * as URLS from 'config/urls';
|
||||||
import useFormatMessage from 'hooks/useFormatMessage';
|
import useFormatMessage from 'hooks/useFormatMessage';
|
||||||
import { ConnectionPropType } from 'propTypes/propTypes';
|
import { ConnectionPropType } from 'propTypes/propTypes';
|
||||||
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
function ContextMenu(props) {
|
function ContextMenu(props) {
|
||||||
const {
|
const {
|
||||||
@@ -18,15 +19,24 @@ function ContextMenu(props) {
|
|||||||
disableReconnection,
|
disableReconnection,
|
||||||
} = props;
|
} = props;
|
||||||
const formatMessage = useFormatMessage();
|
const formatMessage = useFormatMessage();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const createActionHandler = React.useCallback(
|
const createActionHandler = React.useCallback(
|
||||||
(action) => {
|
(action) => {
|
||||||
return function clickHandler(event) {
|
return async function clickHandler(event) {
|
||||||
onMenuItemClick(event, action);
|
onMenuItemClick(event, action);
|
||||||
|
|
||||||
|
if (['test', 'reconnect', 'delete'].includes(action.type)) {
|
||||||
|
await queryClient.invalidateQueries({
|
||||||
|
queryKey: ['apps', appKey, 'connections'],
|
||||||
|
});
|
||||||
|
}
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[onMenuItemClick, onClose],
|
[onMenuItemClick, onClose, queryClient],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu
|
<Menu
|
||||||
open={true}
|
open={true}
|
||||||
|
@@ -17,13 +17,13 @@ export const APP_ADD_CONNECTION = (appKey, shared = false) =>
|
|||||||
`/app/${appKey}/connections/add?shared=${shared}`;
|
`/app/${appKey}/connections/add?shared=${shared}`;
|
||||||
export const APP_ADD_CONNECTION_WITH_AUTH_CLIENT_ID = (
|
export const APP_ADD_CONNECTION_WITH_AUTH_CLIENT_ID = (
|
||||||
appKey,
|
appKey,
|
||||||
appAuthClientId
|
appAuthClientId,
|
||||||
) => `/app/${appKey}/connections/add?appAuthClientId=${appAuthClientId}`;
|
) => `/app/${appKey}/connections/add?appAuthClientId=${appAuthClientId}`;
|
||||||
export const APP_ADD_CONNECTION_PATTERN = '/app/:appKey/connections/add';
|
export const APP_ADD_CONNECTION_PATTERN = '/app/:appKey/connections/add';
|
||||||
export const APP_RECONNECT_CONNECTION = (
|
export const APP_RECONNECT_CONNECTION = (
|
||||||
appKey,
|
appKey,
|
||||||
connectionId,
|
connectionId,
|
||||||
appAuthClientId
|
appAuthClientId,
|
||||||
) => {
|
) => {
|
||||||
const path = `/app/${appKey}/connections/${connectionId}/reconnect`;
|
const path = `/app/${appKey}/connections/${connectionId}/reconnect`;
|
||||||
if (appAuthClientId) {
|
if (appAuthClientId) {
|
||||||
|
Reference in New Issue
Block a user