import { BaseHeaderLayout, Flex, Link, TextInput, Typography, Button } from '@strapi/design-system'; import { useState } from 'react'; import PageWrapper from '../../components/PageWrapper'; import useFormattedLabel from '../../hooks/useFormattedLabel'; import { useFetchClient } from '@strapi/helper-plugin'; import pluginId from '../../pluginId'; import { useHistory } from 'react-router-dom'; import { ArrowLeft } from '@strapi/icons'; export default function AddNewWorkflow() { const { goBack } = useHistory(); const [workflow, setWorkflow] = useState(''); const [branch, setBranch] = useState(''); const [githubAccount, setGithubAccount] = useState(''); const [repo, setRepo] = useState(''); const [githubToken, setGithubToken] = useState(''); const { post } = useFetchClient(); const PAGE_TITLE = 'Add New Workflow'; const HEADER_TITLE = 'Add New Workflow'; const HEADER_SUBTITLE = 'Add a new workflow to update the static content'; const GITHUB_TOKEN = useFormattedLabel('settings.fields.githubtoken'); const REPO = useFormattedLabel('settings.fields.repo'); const WORKFLOWID = useFormattedLabel('settings.fields.workflowid'); const OWNER = useFormattedLabel('settings.fields.owner'); const BRANCH = useFormattedLabel('settings.fields.branch'); const HINT_GITHUB_TOKEN = useFormattedLabel('settings.fields.hint.githubtoken'); const HINT_OWNER = useFormattedLabel('settings.fields.hint.owner'); const HINT_REPO = useFormattedLabel('settings.fields.hint.repo'); const HINT_WORKFLOWID = useFormattedLabel('settings.fields.hint.workflowid'); const HINT_BRANCH = useFormattedLabel('settings.fields.hint.branch'); const PLACEHOLDER_GITHUB_TOKEN = useFormattedLabel('settings.fields.placeholder.githubtoken'); const PLACEHOLDER_OWNER = useFormattedLabel('settings.fields.placeholder.owner'); const PLACEHOLDER_REPO = useFormattedLabel('settings.fields.placeholder.repo'); const PLACEHOLDER_WORKFLOWID = useFormattedLabel('settings.fields.placeholder.workflowid'); const PLACEHOLDER_BRANCH = useFormattedLabel('settings.fields.placeholder.branch'); const BUTTON_DETAILS = useFormattedLabel('button.details'); const BACK_BUTTON = useFormattedLabel('button.back'); const SAVE_BUTTON = useFormattedLabel('button.save') return ( }> {BACK_BUTTON} } /> } pageTitle={PAGE_TITLE} >
{ e.preventDefault(); if (githubToken && githubAccount && repo && workflow && branch) { await post(`/${pluginId}/config`, { githubToken, githubAccount, repo, workflow, branch, }); goBack(); } else { console.error('Please fill all the fields'); } }} > setGithubToken(e.target.value)} placeholder={PLACEHOLDER_GITHUB_TOKEN} required autoComplete="hidden" HintMessage={ {HINT_GITHUB_TOKEN}{' '} {BUTTON_DETAILS} } /> setGithubAccount(e.target.value)} placeholder={PLACEHOLDER_OWNER} required HintMessage={{HINT_OWNER}} /> setRepo(e.target.value)} placeholder={PLACEHOLDER_REPO} required HintMessage={{HINT_REPO}} /> setBranch(e.target.value)} placeholder={PLACEHOLDER_BRANCH} required HintMessage={{HINT_BRANCH}} /> setWorkflow(e.target.value)} placeholder={PLACEHOLDER_WORKFLOWID} required HintMessage={{HINT_WORKFLOWID}} />
); }