Skip to content

Commit bbee29a

Browse files
authored
ref(billing): Convert PowerFeatureHovercard to FC (#98952)
didn't have state or anything
1 parent 940c5b5 commit bbee29a

File tree

1 file changed

+65
-67
lines changed

1 file changed

+65
-67
lines changed

static/gsApp/components/powerFeatureHovercard.tsx

Lines changed: 65 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {Component} from 'react';
21
import styled from '@emotion/styled';
32

43
import {Button} from 'sentry/components/core/button';
@@ -18,7 +17,7 @@ import {PlanTier} from 'getsentry/types';
1817
import {displayPlanName} from 'getsentry/utils/billing';
1918
import trackGetsentryAnalytics from 'getsentry/utils/trackGetsentryAnalytics';
2019

21-
type Props = {
20+
interface PowerFeatureHovercardProps {
2221
/**
2322
* The set of features that are required for this feature. Used to
2423
* determine which plan is required for the feature.
@@ -53,86 +52,85 @@ type Props = {
5352
* opens the upsell modal.
5453
*/
5554
useLearnMoreLink?: boolean;
56-
};
55+
}
5756

58-
class PowerFeatureHovercard extends Component<Props> {
59-
recordAnalytics() {
60-
const {id, organization, subscription} = this.props;
57+
function PowerFeatureHovercard({
58+
id,
59+
containerClassName,
60+
containerDisplayMode,
61+
organization,
62+
subscription,
63+
partial,
64+
features,
65+
children,
66+
}: PowerFeatureHovercardProps) {
67+
const recordAnalytics = () => {
6168
trackGetsentryAnalytics('power_icon.clicked', {
6269
organization,
6370
subscription,
6471
source: id,
6572
});
66-
}
73+
};
6774

68-
handleClick = (e: React.MouseEvent) => {
75+
const handleClick = (e: React.MouseEvent) => {
6976
e.preventDefault();
70-
const {organization, id} = this.props;
7177

72-
this.recordAnalytics();
78+
recordAnalytics();
7379
openUpsellModal({
7480
organization,
7581
source: id ?? '',
7682
});
7783
};
7884

79-
render() {
80-
const {
81-
containerClassName,
82-
containerDisplayMode,
83-
organization,
84-
subscription,
85-
partial,
86-
features,
87-
children,
88-
} = this.props;
89-
90-
const hoverBody = (
91-
<PlanFeature features={features} {...{organization, subscription}}>
92-
{({plan, tierChange}) => {
93-
let planName = displayPlanName(plan);
94-
95-
if (tierChange === PlanTier.AM1) {
96-
planName = `Performance ${planName}`;
97-
}
98-
99-
return (
100-
<LearnMoreTextBody data-test-id="power-hovercard">
101-
<Flex direction="column" gap="md">
102-
<div>
103-
{partial
104-
? t('Better With %s Plan', planName)
105-
: t('Requires %s Plan', planName)}
106-
</div>
107-
<Button
108-
priority="primary"
109-
onClick={this.handleClick}
110-
data-test-id="power-learn-more"
111-
size="xs"
112-
icon={<IconLightning size="xs" />}
113-
>
114-
{t('Learn More')}
115-
</Button>
116-
</Flex>
117-
</LearnMoreTextBody>
118-
);
119-
}}
120-
</PlanFeature>
121-
);
122-
123-
return (
124-
<StyledHovercard
125-
containerClassName={containerClassName}
126-
containerDisplayMode={containerDisplayMode}
127-
bodyClassName="power-icon"
128-
body={hoverBody}
129-
position="right"
130-
delay={200}
131-
>
132-
{children}
133-
</StyledHovercard>
134-
);
135-
}
85+
const hoverBody = (
86+
<PlanFeature
87+
features={features}
88+
organization={organization}
89+
subscription={subscription}
90+
>
91+
{({plan, tierChange}) => {
92+
let planName = displayPlanName(plan);
93+
94+
if (tierChange === PlanTier.AM1) {
95+
planName = `Performance ${planName}`;
96+
}
97+
98+
return (
99+
<LearnMoreTextBody data-test-id="power-hovercard">
100+
<Flex direction="column" gap="md">
101+
<div>
102+
{partial
103+
? t('Better With %s Plan', planName)
104+
: t('Requires %s Plan', planName)}
105+
</div>
106+
<Button
107+
priority="primary"
108+
onClick={handleClick}
109+
data-test-id="power-learn-more"
110+
size="xs"
111+
icon={<IconLightning size="xs" />}
112+
>
113+
{t('Learn More')}
114+
</Button>
115+
</Flex>
116+
</LearnMoreTextBody>
117+
);
118+
}}
119+
</PlanFeature>
120+
);
121+
122+
return (
123+
<StyledHovercard
124+
containerClassName={containerClassName}
125+
containerDisplayMode={containerDisplayMode}
126+
bodyClassName="power-icon"
127+
body={hoverBody}
128+
position="right"
129+
delay={200}
130+
>
131+
{children}
132+
</StyledHovercard>
133+
);
136134
}
137135

138136
const LearnMoreTextBody = styled('div')`

0 commit comments

Comments
 (0)