feat: prevent adding connection when app is disabled

This commit is contained in:
kasia.oczkowska
2025-03-31 15:21:42 +01:00
parent 59256480c6
commit 56a2839504
2 changed files with 10 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ import * as URLS from 'config/urls';
import useAuthenticateApp from 'hooks/useAuthenticateApp.ee'; import useAuthenticateApp from 'hooks/useAuthenticateApp.ee';
import useFormatMessage from 'hooks/useFormatMessage'; import useFormatMessage from 'hooks/useFormatMessage';
import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar'; import useEnqueueSnackbar from 'hooks/useEnqueueSnackbar';
import useAppConfig from 'hooks/useAppConfig.ee';
import { generateExternalLink } from 'helpers/translationValues'; import { generateExternalLink } from 'helpers/translationValues';
import { Form } from './style'; import { Form } from './style';
import useAppAuth from 'hooks/useAppAuth'; import useAppAuth from 'hooks/useAppAuth';
@@ -41,6 +42,7 @@ function AddAppConnection(props) {
}); });
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const enqueueSnackbar = useEnqueueSnackbar(); const enqueueSnackbar = useEnqueueSnackbar();
const { data: appConfig } = useAppConfig(key);
React.useEffect(function relayProviderData() { React.useEffect(function relayProviderData() {
if (window.opener) { if (window.opener) {
@@ -170,7 +172,7 @@ function AddAppConnection(props) {
color="primary" color="primary"
sx={{ boxShadow: 2 }} sx={{ boxShadow: 2 }}
loading={inProgress} loading={inProgress}
disabled={!authenticate} disabled={!authenticate || appConfig?.data?.disabled === true}
data-test="create-connection-button" data-test="create-connection-button"
> >
{formatMessage('addAppConnection.submit')} {formatMessage('addAppConnection.submit')}

View File

@@ -5,6 +5,7 @@ import AppConnectionRow from 'components/AppConnectionRow';
import NoResultFound from 'components/NoResultFound'; import NoResultFound from 'components/NoResultFound';
import Can from 'components/Can'; import Can from 'components/Can';
import useFormatMessage from 'hooks/useFormatMessage'; import useFormatMessage from 'hooks/useFormatMessage';
import useAppConfig from 'hooks/useAppConfig.ee';
import * as URLS from 'config/urls'; import * as URLS from 'config/urls';
import useAppConnections from 'hooks/useAppConnections'; import useAppConnections from 'hooks/useAppConnections';
@@ -12,6 +13,8 @@ function AppConnections(props) {
const { appKey } = props; const { appKey } = props;
const formatMessage = useFormatMessage(); const formatMessage = useFormatMessage();
const { data } = useAppConnections(appKey); const { data } = useAppConnections(appKey);
const { data: appConfig } = useAppConfig(appKey);
const appConnections = data?.data || []; const appConnections = data?.data || [];
const hasConnections = appConnections?.length; const hasConnections = appConnections?.length;
@@ -22,7 +25,10 @@ function AppConnections(props) {
<NoResultFound <NoResultFound
text={formatMessage('app.noConnections')} text={formatMessage('app.noConnections')}
data-test="connections-no-results" data-test="connections-no-results"
{...(allowed && { to: URLS.APP_ADD_CONNECTION(appKey) })} {...(allowed &&
!appConfig?.data?.disabled && {
to: URLS.APP_ADD_CONNECTION(appKey),
})}
/> />
)} )}
</Can> </Can>