Skip to content

chore: refactor frontend to use workspace status directly #4361

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

Merged
merged 11 commits into from
Oct 5, 2022
Prev Previous commit
Next Next commit
Handle disabled button labels separately
  • Loading branch information
presleyp committed Oct 4, 2022
commit 7dc2ef2da316da332d4f1128b25a4ded96d1d46e
2 changes: 1 addition & 1 deletion site/src/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"canceling": "Canceling action",
"canceled": "Canceled action",
"failed": "Failed",
"pending": "Queued"
"pending": "Pending"
},
"deleteDialog": {
"title": "Delete {{entity}}",
Expand Down
5 changes: 5 additions & 0 deletions site/src/i18n/en/workspacePage.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@
"starting": "Starting...",
"stopping": "Stopping...",
"deleting": "Deleting..."
},
Copy link
Member

Choose a reason for hiding this comment

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

Same sort of comment here: I like linking the language to the actual typing that's coming back from the API - that way we get a 1:1 mapping of BE state and UI. In the past, I've managed with constants like:

export const ActionButtonLabels = {
  [WorkspaceStatus.starting]: i18n.t('workspacePage:actionButton.starting'),
  [WorkspaceStatus.stopping]: i18n.t('workspacePage:actionButton.stopping'),
  etc...
} as const;

But that was with enums. @presleyp or @jsjoeio again, is there a way to do this with literals? I feel like I could come over to the dark side if there is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we could define this but with "starting" instead of [WorkspaceStatus.starting], which is not as clear that it's typesafe, but is typesafe. And then we'd know that every value of WorkspaceStatus mapped to some text. How's that? (@jsjoeio def interested in your input on all of this when you're available!)

Copy link
Member

Choose a reason for hiding this comment

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

That would be nice, if you feel it's a good add. Not a dealbreaker if you don't!

Also yeah, so curious to hear if there's a way to directly index.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up just changing the way I handle text for the disabled buttons, so that it's not a dynamic lookup.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how i18n could let us pull in TypeScript types 🤔 Ahhh I see @Kira-Pilot's comment above. I think that's a great idea! Happy to look into this after this PR is merged too.

"disabledButton": {
"canceling": "Canceling",
"deleted": "Deleted",
"pending": "Pending"
}
}