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

View File

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

View File

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

View File

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

View File

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