Skip to content

Commit

Permalink
first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
dkent600 committed Aug 18, 2020
1 parent db10bd4 commit 214f3f4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/components/Proposal/ProposalDetails.scss
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,32 @@ button.disabled {
flex-grow: 1;
min-width: 320px;
max-width: 40%;

.eventHistory {
display: table;
width: 100%;
margin-left: 20px;

.event {
font-size: 16px;
display: table-row;
white-space: nowrap;

.label,
.datetime {
display: table-cell;
padding-bottom: 6px;
}

.label {
color: #4f6176;
}

.datetime {
color: #9aa9b5;
}
}
}
}

.createdBy {
Expand Down
15 changes: 14 additions & 1 deletion src/components/Proposal/ProposalDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AccountProfileName from "components/Account/AccountProfileName";
import ProposalCountdown from "components/Shared/ProposalCountdown";
import FollowButton from "components/Shared/FollowButton";
import { DiscussionEmbed } from "disqus-react";
import { humanProposalTitle, ensureHttps } from "lib/util";
import { humanProposalTitle, ensureHttps, formatFriendlyDateForLocalTimezone, safeMoment } from "lib/util";
import { schemeName } from "lib/schemeUtils";
import Analytics from "lib/analytics";
import { Page } from "pages";
Expand Down Expand Up @@ -305,6 +305,19 @@ class ProposalDetailsPage extends React.Component<IProps, IState> {
</div>
</div>

<div className={css.eventHistory}>
<div className={css.event}>
<div className={css.label}>Created:</div>
<div className={css.datetime}>{formatFriendlyDateForLocalTimezone(safeMoment(proposal.createdAt))}</div>
</div>
{proposal.executedAt ?
<div className={css.event}>
<div className={css.label}>Executed:</div>
<div className={css.datetime}>{formatFriendlyDateForLocalTimezone(safeMoment(proposal.executedAt))}</div>
</div>
: ""}
</div>

</div>
</div>

Expand Down
24 changes: 24 additions & 0 deletions src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,3 +678,27 @@ export function ethBalance(address: Address): Observable<BN> {

return observable.pipe(map((item: any) => new BN(item)));
}

/**
* arc.js is inconsistent in how it returns datetimes.
* Convert all possibilities safely to a `moment`.
* Is OK when the dateSpecifier is already a moment.
* If is a string, must be ISO-conformant.
* @param dateSpecifier
*/
export function safeMoment(dateSpecifier: moment.Moment | Date | number | string | undefined): moment.Moment {
switch (typeof dateSpecifier) {
case "object":
if (moment.isMoment(dateSpecifier)) {
return dateSpecifier;
}
// else assume is a Date, fallthrough
case "string":
return moment(dateSpecifier);
case "number":
// then should be a count of seconds in UNIX epoch
return moment.unix(dateSpecifier);
default:
throw new Error(`safeMoment: unknown type: ${typeof dateSpecifier}`);
}
}

0 comments on commit 214f3f4

Please sign in to comment.