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(operator): Add Org DeleteOn and Account CancelledAt dates #6736

Merged
merged 2 commits into from
Jun 21, 2023
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"prettier:fix": "pretty-quick --config .prettierrc.json --write '{src,cypress}/**/*.{ts,tsx}'",
"tsc": "tsc -p ./tsconfig.json --noEmit --pretty --skipLibCheck",
"tsc:watch": "yarn tsc --watch",
"generate": "export SHA=eec3a9ed87d664529e6a5dddad76232ed9e823bf && export REMOTE=https://raw.githubusercontent.com/influxdata/openapi/${SHA}/ && yarn generate-meta",
"generate": "export SHA=993f6756500aebe47903a3ddaee62f9f75d207c1 && export REMOTE=https://raw.githubusercontent.com/influxdata/openapi/${SHA}/ && yarn generate-meta",
"generate-local": "export REMOTE=../openapi/ && yarn generate-meta",
"generate-local-cloud": "export REMOTE=../openapi/ && yarn generate-meta-cloud",
"generate-meta": "if [ -z \"${CLOUD_URL}\" ]; then yarn generate-meta-oss; else yarn generate-meta-cloud; fi",
Expand Down
23 changes: 23 additions & 0 deletions src/operator/OrgOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ const OrgOverlay: FC = () => {
history.goBack()
}

const deleteOn = organization?.deleteOn
? new Date(organization?.deleteOn)
: null
const hasDeleteDate = Boolean(deleteOn)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One possibility here is that the deleteOn string exists but isn't valid, so new Date evaluates to NaN. That would cause any methods chained off deleteOn to fail, but you should be fine here since [whatever conditions] && NaN is falsy, so the code that relies on those chained methods will not render.

What could be more explicit (and defer to you on which you prefer) would be to separate the variable that gates whether to render the data from the data that is being rendered, so that we know the rendering condition can only be true or false.

const deleteOn = organization?.deleteOn ? new Date(organization?.deleteOn) : null
const hasDeleteDate = Boolean(deleteOn)

And then make the condition for rendering hasDeleteDate

But up to you - I've done some testing here and both should have the same effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think that's probably a good change. Plus hasDeleteDate is a better name for a rendering condition than just the truthiness of deleteOn

return (
<Overlay
visible={true}
Expand Down Expand Up @@ -171,6 +176,24 @@ const OrgOverlay: FC = () => {
<p>{organization?.account?.type ?? ''}</p>
</Grid.Column>
</Grid.Row>
<Grid.Row>
<Grid.Column widthMD={Columns.Four}>
<label className="org-overlay-detail--text">
Organization State
</label>
<p>{organization?.state ?? ''}</p>
</Grid.Column>
<Grid.Column widthMD={Columns.Four}>
<label className="org-overlay-detail--text">
Delete On
</label>
<p>
{organization?.state === 'suspended' && hasDeleteDate
? `${deleteOn.toLocaleTimeString()} ${deleteOn.toDateString()}`
: 'N/A'}
</p>
</Grid.Column>
</Grid.Row>
<SpinnerContainer
loading={limitsStatus}
spinnerComponent={<TechnoSpinner diameterPixels={100} />}
Expand Down
14 changes: 14 additions & 0 deletions src/operator/account/AccountGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const AccountGrid: FC = () => {
return account?.marketplaceSubscription?.subscriberId ?? 'N/A'
}

const cancelledAt = account?.cancelledAt
? new Date(account?.cancelledAt)
: null
const hasCancelledAt = Boolean(cancelledAt)

return (
<FlexBox
direction={FlexDirection.Row}
Expand Down Expand Up @@ -47,6 +52,15 @@ const AccountGrid: FC = () => {
body={organizations?.[0]?.provider ?? 'N/A'}
testID="cloud-provider"
/>
<AccountField
header="Cancelled At"
body={
account.type === 'cancelled' && hasCancelledAt
? `${cancelledAt.toLocaleTimeString()} ${cancelledAt.toDateString()}`
: 'N/A'
}
testID="cancelled-at"
/>
</FlexBox>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; but if you change anything based on the above comment, this component should have the same logic. 👍

<FlexBox
direction={FlexDirection.Column}
Expand Down