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

MNTOR-3396 - Organize storybook dashboard states #5308

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

codemist
Copy link
Collaborator

References:

Jira: MNTOR-3395
Figma:

Description

Screenshot (if applicable)

Not applicable.

How to test

Checklist (Definition of Done)

  • Localization strings (if needed) have been added.
  • Commits in this PR are minimal and have descriptive commit messages.
  • I've added or updated the relevant sections in readme and/or code comments
  • I've added a unit test to test for potential regressions of this bug.
  • If this PR implements a feature flag or experimentation, the Ship Behind Feature Flag status in Jira has been set
  • Product Owner accepted the User Story (demo of functionality completed) or waived the privilege.
  • All acceptance criteria are met.
  • Jira ticket has been updated (if needed) to match changes made during the development process.
  • Jira ticket has been updated (if needed) with suggestions for QA when this PR is deployed to stage.

Vinnl and others added 9 commits November 14, 2024 10:55
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.
@codemist codemist requested a review from flozia November 14, 2024 16:22
Copy link

2 similar comments
Copy link

Copy link

Copy link
Collaborator

@flozia flozia left a 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.

Comment on lines +27 to +39
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",
};
Copy link
Collaborator

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 = (
Copy link
Collaborator

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",
Copy link
Collaborator

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.

image

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants