Skip to content

Commit

Permalink
fix: remove revert to draft state (#3949)
Browse files Browse the repository at this point in the history
  • Loading branch information
mchen10 authored Oct 28, 2024
1 parent 5b8b1bb commit 6a13622
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/pages/Howto/Content/Common/HowtoButtonDraft.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Button } from 'oa-components'
import { IModerationStatus } from 'oa-shared'
import { Flex, Text } from 'theme-ui'

import { buttons } from '../../labels'

import type { FormApi } from 'final-form'
import type { IModerationStatus } from 'oa-shared'

interface IProps {
form: FormApi
Expand All @@ -14,10 +14,8 @@ interface IProps {
}

export const HowtoButtonDraft = (props: IProps) => {
const { form, formId, moderation, submitting } = props
const { create, description, update } = buttons.draft

const text = moderation !== IModerationStatus.DRAFT ? create : update
const { form, formId, submitting } = props
const { create, description } = buttons.draft

return (
<Flex sx={{ flexDirection: 'column', alignItems: 'center' }}>
Expand All @@ -31,7 +29,7 @@ export const HowtoButtonDraft = (props: IProps) => {
sx={{ width: '100%', display: 'block' }}
form={formId}
>
<span>{text}</span>
<span>{create}</span>
</Button>
<Text sx={{ fontSize: 1, textAlign: 'center' }}>{description}</Text>
</Flex>
Expand Down
1 change: 0 additions & 1 deletion src/pages/Howto/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const headings = {
export const buttons = {
draft: {
create: 'Save draft',
update: 'Revert to draft',
description: 'A draft can be saved any time',
},
files: 'Re-upload files (this will delete the existing ones)',
Expand Down
6 changes: 2 additions & 4 deletions src/pages/Research/Content/Common/Research.form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const ResearchFormLabel = ({ children, ...props }) => (

const ResearchForm = observer((props: IProps) => {
const { formValues, parentType } = props
const { create, update } = buttons.draft
const { create } = buttons.draft

formValues.researchStatus = formValues.researchStatus || 'In progress'

Expand Down Expand Up @@ -106,8 +106,6 @@ const ResearchForm = observer((props: IProps) => {
await store.uploadResearch(formValues)
}

const draftButtonText =
formValues.moderation !== IModerationStatus.DRAFT ? create : update
const pageTitle = headings.overview[parentType]

return (
Expand Down Expand Up @@ -323,7 +321,7 @@ const ResearchForm = observer((props: IProps) => {
disabled={submitting}
sx={{ width: '100%', display: 'block' }}
>
<span>{draftButtonText}</span>
<span>{create}</span>
</Button>

<Button
Expand Down

0 comments on commit 6a13622

Please sign in to comment.