Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show clearly when research update is draft #3838

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion packages/cypress/src/integration/research/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ describe('[Research]', () => {
cy.get('[data-cy=create]').click()

cy.step('Enter research article details')

cy.get('[data-cy=intro-title').clear().type(expected.title).blur()
cy.get('[data-cy=intro-description]').clear().type(expected.description)
cy.get('[data-cy=submit]').click()
Expand Down Expand Up @@ -313,6 +312,24 @@ describe('[Research]', () => {
cy.visit(`/research/${expected.slug}`)

cy.contains(updateTitle)
cy.get('[data-cy=DraftUpdateLabel]').should('be.visible')

cy.step('Draft not visible to others')
cy.logout()
cy.visit(`/research/${expected.slug}`)
cy.get(updateTitle).should('not.exist')
cy.get('[data-cy=DraftUpdateLabel]').should('not.exist')

cy.step('Draft updates can be published')
cy.login(researcherEmail, researcherPassword)
cy.visit(`/research/${expected.slug}`)
cy.get('[data-cy=edit-update]').click()
cy.contains('Edit your update')
cy.get('[data-cy=videoUrl]').clear().type(updateVideoUrl).blur()
cy.get('[data-cy=submit]').click()
cy.get('[data-cy=view-research]:enabled', { timeout: 20000 }).click()
cy.contains(updateTitle)
cy.get('[data-cy=DraftUpdateLabel]').should('not.exist')
})
})
})
60 changes: 32 additions & 28 deletions src/pages/Research/Content/Common/ResearchUpdate.form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,25 +258,50 @@ export const ResearchUpdateForm = observer((props: IProps) => {
px={2}
mt={[0, 0, 4]}
>
<Box
<Flex
sx={{
flexDirection: 'column',
position: ['relative', 'relative', 'sticky'],
top: 3,
gap: 3,
maxWidth: ['inherit', 'inherit', '400px'],
}}
>
<Button
large
id="submit-form"
data-testid="submit-form"
data-cy="submit"
onClick={(evt) => {
trySubmitForm(false)
evt.preventDefault()
}}
variant="primary"
type="submit"
disabled={submitting}
sx={{
alignSelf: 'stretch',
justifyContent: 'center',
}}
>
{publishButtonText}
</Button>

<Button
data-cy="draft"
onClick={() => {
trySubmitForm(true)
}}
variant="secondary"
type="submit"
sx={{
alignSelf: 'stretch',
justifyContent: 'center',
}}
disabled={submitting}
sx={{ width: '100%', display: 'block', mt: 0 }}
>
<span>{draftButtonText}</span>
{draftButtonText}
</Button>

{isEdit ? (
<Button
data-cy="delete"
Expand All @@ -287,32 +312,11 @@ export const ResearchUpdateForm = observer((props: IProps) => {
variant="destructive"
type="submit"
disabled={submitting}
sx={{ width: '100%', display: 'block', mt: 3 }}
sx={{ alignSelf: 'stretch', justifyContent: 'center' }}
>
{deletion.text}
</Button>
) : null}
<Button
large
id="submit-form"
data-testid="submit-form"
data-cy="submit"
onClick={(evt) => {
trySubmitForm(false)
evt.preventDefault()
}}
variant="primary"
type="submit"
disabled={submitting}
sx={{
mt: 3,
mb: ['40px', '40px', 0],
width: '100%',
justifyContent: 'center',
}}
>
<span>{publishButtonText}</span>
</Button>

<ResearchErrors
errors={errors}
Expand All @@ -322,7 +326,7 @@ export const ResearchUpdateForm = observer((props: IProps) => {

{store.activeResearchItem ? (
<ResearchEditorOverview
sx={{ mt: 4 }}
sx={{ mt: 2 }}
updates={getResearchUpdates(
store.activeResearchItem.updates || [],
store.activeResearchItem._id,
Expand All @@ -334,7 +338,7 @@ export const ResearchUpdateForm = observer((props: IProps) => {
showBackToResearchButton={true}
/>
) : null}
</Box>
</Flex>
</Flex>
<ConfirmModal
isOpen={showDeleteModal}
Expand Down
11 changes: 9 additions & 2 deletions src/pages/Research/Content/ResearchArticle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,14 @@ const ResearchArticle = observer(() => {
).length || 0
}
/>
<Box sx={{ marginTop: 8, marginBottom: 4 }}>
<Flex
sx={{
flexDirection: 'column',
marginTop: 8,
marginBottom: 4,
gap: [4, 6],
}}
>
{item &&
getPublicUpdates(item, researchStore.activeUser).map(
(update, index) => (
Expand All @@ -227,7 +234,7 @@ const ResearchArticle = observer(() => {
/>
),
)}
</Box>
</Flex>

<UserEngagementWrapper>
<Box
Expand Down
Loading
Loading