Merge branch 'main' into AUT-1380

This commit is contained in:
Jakub P.
2025-01-14 17:03:39 +01:00
34 changed files with 994 additions and 570 deletions

View File

@@ -13,7 +13,6 @@ import useCreateConnectionAuthUrl from './useCreateConnectionAuthUrl';
import useUpdateConnection from './useUpdateConnection';
import useResetConnection from './useResetConnection';
import useVerifyConnection from './useVerifyConnection';
import { useWhatChanged } from '@simbathesailor/use-what-changed';
function getSteps(auth, hasConnection, useShared) {
if (hasConnection) {
@@ -143,24 +142,6 @@ export default function useAuthenticateApp(payload) {
verifyConnection,
]);
useWhatChanged(
[
steps,
appKey,
oauthClientId,
connectionId,
queryClient,
createConnection,
createConnectionAuthUrl,
updateConnection,
resetConnection,
verifyConnection,
],
'steps, appKey, oauthClientId, connectionId, queryClient, createConnection, createConnectionAuthUrl, updateConnection, resetConnection, verifyConnection',
'',
'useAuthenticate',
);
return {
authenticate,
inProgress: authenticationInProgress,

View File

@@ -2,11 +2,11 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
import api from 'helpers/api';
export default function useDeleteFlow() {
export default function useDeleteFlow(flowId) {
const queryClient = useQueryClient();
const query = useMutation({
mutationFn: async (flowId) => {
mutationFn: async () => {
const { data } = await api.delete(`/v1/flows/${flowId}`);
return data;

View File

@@ -0,0 +1,31 @@
import * as React from 'react';
import slugify from 'slugify';
export default function useDownloadJsonAsFile() {
const handleDownloadJsonAsFile = React.useCallback(
function handleDownloadJsonAsFile({ contents, name }) {
const stringifiedContents = JSON.stringify(contents, null, 2);
const slugifiedName = slugify(name, {
lower: true,
strict: true,
replacement: '-',
});
const fileBlob = new Blob([stringifiedContents], {
type: 'application/json',
});
const fileObjectUrl = URL.createObjectURL(fileBlob);
const temporaryDownloadLink = document.createElement('a');
temporaryDownloadLink.href = fileObjectUrl;
temporaryDownloadLink.download = slugifiedName;
temporaryDownloadLink.click();
},
[],
);
return handleDownloadJsonAsFile;
}

View File

@@ -0,0 +1,15 @@
import { useMutation } from '@tanstack/react-query';
import api from 'helpers/api';
export default function useExportFlow(flowId) {
const mutation = useMutation({
mutationFn: async () => {
const { data } = await api.post(`/v1/flows/${flowId}/export`);
return data;
},
});
return mutation;
}