Compare commits
28 Commits
temp-branc
...
v0.13.1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
24bf07e068 | ||
![]() |
bae234827f | ||
![]() |
81c698f45b | ||
![]() |
c9fecec575 | ||
![]() |
2f42dfdc51 | ||
![]() |
5afd500c26 | ||
![]() |
50d91405a9 | ||
![]() |
69eed65c9b | ||
![]() |
f1355cd0ab | ||
![]() |
cc1a924c8b | ||
![]() |
02005a3f09 | ||
![]() |
d9219a5a48 | ||
![]() |
dffbdf544c | ||
![]() |
e2dbf1a215 | ||
![]() |
c1396b97f0 | ||
![]() |
920a711c00 | ||
![]() |
02a872a376 | ||
![]() |
be4493710f | ||
![]() |
52c0c5e0c5 | ||
![]() |
4c639f170e | ||
![]() |
509a414151 | ||
![]() |
8f3c793a69 | ||
![]() |
a2dd9cf1b8 | ||
![]() |
42285a5879 | ||
![]() |
5d63fce6f0 | ||
![]() |
46a4c8faec | ||
![]() |
ba14481151 | ||
![]() |
5a4207414d |
@@ -52,7 +52,7 @@ const appConfig = {
|
||||
isDev: appEnv === 'development',
|
||||
isTest: appEnv === 'test',
|
||||
isProd: appEnv === 'production',
|
||||
version: '0.12.0',
|
||||
version: '0.13.1',
|
||||
postgresDatabase: process.env.POSTGRES_DATABASE || 'automatisch_development',
|
||||
postgresSchema: process.env.POSTGRES_SCHEMA || 'public',
|
||||
postgresPort: parseInt(process.env.POSTGRES_PORT || '5432'),
|
||||
|
@@ -1,13 +1,17 @@
|
||||
import appConfig from '../../../../config/app.js';
|
||||
import { hasValidLicense } from '../../../../helpers/license.ee.js';
|
||||
import { renderObject } from '../../../../helpers/renderer.js';
|
||||
import Config from '../../../../models/config.js';
|
||||
|
||||
export default async (request, response) => {
|
||||
const installationCompleted = await Config.isInstallationCompleted();
|
||||
|
||||
const info = {
|
||||
isCloud: appConfig.isCloud,
|
||||
isMation: appConfig.isMation,
|
||||
isEnterprise: await hasValidLicense(),
|
||||
docsUrl: appConfig.docsUrl,
|
||||
installationCompleted,
|
||||
isCloud: appConfig.isCloud,
|
||||
isEnterprise: await hasValidLicense(),
|
||||
isMation: appConfig.isMation,
|
||||
};
|
||||
|
||||
renderObject(response, info);
|
||||
|
@@ -1,12 +1,14 @@
|
||||
import { vi, expect, describe, it } from 'vitest';
|
||||
import request from 'supertest';
|
||||
import appConfig from '../../../../config/app.js';
|
||||
import Config from '../../../../models/config.js';
|
||||
import app from '../../../../app.js';
|
||||
import infoMock from '../../../../../test/mocks/rest/api/v1/automatisch/info.js';
|
||||
import * as license from '../../../../helpers/license.ee.js';
|
||||
|
||||
describe('GET /api/v1/automatisch/info', () => {
|
||||
it('should return Automatisch info', async () => {
|
||||
vi.spyOn(Config, 'isInstallationCompleted').mockResolvedValue(true);
|
||||
vi.spyOn(appConfig, 'isCloud', 'get').mockReturnValue(false);
|
||||
vi.spyOn(appConfig, 'isMation', 'get').mockReturnValue(false);
|
||||
vi.spyOn(license, 'hasValidLicense').mockResolvedValue(true);
|
||||
|
@@ -10,7 +10,7 @@ describe('GET /api/v1/automatisch/version', () => {
|
||||
|
||||
const expectedPayload = {
|
||||
data: {
|
||||
version: '0.12.0',
|
||||
version: '0.13.1',
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
|
@@ -3,70 +3,100 @@ import { HttpsProxyAgent } from 'https-proxy-agent';
|
||||
import { HttpProxyAgent } from 'http-proxy-agent';
|
||||
import appConfig from '../config/app.js';
|
||||
|
||||
const config = axios.defaults;
|
||||
const httpProxyUrl = appConfig.httpProxy;
|
||||
const httpsProxyUrl = appConfig.httpsProxy;
|
||||
const supportsProxy = httpProxyUrl || httpsProxyUrl;
|
||||
const noProxyEnv = appConfig.noProxy;
|
||||
const noProxyHosts = noProxyEnv ? noProxyEnv.split(',').map(host => host.trim()) : [];
|
||||
export function createInstance(customConfig = {}, { requestInterceptor, responseErrorInterceptor } = {}) {
|
||||
const config = {
|
||||
...axios.defaults,
|
||||
...customConfig
|
||||
};
|
||||
const httpProxyUrl = appConfig.httpProxy;
|
||||
const httpsProxyUrl = appConfig.httpsProxy;
|
||||
const supportsProxy = httpProxyUrl || httpsProxyUrl;
|
||||
const noProxyEnv = appConfig.noProxy;
|
||||
const noProxyHosts = noProxyEnv ? noProxyEnv.split(',').map(host => host.trim()) : [];
|
||||
|
||||
if (supportsProxy) {
|
||||
if (httpProxyUrl) {
|
||||
config.httpAgent = new HttpProxyAgent(httpProxyUrl);
|
||||
if (supportsProxy) {
|
||||
if (httpProxyUrl) {
|
||||
config.httpAgent = new HttpProxyAgent(httpProxyUrl);
|
||||
}
|
||||
|
||||
if (httpsProxyUrl) {
|
||||
config.httpsAgent = new HttpsProxyAgent(httpsProxyUrl);
|
||||
}
|
||||
|
||||
config.proxy = false;
|
||||
}
|
||||
|
||||
if (httpsProxyUrl) {
|
||||
config.httpsAgent = new HttpsProxyAgent(httpsProxyUrl);
|
||||
const instance = axios.create(config);
|
||||
|
||||
function shouldSkipProxy(hostname) {
|
||||
return noProxyHosts.some(noProxyHost => {
|
||||
return hostname.endsWith(noProxyHost) || hostname === noProxyHost;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* The interceptors are executed in the reverse order they are added.
|
||||
*/
|
||||
instance.interceptors.request.use(
|
||||
function skipProxyIfInNoProxy(requestConfig) {
|
||||
const hostname = new URL(requestConfig.baseURL).hostname;
|
||||
|
||||
if (supportsProxy && shouldSkipProxy(hostname)) {
|
||||
requestConfig.httpAgent = undefined;
|
||||
requestConfig.httpsAgent = undefined;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
},
|
||||
(error) => Promise.reject(error)
|
||||
);
|
||||
|
||||
// not always we have custom request interceptors
|
||||
if (requestInterceptor) {
|
||||
instance.interceptors.request.use(
|
||||
async function customInterceptor(requestConfig) {
|
||||
let newRequestConfig = requestConfig;
|
||||
|
||||
for (const interceptor of requestInterceptor) {
|
||||
newRequestConfig = await interceptor(newRequestConfig);
|
||||
}
|
||||
|
||||
return newRequestConfig;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
config.proxy = false;
|
||||
instance.interceptors.request.use(
|
||||
function removeBaseUrlForAbsoluteUrls(requestConfig) {
|
||||
/**
|
||||
* If the URL is an absolute URL, we remove its origin out of the URL
|
||||
* and set it as baseURL. This lets us streamlines the requests made by Automatisch
|
||||
* and requests made by app integrations.
|
||||
*/
|
||||
try {
|
||||
const url = new URL(requestConfig.url);
|
||||
requestConfig.baseURL = url.origin;
|
||||
requestConfig.url = url.pathname + url.search;
|
||||
|
||||
return requestConfig;
|
||||
} catch (err) {
|
||||
return requestConfig;
|
||||
}
|
||||
},
|
||||
(error) => Promise.reject(error)
|
||||
);
|
||||
|
||||
// not always we have custom response error interceptor
|
||||
if (responseErrorInterceptor) {
|
||||
instance.interceptors.response.use(
|
||||
(response) => response,
|
||||
responseErrorInterceptor
|
||||
);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
const axiosWithProxyInstance = axios.create(config);
|
||||
const defaultInstance = createInstance();
|
||||
|
||||
function shouldSkipProxy(hostname) {
|
||||
return noProxyHosts.some(noProxyHost => {
|
||||
return hostname.endsWith(noProxyHost) || hostname === noProxyHost;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* The interceptors are executed in the reverse order they are added.
|
||||
*/
|
||||
axiosWithProxyInstance.interceptors.request.use(
|
||||
function skipProxyIfInNoProxy(requestConfig) {
|
||||
const hostname = new URL(requestConfig.baseURL).hostname;
|
||||
|
||||
if (supportsProxy && shouldSkipProxy(hostname)) {
|
||||
requestConfig.httpAgent = undefined;
|
||||
requestConfig.httpsAgent = undefined;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
},
|
||||
undefined,
|
||||
{ synchronous: true }
|
||||
);
|
||||
|
||||
axiosWithProxyInstance.interceptors.request.use(
|
||||
function removeBaseUrlForAbsoluteUrls(requestConfig) {
|
||||
/**
|
||||
* If the URL is an absolute URL, we remove its origin out of the URL
|
||||
* and set it as baseURL. This lets us streamlines the requests made by Automatisch
|
||||
* and requests made by app integrations.
|
||||
*/
|
||||
try {
|
||||
const url = new URL(requestConfig.url);
|
||||
requestConfig.baseURL = url.origin;
|
||||
requestConfig.url = url.pathname + url.search;
|
||||
|
||||
return requestConfig;
|
||||
} catch {
|
||||
return requestConfig;
|
||||
}
|
||||
},
|
||||
undefined,
|
||||
{ synchronous: true}
|
||||
);
|
||||
|
||||
export default axiosWithProxyInstance;
|
||||
export default defaultInstance;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, it, expect, vi } from 'vitest';
|
||||
|
||||
describe('Axios with proxy', () => {
|
||||
describe('Custom default axios with proxy', () => {
|
||||
beforeEach(() => {
|
||||
vi.resetModules();
|
||||
});
|
||||
@@ -23,7 +23,13 @@ describe('Axios with proxy', () => {
|
||||
expect(secondRequestInterceptor.fulfilled.name).toBe('removeBaseUrlForAbsoluteUrls');
|
||||
});
|
||||
|
||||
describe('skipProxyIfInNoProxy', () => {
|
||||
it('should throw with invalid url (consisting of path alone)', async () => {
|
||||
const axios = (await import('./axios-with-proxy.js')).default;
|
||||
|
||||
await expect(() => axios('/just-a-path')).rejects.toThrowError('Invalid URL');
|
||||
});
|
||||
|
||||
describe('with skipProxyIfInNoProxy interceptor', () => {
|
||||
let appConfig, axios;
|
||||
beforeEach(async() => {
|
||||
appConfig = (await import('../config/app.js')).default;
|
||||
@@ -67,7 +73,7 @@ describe('Axios with proxy', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeBaseUrlForAbsoluteUrls', () => {
|
||||
describe('with removeBaseUrlForAbsoluteUrls interceptor', () => {
|
||||
let axios;
|
||||
beforeEach(async() => {
|
||||
axios = (await import('./axios-with-proxy.js')).default;
|
||||
@@ -116,4 +122,48 @@ describe('Axios with proxy', () => {
|
||||
expect(interceptedRequestConfig.url).toBe('/path?query=1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('with extra requestInterceptors', () => {
|
||||
it('should apply extra request interceptors in the middle', async () => {
|
||||
const { createInstance } = await import('./axios-with-proxy.js');
|
||||
|
||||
const interceptor = (config) => {
|
||||
config.test = true;
|
||||
return config;
|
||||
}
|
||||
|
||||
const instance = createInstance({}, {
|
||||
requestInterceptor: [
|
||||
interceptor
|
||||
]
|
||||
});
|
||||
const requestInterceptors = instance.interceptors.request.handlers;
|
||||
const customInterceptor = requestInterceptors[1].fulfilled;
|
||||
|
||||
expect(requestInterceptors.length).toBe(3);
|
||||
await expect(customInterceptor({})).resolves.toStrictEqual({ test: true });
|
||||
});
|
||||
|
||||
it('should work with a custom interceptor setting a baseURL and a request to path', async () => {
|
||||
const { createInstance } = await import('./axios-with-proxy.js');
|
||||
|
||||
const interceptor = (config) => {
|
||||
config.baseURL = 'http://localhost';
|
||||
return config;
|
||||
}
|
||||
|
||||
const instance = createInstance({}, {
|
||||
requestInterceptor: [
|
||||
interceptor
|
||||
]
|
||||
});
|
||||
|
||||
try {
|
||||
await instance.get('/just-a-path');
|
||||
} catch (error) {
|
||||
expect(error.config.baseURL).toBe('http://localhost');
|
||||
expect(error.config.url).toBe('/just-a-path');
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
@@ -11,6 +11,7 @@ export default function computeParameters(parameters, executionSteps) {
|
||||
const computedValue = parts
|
||||
.map((part) => {
|
||||
const isVariable = part.match(variableRegExp);
|
||||
|
||||
if (isVariable) {
|
||||
const stepIdAndKeyPath = part.replace(/{{step.|}}/g, '');
|
||||
const [stepId, ...keyPaths] = stepIdAndKeyPath.split('.');
|
||||
@@ -20,17 +21,36 @@ export default function computeParameters(parameters, executionSteps) {
|
||||
});
|
||||
const data = executionStep?.dataOut;
|
||||
const dataValue = get(data, keyPath);
|
||||
|
||||
// Covers both arrays and objects
|
||||
if (typeof dataValue === 'object') {
|
||||
return JSON.stringify(dataValue);
|
||||
}
|
||||
|
||||
return dataValue;
|
||||
}
|
||||
|
||||
return part;
|
||||
})
|
||||
.join('');
|
||||
}).join('');
|
||||
|
||||
return {
|
||||
...result,
|
||||
[key]: computedValue,
|
||||
};
|
||||
// challenge the input to see if it is stringifies object or array
|
||||
try {
|
||||
const parsedValue = JSON.parse(computedValue);
|
||||
|
||||
if (typeof parsedValue === 'number') {
|
||||
throw new Error('Use original unparsed value.');
|
||||
}
|
||||
|
||||
return {
|
||||
...result,
|
||||
[key]: parsedValue,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
...result,
|
||||
[key]: computedValue,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
|
@@ -1,65 +1,43 @@
|
||||
import HttpError from '../../errors/http.js';
|
||||
import axios from '../axios-with-proxy.js';
|
||||
|
||||
// Mutates the `toInstance` by copying the request interceptors from `fromInstance`
|
||||
const copyRequestInterceptors = (fromInstance, toInstance) => {
|
||||
// Copy request interceptors
|
||||
fromInstance.interceptors.request.forEach(interceptor => {
|
||||
toInstance.interceptors.request.use(
|
||||
interceptor.fulfilled,
|
||||
interceptor.rejected,
|
||||
{
|
||||
synchronous: interceptor.synchronous,
|
||||
runWhen: interceptor.runWhen
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
import { createInstance } from '../axios-with-proxy.js';
|
||||
|
||||
export default function createHttpClient({ $, baseURL, beforeRequest = [] }) {
|
||||
const instance = axios.create({
|
||||
baseURL,
|
||||
});
|
||||
async function interceptResponseError(error) {
|
||||
const { config, response } = error;
|
||||
// Do not destructure `status` from `error.response` because it might not exist
|
||||
const status = response?.status;
|
||||
|
||||
// 1. apply the beforeRequest functions from the app
|
||||
instance.interceptors.request.use((requestConfig) => {
|
||||
const result = beforeRequest.reduce((newConfig, beforeRequestFunc) => {
|
||||
return beforeRequestFunc($, newConfig);
|
||||
}, requestConfig);
|
||||
if (
|
||||
// TODO: provide a `shouldRefreshToken` function in the app
|
||||
(status === 401 || status === 403) &&
|
||||
$.app.auth &&
|
||||
$.app.auth.refreshToken &&
|
||||
!$.app.auth.isRefreshTokenRequested
|
||||
) {
|
||||
$.app.auth.isRefreshTokenRequested = true;
|
||||
await $.app.auth.refreshToken($);
|
||||
|
||||
return result;
|
||||
});
|
||||
// retry the previous request before the expired token error
|
||||
const newResponse = await instance.request(config);
|
||||
$.app.auth.isRefreshTokenRequested = false;
|
||||
|
||||
// 2. inherit the request inceptors from the parent instance
|
||||
copyRequestInterceptors(axios, instance);
|
||||
|
||||
instance.interceptors.response.use(
|
||||
(response) => response,
|
||||
async (error) => {
|
||||
const { config, response } = error;
|
||||
// Do not destructure `status` from `error.response` because it might not exist
|
||||
const status = response?.status;
|
||||
|
||||
if (
|
||||
// TODO: provide a `shouldRefreshToken` function in the app
|
||||
(status === 401 || status === 403) &&
|
||||
$.app.auth &&
|
||||
$.app.auth.refreshToken &&
|
||||
!$.app.auth.isRefreshTokenRequested
|
||||
) {
|
||||
$.app.auth.isRefreshTokenRequested = true;
|
||||
await $.app.auth.refreshToken($);
|
||||
|
||||
// retry the previous request before the expired token error
|
||||
const newResponse = await instance.request(config);
|
||||
$.app.auth.isRefreshTokenRequested = false;
|
||||
|
||||
return newResponse;
|
||||
}
|
||||
|
||||
throw new HttpError(error);
|
||||
return newResponse;
|
||||
}
|
||||
);
|
||||
|
||||
throw new HttpError(error);
|
||||
};
|
||||
|
||||
const instance = createInstance(
|
||||
{
|
||||
baseURL,
|
||||
},
|
||||
{
|
||||
requestInterceptor: beforeRequest.map((originalBeforeRequest) => {
|
||||
return async (requestConfig) => await originalBeforeRequest($, requestConfig);
|
||||
}),
|
||||
responseErrorInterceptor: interceptResponseError,
|
||||
}
|
||||
)
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
@@ -63,6 +63,8 @@ export default async (flowId, request, response) => {
|
||||
});
|
||||
|
||||
if (testRun) {
|
||||
response.status(204).end();
|
||||
|
||||
// in case of testing, we do not process the whole process.
|
||||
continue;
|
||||
}
|
||||
@@ -74,6 +76,12 @@ export default async (flowId, request, response) => {
|
||||
executionId,
|
||||
});
|
||||
|
||||
if (actionStep.appKey === 'filter' && !actionExecutionStep.dataOut) {
|
||||
response.status(422).end();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (actionStep.key === 'respondWith' && !response.headersSent) {
|
||||
const { headers, statusCode, body } = actionExecutionStep.dataOut;
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
const infoMock = () => {
|
||||
return {
|
||||
data: {
|
||||
isCloud: false,
|
||||
isMation: false,
|
||||
isEnterprise: true,
|
||||
docsUrl: 'https://automatisch.io/docs',
|
||||
installationCompleted: true,
|
||||
isCloud: false,
|
||||
isEnterprise: true,
|
||||
isMation: false,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
|
@@ -14,7 +14,7 @@ connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||
7. Click on the **Select all** and then click on the **Create** button.
|
||||
8. Now, copy your **API key secret** and paste the key into the **API Key** field in Automatisch.
|
||||
9. Write any screen name to be displayed in Automatisch.
|
||||
10. You can find your project ID next to your project name. Paste the id into **Project ID** field in Automatsich.
|
||||
11. If you are using self-hosted Appwrite project, you can paste the instace url into **Appwrite instance URL** field in Automatisch.
|
||||
10. You can find your project ID next to your project name. Paste the id into **Project ID** field in Automatisch.
|
||||
11. If you are using self-hosted Appwrite project, you can paste the instance url into **Appwrite instance URL** field in Automatisch.
|
||||
12. Fill the host name field with the hostname of your instance URL. It's either `cloud.appwrite.io` or hostname of your instance URL.
|
||||
13. Start using Appwrite integration with Automatisch!
|
||||
|
@@ -1,7 +1,7 @@
|
||||
---
|
||||
favicon: /favicons/appwrite.svg
|
||||
items:
|
||||
- name: New documets
|
||||
- name: New documents
|
||||
desc: Triggers when a new document is created.
|
||||
---
|
||||
|
||||
|
@@ -8,11 +8,6 @@
|
||||
name="description"
|
||||
content="Build workflow automation without spending time and money. No code is required."
|
||||
/>
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
|
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"short_name": "automatisch",
|
||||
"name": "automatisch",
|
||||
"description": "Build workflow automation without spending time and money. No code is required.",
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
@@ -3,7 +3,6 @@ import * as React from 'react';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { useFormContext, useWatch } from 'react-hook-form';
|
||||
import Stack from '@mui/material/Stack';
|
||||
import Box from '@mui/material/Box';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import Divider from '@mui/material/Divider';
|
||||
import IconButton from '@mui/material/IconButton';
|
||||
@@ -12,6 +11,7 @@ import AddIcon from '@mui/icons-material/Add';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
import InputCreator from 'components/InputCreator';
|
||||
import { EditorContext } from 'contexts/Editor';
|
||||
import { Grid } from '@mui/material';
|
||||
|
||||
const createGroupItem = () => ({
|
||||
key: '',
|
||||
@@ -122,7 +122,7 @@ function FilterConditions(props) {
|
||||
<React.Fragment>
|
||||
<Stack sx={{ width: '100%' }} direction="column" spacing={2} mt={2}>
|
||||
{groups?.map((group, groupIndex) => (
|
||||
<>
|
||||
<React.Fragment key={groupIndex}>
|
||||
{groupIndex !== 0 && <Divider />}
|
||||
|
||||
<Typography variant="subtitle2" gutterBottom>
|
||||
@@ -133,19 +133,16 @@ function FilterConditions(props) {
|
||||
</Typography>
|
||||
|
||||
{group?.and?.map((groupItem, groupItemIndex) => (
|
||||
<Stack direction="row" spacing={2} key={`item-${groupItem.id}`}>
|
||||
<Stack
|
||||
direction={{ xs: 'column', sm: 'row' }}
|
||||
spacing={{ xs: 2 }}
|
||||
sx={{ display: 'flex', flex: 1 }}
|
||||
<Grid container key={`item-${groupItem.id}`}>
|
||||
<Grid
|
||||
container
|
||||
spacing={2}
|
||||
item
|
||||
xs={12}
|
||||
sm={11}
|
||||
sx={{ order: { xs: 2, sm: 1 } }}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flex: '1 0 0px',
|
||||
maxWidth: ['100%', '33%'],
|
||||
}}
|
||||
>
|
||||
<Grid item xs={12} md={4}>
|
||||
<InputCreator
|
||||
schema={createStringArgument({
|
||||
key: `or.${groupIndex}.and.${groupItemIndex}.key`,
|
||||
@@ -155,15 +152,8 @@ function FilterConditions(props) {
|
||||
stepId={stepId}
|
||||
disabled={editorContext.readOnly}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flex: '1 0 0px',
|
||||
maxWidth: ['100%', '33%'],
|
||||
}}
|
||||
>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={4}>
|
||||
<InputCreator
|
||||
schema={createDropdownArgument({
|
||||
key: `or.${groupIndex}.and.${groupItemIndex}.operator`,
|
||||
@@ -174,15 +164,8 @@ function FilterConditions(props) {
|
||||
stepId={stepId}
|
||||
disabled={editorContext.readOnly}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flex: '1 0 0px',
|
||||
maxWidth: ['100%', '33%'],
|
||||
}}
|
||||
>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={4}>
|
||||
<InputCreator
|
||||
schema={createStringArgument({
|
||||
key: `or.${groupIndex}.and.${groupItemIndex}.value`,
|
||||
@@ -192,18 +175,28 @@ function FilterConditions(props) {
|
||||
stepId={stepId}
|
||||
disabled={editorContext.readOnly}
|
||||
/>
|
||||
</Box>
|
||||
</Stack>
|
||||
|
||||
<IconButton
|
||||
size="small"
|
||||
edge="start"
|
||||
onClick={() => removeGroupItem(groupIndex, groupItemIndex)}
|
||||
sx={{ width: 61, height: 61 }}
|
||||
>
|
||||
<RemoveIcon />
|
||||
</IconButton>
|
||||
</Stack>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={1} sx={{ order: { xs: 1, sm: 2 } }}>
|
||||
<Stack justifyContent="center" alignItems="flex-end">
|
||||
<IconButton
|
||||
size="small"
|
||||
edge="start"
|
||||
onClick={() =>
|
||||
removeGroupItem(groupIndex, groupItemIndex)
|
||||
}
|
||||
sx={{
|
||||
width: 40,
|
||||
height: 40,
|
||||
mb: { xs: 2, sm: 0 },
|
||||
}}
|
||||
disabled={groups.length === 1 && group.and.length === 1}
|
||||
>
|
||||
<RemoveIcon />
|
||||
</IconButton>
|
||||
</Stack>
|
||||
</Grid>
|
||||
</Grid>
|
||||
))}
|
||||
|
||||
<Stack spacing={1} direction="row">
|
||||
@@ -227,7 +220,7 @@ function FilterConditions(props) {
|
||||
</IconButton>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</Stack>
|
||||
</React.Fragment>
|
||||
|
@@ -44,7 +44,7 @@ function InstallationForm() {
|
||||
|
||||
const handleOnRedirect = () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['automatisch', 'config'],
|
||||
queryKey: ['automatisch', 'info'],
|
||||
});
|
||||
};
|
||||
|
||||
|
@@ -19,7 +19,13 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
|
||||
const value = joinBy('.', parentKey, index?.toString(), name);
|
||||
|
||||
if (Array.isArray(sampleValue)) {
|
||||
return sampleValue.flatMap((item, index) =>
|
||||
const arrayItself = {
|
||||
label,
|
||||
value,
|
||||
sampleValue: JSON.stringify(sampleValue),
|
||||
};
|
||||
|
||||
const arrayItems = sampleValue.flatMap((item, index) =>
|
||||
process({
|
||||
data: item,
|
||||
parentKey: value,
|
||||
@@ -27,6 +33,9 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
|
||||
parentLabel: label,
|
||||
}),
|
||||
);
|
||||
|
||||
// TODO: remove spreading
|
||||
return [arrayItself, ...arrayItems];
|
||||
}
|
||||
|
||||
if (typeof sampleValue === 'object' && sampleValue !== null) {
|
||||
@@ -36,6 +45,7 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
|
||||
parentLabel: label,
|
||||
});
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
label,
|
||||
|
@@ -29,14 +29,16 @@ import adminSettingsRoutes from './adminSettingsRoutes';
|
||||
import Notifications from 'pages/Notifications';
|
||||
import useAutomatischConfig from 'hooks/useAutomatischConfig';
|
||||
import useAuthentication from 'hooks/useAuthentication';
|
||||
import useAutomatischInfo from 'hooks/useAutomatischInfo';
|
||||
import Installation from 'pages/Installation';
|
||||
|
||||
function Routes() {
|
||||
const { data: configData, isSuccess } = useAutomatischConfig();
|
||||
const { data: automatischInfo, isSuccess } = useAutomatischInfo();
|
||||
const { data: configData } = useAutomatischConfig();
|
||||
const { isAuthenticated } = useAuthentication();
|
||||
const config = configData?.data;
|
||||
|
||||
const installed = isSuccess ? config?.['installation.completed'] === true : true;
|
||||
const installed = isSuccess ? automatischInfo.data.installationCompleted : true;
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
|
Reference in New Issue
Block a user