refactor(web): fix types

This commit is contained in:
Ali BARIN
2022-10-06 17:40:48 +02:00
committed by Faruk AYDIN
parent 0825eb36e4
commit ae76f7100c
30 changed files with 12 additions and 15 deletions

View File

@@ -10,8 +10,7 @@ class App {
// Temporaryly restrict the apps we expose until
// their actions/triggers are implemented!
static temporaryList = ['slack2', 'twitter2'];
// static temporaryList = ['slack', 'twitter', 'scheduler'];
static temporaryList = ['slack', 'twitter'];
static async findAll(name?: string): Promise<IApp[]> {
if (!name)

View File

@@ -204,6 +204,7 @@ export interface IAuthentication {
}
export interface ISubstep {
key: string;
name: string;
arguments: IField[];
}

View File

@@ -30,7 +30,8 @@ type Response = {
export default function AddAppConnection(props: AddAppConnectionProps): React.ReactElement {
const { application, connectionId, onClose } = props;
const { name, authDocUrl, key, fields, authenticationSteps, reconnectionSteps } = application;
const { name, authDocUrl, key, auth } = application;
const { fields, authenticationSteps, reconnectionSteps } = auth;
const formatMessage = useFormatMessage();
const [errorMessage, setErrorMessage] = React.useState<string | null>(null);
const [inProgress, setInProgress] = React.useState(false);

View File

@@ -12,7 +12,7 @@ import useFormatMessage from 'hooks/useFormatMessage';
import { EditorContext } from 'contexts/Editor';
import { GET_APPS } from 'graphql/queries/get-apps';
import FlowSubstepTitle from 'components/FlowSubstepTitle';
import type { IApp, IStep, ISubstep } from '@automatisch/types';
import type { IApp, IStep, ISubstep, ITrigger, IAction } from '@automatisch/types';
type ChooseAppAndEventSubstepProps = {
substep: ISubstep;
@@ -24,7 +24,7 @@ type ChooseAppAndEventSubstepProps = {
step: IStep;
};
const optionGenerator = (app: IApp): { label: string; value: string } => ({
const optionGenerator = (app: { name: string, key: string, }): { label: string; value: string } => ({
label: app.name as string,
value: app.key as string,
});
@@ -68,7 +68,7 @@ function ChooseAppAndEventSubstep(
const selectedActionOrTrigger =
actionsOrTriggers?.find(
(actionOrTrigger) => actionOrTrigger.key === step?.key
) || null;
);
const { name } = substep;
@@ -179,11 +179,11 @@ function ChooseAppAndEventSubstep(
</Box>
)}
{isTrigger && selectedActionOrTrigger?.pollInterval && (
{isTrigger && (selectedActionOrTrigger as ITrigger)?.pollInterval && (
<TextField
label={formatMessage('flowEditor.pollIntervalLabel')}
value={formatMessage('flowEditor.pollIntervalValue', {
minutes: selectedActionOrTrigger.pollInterval,
minutes: (selectedActionOrTrigger as ITrigger)?.pollInterval,
})}
sx={{ mt: 2 }}
fullWidth

View File

@@ -235,7 +235,7 @@ export default function FlowStep(
>
<ChooseAppAndEventSubstep
expanded={currentSubstep === 0}
substep={{ name: 'Choose app & event', arguments: [] }}
substep={{ key: 'chooAppAndEvent', name: 'Choose app & event', arguments: [] }}
onExpand={() => toggleSubstep(0)}
onCollapse={() => toggleSubstep(0)}
onSubmit={expandNextStep}
@@ -246,11 +246,7 @@ export default function FlowStep(
{substeps?.length > 0 &&
substeps.map(
(
substep: {
name: string;
key: string;
arguments: IField[];
},
substep: ISubstep,
index: number
) => (
<React.Fragment key={`${substep?.name}-${index}`}>
@@ -279,7 +275,7 @@ export default function FlowStep(
/>
)}
{['chooseConnection', 'testStep'].includes(substep.key) ===
{substep.key && ['chooseConnection', 'testStep'].includes(substep.key) ===
false && (
<FlowSubstep
expanded={currentSubstep === index + 1}