Skip to content

Commit

Permalink
fix: show proposal published and edit dates
Browse files Browse the repository at this point in the history
This commit displays the missing "published" timestamp event for
proposals that have been edited. Also, display timestamps for mobile
views and adds e2e tests to prevent this from happening further.
  • Loading branch information
victorgcramos authored Dec 19, 2021
1 parent 19e2970 commit 8f4a9c1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/components/Proposal/Proposal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ const Proposal = React.memo(function Proposal({
isAuthor && isEditableProposal(proposal, voteSummary) && !isLegacy;
const { apiInfo } = useLoader();
const mobile = useMediaQuery("(max-width: 560px)");
const showEditedDate = version > 1 && timestamp !== publishedat && !mobile;
const showPublishedDate = publishedat && !mobile && !showEditedDate;
const showEditedDate = version > 1 && timestamp !== publishedat;
const showExtendedVersionPicker =
extended && version > 1 && !isCensored && (isVetted || isAuthor || isAdmin);
const showVersionAsText = !extended && !mobile;
Expand Down Expand Up @@ -343,11 +342,13 @@ const Proposal = React.memo(function Proposal({
timestamp={linkby}
/>
)}
{showPublishedDate && (
<span data-testid="proposal-published-timestamp">
<Event event="published" timestamp={publishedat} />
)}
</span>
{showEditedDate && (
<Event event="edited" timestamp={timestamp} />
<span data-testid="proposal-edited-timestamp">
<Event event="edited" timestamp={timestamp} />
</span>
)}
{showVersionAsText && (
<Text
Expand Down
8 changes: 2 additions & 6 deletions src/components/RecordWrapper/RecordWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ export const Subtitle = ({ children, separatorSymbol = "•" }) => (
<Join
className={classNames("margin-top-s", styles.subtitleWrapper)}
SeparatorComponent={() => (
<span className="text-secondary-color margin-left-s margin-right-s">
{separatorSymbol}
</span>
<span className={styles.subtitleSeparator}>{separatorSymbol}</span>
)}>
{children}
</Join>
Expand All @@ -115,9 +113,7 @@ export const JoinTitle = ({ children, className, separatorSymbol = "•" }) => (
<Join
className={classNames(className, styles.flexWrap)}
SeparatorComponent={() => (
<span className="text-secondary-color margin-left-s margin-right-s">
{separatorSymbol}
</span>
<span className={styles.subtitleSeparator}>{separatorSymbol}</span>
)}>
{children}
</Join>
Expand Down
19 changes: 19 additions & 0 deletions src/components/RecordWrapper/RecordWrapper.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
flex-wrap: wrap;
}

.subtitleSeparator {
margin-right: var(--spacing-small);
margin-left: var(--spacing-small);
color: var(--text-secondary-color);
}

.flexWrap {
flex-wrap: wrap;
}
Expand Down Expand Up @@ -150,4 +156,17 @@ div.darkActionsTooltip {
.title {
max-width: 100%;
}

.subtitleWrapper {
flex-flow: column;
max-width: 100%;
}

.subtitleWrapper > .subtitleSeparator {
display: none;
}

.subtitleWrapper > *:not(:first-child) {
padding-top: 1rem;
}
}
4 changes: 4 additions & 0 deletions teste2e/cypress/e2e/proposal/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ describe("Proposal Edit", () => {
.its("status")
.should("eq", 200);
cy.findByText(/version 2/).should("exist");
cy.findByTestId("proposal-published-timestamp").should("be.visible");
cy.findByTestId("proposal-edited-timestamp").should("be.visible");
}
);
});
Expand All @@ -67,6 +69,8 @@ describe("Proposal Edit", () => {
cy.identity();
cy.visit(`record/${shortRecordToken(censorshiprecord.token)}`);
cy.findByTestId(/record-edit-button/i).should("not.exist");
cy.findByTestId("proposal-published-timestamp").should("be.visible");
cy.findByTestId("proposal-edited-timestamp").should("not.exist");
}
);
});
Expand Down

0 comments on commit 8f4a9c1

Please sign in to comment.