From c67ca12f26e3305c5f343bfaf6040be92391cc5b Mon Sep 17 00:00:00 2001 From: Ben Furber Date: Tue, 3 Sep 2024 14:26:54 +0100 Subject: [PATCH] feat: show clear when research update is draft --- .../src/integration/research/write.spec.ts | 18 +- .../Content/Common/ResearchUpdate.form.tsx | 60 ++-- .../Research/Content/ResearchArticle.tsx | 11 +- src/pages/Research/Content/ResearchUpdate.tsx | 288 ++++++++++-------- 4 files changed, 216 insertions(+), 161 deletions(-) diff --git a/packages/cypress/src/integration/research/write.spec.ts b/packages/cypress/src/integration/research/write.spec.ts index 7b09c2383f..0e8758aeb3 100644 --- a/packages/cypress/src/integration/research/write.spec.ts +++ b/packages/cypress/src/integration/research/write.spec.ts @@ -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() @@ -313,6 +312,23 @@ 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.get('[data-cy=intro-title').click() + 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') }) }) }) diff --git a/src/pages/Research/Content/Common/ResearchUpdate.form.tsx b/src/pages/Research/Content/Common/ResearchUpdate.form.tsx index 4b9a107ec1..4f35897e14 100644 --- a/src/pages/Research/Content/Common/ResearchUpdate.form.tsx +++ b/src/pages/Research/Content/Common/ResearchUpdate.form.tsx @@ -258,13 +258,34 @@ export const ResearchUpdateForm = observer((props: IProps) => { px={2} mt={[0, 0, 4]} > - + + + {isEdit ? ( ) : null} - { {store.activeResearchItem ? ( { showBackToResearchButton={true} /> ) : null} - + { ).length || 0 } /> - + {item && getPublicUpdates(item, researchStore.activeUser).map( (update, index) => ( @@ -227,7 +234,7 @@ const ResearchArticle = observer(() => { /> ), )} - + { files, fileLink, images, + status, title, videoUrl, } = update @@ -62,164 +64,190 @@ const ResearchUpdate = (props: IProps) => { } const displayNumber = updateIndex + 1 + const isDraft = status == 'draft' return ( + {isDraft && ( + <> + + + + )} + - - {displayNumber} - + + + {displayNumber} + - {research && ( - - )} - + {research && ( + + )} + - - - - - - {contributors.length > 0 ? ( - - - - ) : null} - - - {title} - - + + + + + + {contributors.length > 0 ? ( + + + + ) : null} - - - - {'created ' + formattedCreateDatestamp} - - - {formattedCreateDatestamp !== formattedModifiedDatestamp && ( + + {title} + + + + + - {'edited ' + formattedModifiedDatestamp} + {'created ' + formattedCreateDatestamp} + + {formattedCreateDatestamp !== + formattedModifiedDatestamp && ( + + {'edited ' + formattedModifiedDatestamp} + + )} + + {/* Show edit button for the creator of the research OR a super-admin */} + {isEditable && ( + + + )} - {/* Show edit button for the creator of the research OR a super-admin */} - {isEditable && ( - - - - )} + + + {description} + + - - + {videoUrl ? ( + + ) : ( + + )} + + {((files && files.length > 0) || fileLink) && ( + - {description} - - - - - {videoUrl ? ( - - ) : ( - + {fileLink && ( + + )} + {files && + files + .filter(Boolean) + .map( + (file, index) => + file && ( + + ), + )} + + )} - - {((files && files.length > 0) || fileLink) && ( - - {fileLink && ( - - )} - {files && - files - .filter(Boolean) - .map( - (file, index) => - file && ( - - ), - )} - - - )} - - + + + )