-
Notifications
You must be signed in to change notification settings - Fork 211
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
MNTOR-3396 - Organize storybook dashboard states #5308
base: main
Are you sure you want to change the base?
Conversation
This removes the `Breach` type in functions/universal/breaches, which was created when first introducing TypeScript and the flow of data was still unclear, but by now had overlap with other types and no clear provenance. Instead, there are now three breach-related types, that represent where the data came from: - HibpGetBreachesResponse: this is an array of breach elements as returned from the HIBP API, unprocessed. Properties are in PascalCase, so are a breach's data classes. - BreachRow: this is a breach's data as stored in our database, along with some data we added to it, such as a favicon URL. Properties are snake_case, and data classes are lowercased and kebab-cased by the formatDataClassesArray function. - HibpLikeDbBreach: this is a breach's data fetched from the database, but stored in an object meant to look like the ones in HibpGetBreachesResponse. In other words, it contains the same data as BreachRow (including lowercased, kebab-cased data classes), but on PascalCase properties. The latter is somewhat of a historical artefact, because we used to try to load breaches from our database, then if our database didn't contain any breaches yet, fetch them live from the HIBP API and continue working with that. We no longer do that: now, even after fetching them from the HIBP API, we do a new query to get them from the database and process them into HibpLikeDbBreach, so that we can assume a consisent data structure everywhere we work with breaches.
Preview URL 🚀 : https://blurts-server-pr-5308-mgjlpikfea-uk.a.run.app |
2 similar comments
Preview URL 🚀 : https://blurts-server-pr-5308-mgjlpikfea-uk.a.run.app |
Preview URL 🚀 : https://blurts-server-pr-5308-mgjlpikfea-uk.a.run.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple duplicate variables in the Dashboard*.stories.ts
files that we can consolidate as well as some duplicate button stories that we should delete.
const brokerOptions = { | ||
"no-scan": "No scan started", | ||
empty: "No scan results", | ||
unresolved: "With unresolved scan results", | ||
resolved: "All scan results resolved", | ||
"scan-in-progress": "Scan is in progress", | ||
"manually-resolved": "Manually resolved", | ||
}; | ||
const breachOptions = { | ||
empty: "No data breaches", | ||
unresolved: "With unresolved data breaches", | ||
resolved: "All data breaches resolved", | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: brokerOptions
and breachOptions
is also defined in DashboardUSUsers.stories.tsx
and multiple other files — might be a good idea to just have those in one place and import them here.
unresolved: "With unresolved data breaches", | ||
resolved: "All data breaches resolved", | ||
}; | ||
type DashboardWrapperProps = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type DashboardWrapperProps
is duplicated as well and can be reused.
@@ -8,7 +8,7 @@ import { DoughnutChart } from "../Chart"; | |||
|
|||
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction | |||
const meta: Meta<typeof DoughnutChart> = { | |||
title: "Charts", | |||
title: "Dashboard/TopBanner/Charts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we change the title either here or there to the same spelling — “TopBanner” or “Top Banner” — they will be grouped together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stories in this file look like duplicates of Button.stories.ts
and do not contain checkboxes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is also a duplicate of Button.stories.ts
and can be removed.
References:
Jira: MNTOR-3395
Figma:
Description
Screenshot (if applicable)
Not applicable.
How to test
Checklist (Definition of Done)