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

Extract out confirm-data and confirm-hex-data components from confirm-transaction-base.component.js #17822

Merged
merged 42 commits into from
Mar 9, 2023

Conversation

jpuri
Copy link
Contributor

@jpuri jpuri commented Feb 20, 2023

Fixes: #17419

Extract out components to render transaction data and hexData from confirm-transaction-base component.

@jpuri jpuri requested a review from a team as a code owner February 20, 2023 06:03
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot
Copy link
Collaborator

Builds ready [679c24c]
Page Load Metrics (1410 ± 30 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint91156107157
domContentLoaded1219151914096330
load1219151914106330
domInteractive1219151914096330
Bundle size diffs
  • background: 0 bytes
  • ui: 4309 bytes
  • common: 0 bytes

@metamaskbot
Copy link
Collaborator

Builds ready [4c98fe2]
Page Load Metrics (1514 ± 53 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint92138110126
domContentLoaded13531695149710852
load13531751151411053
domInteractive13531695149710852
Bundle size diffs
  • background: 0 bytes
  • ui: 4309 bytes
  • common: 0 bytes

Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

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

😍 Yassss. Love seeing the confirmations getting some TLC refactoring. I have some suggestions for how we can make the most of this refactor from a codebase quality/patterns perspective. Overall looks good though

ui/components/app/confirm-data/index.js Outdated Show resolved Hide resolved
ui/components/app/confirm-data/index.js Outdated Show resolved Hide resolved
ui/components/app/confirm-data/index.js Outdated Show resolved Hide resolved
@jpuri jpuri requested a review from brad-decker February 24, 2023 06:39
@jpuri
Copy link
Contributor Author

jpuri commented Mar 2, 2023

It would be really great to get storybook stories for these components so we can view and work on them in isolation

  • Will help with visual review
  • Will help further iterations in future
  • Hot reload is much quicker in storybook than on local build of the extension

You can read how to create a story here https://metamask.github.io/metamask-storybook/?path=/story/getting-started-documentation-guidelines--page#creating-a-story

Hey @georgewrmarshall : this component has dependency on app state, I am finding it hard to write stories.

@metamaskbot
Copy link
Collaborator

Builds ready [95a02f9]
Page Load Metrics (1519 ± 36 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint92143111136
domContentLoaded1297154414775728
load1298163415197536
domInteractive1297154414775728
Bundle size diffs
  • background: 0 bytes
  • ui: 7681 bytes
  • common: 0 bytes

Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

as mentioned here https://github.com/MetaMask/metamask-extension/pull/17822/files#r1117481915, I think it makes more sense to keep these components in ui/pages/confirm-transaction-base rather than ui/components/app since they seem to only be used in the ConfirmTransactionBase component and they aren't planned to be used elsewhere. Maybe we can get a 3rd person to weigh in on this.

If we do keep them in ui/components/app I think it's a good idea to have storybook pages associated with them

@jpuri jpuri requested a review from digiwand March 6, 2023 05:53
@jpuri
Copy link
Contributor Author

jpuri commented Mar 6, 2023

PR is updated with storybooks.

@metamaskbot
Copy link
Collaborator

Builds ready [6e53ff1]
Page Load Metrics (1766 ± 62 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1053091414220
domContentLoaded15301965171412460
load15301991176613062
domInteractive15301965171412460
Bundle size diffs
  • background: 0 bytes
  • ui: 7681 bytes
  • common: 0 bytes

digiwand
digiwand previously approved these changes Mar 6, 2023
Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

LGTM!

spoke about keeping the components in ui/components/app with @jpuri & @Gudahtt. We're okay moving forward with this


[maybe non-blocking question] cc: @jpuri @brad-decker @georgewrmarshall

In regards to #17822 (comment)

There are a couple you have targeted to be rendered as h3 tags but with bodySm styling, is that intentional?

I'm a little confused by this too. Does anyone here happen to know:

  • do we have plans to add styles for heading tags (e.g. <h1> or <h3>)?
  • do we have plans to add additional TextVariant styles for heading tags so we don't use other non-heading TextVariants like bodySm? else, is this a normal use-case to combine heading tags with non-heading TextVariants?

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Great work on the stories! I'm wondering if they could be improved further by providing the mock state to display more visual states? It may not be possible but have added a way to change the display of a component using mocked state. Some other minor suggestions. Also great work on usage of design system components and reducing CSS 💯

ui/components/app/confirm-data/README.mdx Outdated Show resolved Hide resolved
DataComponentStory.args = {
txData,
dataComponent,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Fantastic work! Is there a state where this component shows more than the error state? If it requires different redux stat you can add that by providing a provider

import React from 'react';

import { Provider } from 'react-redux';

import testData from '../../../../.storybook/test-data'; // this is the test data that you can use to populate the store
import configureStore from '../../../store/store';

import ConfirmData from './confirm-data';

const store = configureStore(testData); // this is the store that you can use to wrap the component in you could customize it with the specific data you need per story

export default {
  title: 'Components/App/ConfirmData',
  decorators: [(story) => <Provider store={store}>{story()}</Provider>], // if you need to wrap the component in a provider, you can do it here
  argTypes: {
    txData: {
      control: 'object',
    },
    dataComponent: {
      control: 'element',
    },
  },
  args: {
    txData: {
      txParams: {
        data: '0x608060405234801',
      },
      origin: 'https://metamask.github.io/',
      type: 'transfer',
    },
  },
};

export const DefaultStory = (args) => <ConfirmData {...args} />;

DefaultStory.storyName = 'Default';

export const NoData = (args) => <ConfirmData {...args} />;
ConfirmData.args = {
  txData: {},
};

export const DataComponent = (args) => <ConfirmData {...args} />;
ConfirmData.args = {
  dataComponent: <span>Data Component</span>,
};

Screenshot 2023-03-06 at 1 20 44 PM

Copy link
Contributor Author

@jpuri jpuri Mar 7, 2023

Choose a reason for hiding this comment

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

I found it showing this message for most of transactions. It requires some api query to get these insights and some other state combination to get insights - I am not very sure about that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok. TBH I'm still not sure how we can do that. I'll do some research. I think there's still a huge benefit to showing the error state though 💯 Thanks @jpuri 🙏

ui/components/app/confirm-hexdata/README.mdx Outdated Show resolved Hide resolved
ui/components/app/confirm-hexdata/confirm-data.stories.js Outdated Show resolved Hide resolved
ui/components/app/confirm-hexdata/confirm-data.stories.js Outdated Show resolved Hide resolved
: '';

return (
<Box padding={4}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consider this assumed layout which is adding spacing to a component before knowing where it might be placed? I'm not sure where we are on spreading props but if you were to spread props here it would allow the padding and spacing to be changed at the implementation stage e.g.

    <Box {...props}

Then on the implementation side

<ConfirmHexData txParams={txParams} padding={4} marginTop={4} />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @georgewrmarshall : the goal of this PR is to extract this component out of confirm-transaction-base. It is bit beyond the scope of this RP to make it more re-usable.

@metamaskbot
Copy link
Collaborator

Builds ready [f7d716f]
Page Load Metrics (1587 ± 40 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint104147122126
domContentLoaded1430165215686732
load1430175415878340
domInteractive1430165215686732
Bundle size diffs
  • background: 0 bytes
  • ui: 7641 bytes
  • common: 0 bytes

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Looking great! I think we can just remove the README.mdx files if we aren't using them for in-depth docs. Sorry I didn't specify that in my last review


## Props

<ArgsTable of={ConfirmData} />
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just remove the README.mdx files altogether. They're only useful if we really want to dig deep on docs for a component otherwise it will generate a basic one. I'll update the storybook docs to define that apologies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey I tried to do that, but locally that gives issue @georgewrmarshall


## Props

<ArgsTable of={ConfirmHexData} />
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just remove this file altogether and remove the reference from the storybook file

@jpuri jpuri requested a review from georgewrmarshall March 8, 2023 17:43
Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

LGTM

@jpuri jpuri merged commit 0ac54e4 into develop Mar 9, 2023
@jpuri jpuri deleted the confirm_data_components branch March 9, 2023 05:08
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
team-confirmations-secure-ux-PR PRs from the confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extract confirm-transaction-base.component.js functions renderData, renderDataHex into separate components
6 participants