1
1
import {
2
2
Breadcrumbs ,
3
- ButtonProgress ,
4
3
Dialog ,
5
4
Icon ,
6
5
SelectMenu ,
9
8
SelectMenuModal ,
10
9
Tooltip ,
11
10
} from "@amplication/ui/design-system" ;
11
+ import { BillingFeature } from "@amplication/util-billing-types" ;
12
12
import { useApolloClient , useQuery } from "@apollo/client" ;
13
13
import {
14
14
ButtonTypeEnum ,
@@ -18,20 +18,15 @@ import {
18
18
PopoverNotificationCenter ,
19
19
} from "@novu/notification-center" ;
20
20
import { useStiggContext } from "@stigg/react-sdk" ;
21
- import React , {
22
- useCallback ,
23
- useContext ,
24
- useMemo ,
25
- useRef ,
26
- useState ,
27
- } from "react" ;
21
+ import React , { useCallback , useContext , useState } from "react" ;
28
22
import { isMacOs } from "react-device-detect" ;
29
- import { Link , useHistory } from "react-router-dom" ;
23
+ import { Link } from "react-router-dom" ;
30
24
import CommandPalette from "../../CommandPalette/CommandPalette" ;
31
25
import { Button , EnumButtonStyle } from "../../Components/Button" ;
32
26
import UserBadge from "../../Components/UserBadge" ;
33
27
import BreadcrumbsContext from "../../Layout/BreadcrumbsContext" ;
34
28
import ProfileForm from "../../Profile/ProfileForm" ;
29
+ import NoNotifications from "../../assets/images/no-notification.svg" ;
35
30
import { unsetToken } from "../../authentication/authentication" ;
36
31
import { AppContext } from "../../context/appContext" ;
37
32
import {
@@ -45,16 +40,12 @@ import {
45
40
AMPLICATION_DOC_URL ,
46
41
} from "../../util/constants" ;
47
42
import { version } from "../../util/version" ;
43
+ import useFetchGithubStars from "../hooks/useFetchGithubStars" ;
44
+ import { GET_CONTACT_US_LINK } from "../queries/workspaceQueries" ;
45
+ import UpgradeCtaButton from "./UpgradeCtaButton" ;
48
46
import WorkspaceBanner from "./WorkspaceBanner" ;
49
- import styles from "./notificationStyle" ;
50
- import NoNotifications from "../../assets/images/no-notification.svg" ;
51
47
import "./WorkspaceHeader.scss" ;
52
- import { BillingFeature } from "@amplication/util-billing-types" ;
53
- import { useUpgradeButtonData } from "../hooks/useUpgradeButtonData" ;
54
- import { GET_CONTACT_US_LINK } from "../queries/workspaceQueries" ;
55
- import { FeatureIndicator } from "../../Components/FeatureIndicator" ;
56
- import { CompletePreviewSignupButton } from "../../User/CompletePreviewSignupButton" ;
57
- import useFetchGithubStars from "../hooks/useFetchGithubStars" ;
48
+ import styles from "./notificationStyle" ;
58
49
59
50
const CLASS_NAME = "workspace-header" ;
60
51
const AMP_GITHUB_URL = "https://github.com/amplication/amplication" ;
@@ -86,31 +77,18 @@ const HELP_MENU_LIST: HelpMenuItem[] = [
86
77
} ,
87
78
] ;
88
79
89
- const talkToUsLink =
90
- "https://meetings-eu1.hubspot.com/paz-yanover/product-overview-vp-product" ;
91
-
92
80
const WorkspaceHeader : React . FC = ( ) => {
93
- const { currentWorkspace, currentProject, openHubSpotChat } =
94
- useContext ( AppContext ) ;
95
- const upgradeButtonData = useUpgradeButtonData ( currentWorkspace ) ;
81
+ const { currentWorkspace, currentProject } = useContext ( AppContext ) ;
96
82
97
83
const { data } = useQuery ( GET_CONTACT_US_LINK , {
98
84
variables : { id : currentWorkspace . id } ,
99
85
} ) ;
100
86
101
87
const apolloClient = useApolloClient ( ) ;
102
- const history = useHistory ( ) ;
103
88
const { stigg } = useStiggContext ( ) ;
104
89
const { trackEvent } = useTracking ( ) ;
105
- const novuBellRef = useRef ( null ) ;
106
90
const stars = useFetchGithubStars ( ) ;
107
91
108
- const daysLeftText = useMemo ( ( ) => {
109
- return `${ upgradeButtonData . trialDaysLeft } day${
110
- upgradeButtonData . trialDaysLeft !== 1 ? "s" : ""
111
- } left for the free trial`;
112
- } , [ upgradeButtonData . trialDaysLeft ] ) ;
113
-
114
92
const breadcrumbsContext = useContext ( BreadcrumbsContext ) ;
115
93
116
94
const [ novuCenterState , setNovuCenterState ] = useState ( false ) ;
@@ -121,26 +99,26 @@ const WorkspaceHeader: React.FC = () => {
121
99
const [ showProfileFormDialog , setShowProfileFormDialog ] =
122
100
useState < boolean > ( false ) ;
123
101
124
- const [ showCompleteSignupDialog , setShowCompleteSignupDialog ] =
125
- useState < boolean > ( false ) ;
126
-
127
102
const handleSignOut = useCallback ( ( ) => {
128
103
unsetToken ( ) ;
129
104
apolloClient . clearStore ( ) ;
130
105
131
106
window . location . replace ( REACT_APP_AUTH_LOGOUT_URI ) ;
132
- } , [ history , apolloClient ] ) ;
107
+ } , [ apolloClient ] ) ;
133
108
134
- const onNotificationClick = useCallback ( ( message : IMessage ) => {
135
- trackEvent ( {
136
- eventName : AnalyticsEventNames . ClickNotificationMessage ,
137
- messageType : message . templateIdentifier ,
138
- } ) ;
109
+ const onNotificationClick = useCallback (
110
+ ( message : IMessage ) => {
111
+ trackEvent ( {
112
+ eventName : AnalyticsEventNames . ClickNotificationMessage ,
113
+ messageType : message . templateIdentifier ,
114
+ } ) ;
139
115
140
- if ( message ?. cta ?. data ?. url ) {
141
- // window.location.href = message.cta.data.url;
142
- }
143
- } , [ ] ) ;
116
+ if ( message ?. cta ?. data ?. url ) {
117
+ // window.location.href = message.cta.data.url;
118
+ }
119
+ } ,
120
+ [ trackEvent ]
121
+ ) ;
144
122
145
123
const onBuildNotificationClick = useCallback (
146
124
( templateIdentifier : string , type : ButtonTypeEnum , message : IMessage ) => {
@@ -149,22 +127,14 @@ const WorkspaceHeader: React.FC = () => {
149
127
[ ]
150
128
) ;
151
129
152
- const handleUpgradeClick = useCallback ( ( ) => {
153
- trackEvent ( {
154
- eventName : AnalyticsEventNames . UpgradeClick ,
155
- eventOriginLocation : "workspace-header" ,
156
- workspace : currentWorkspace . id ,
157
- } ) ;
158
- } , [ currentWorkspace . id , trackEvent ] ) ;
159
-
160
130
const handleContactUsClick = useCallback ( ( ) => {
161
131
window . open ( data ?. contactUsLink , "_blank" ) ;
162
132
trackEvent ( {
163
133
eventName : AnalyticsEventNames . HelpMenuItemClick ,
164
134
action : "Contact Us" ,
165
135
eventOriginLocation : "workspace-header-help-menu" ,
166
136
} ) ;
167
- } , [ openHubSpotChat ] ) ;
137
+ } , [ data ?. contactUsLink , trackEvent ] ) ;
168
138
169
139
const handleItemDataClicked = useCallback (
170
140
( itemData : ItemDataCommand ) => {
@@ -179,18 +149,14 @@ const WorkspaceHeader: React.FC = () => {
179
149
setShowProfileFormDialog ( ! showProfileFormDialog ) ;
180
150
} , [ showProfileFormDialog , setShowProfileFormDialog ] ) ;
181
151
182
- const handleShowCompleteSignupDialog = useCallback ( ( ) => {
183
- setShowCompleteSignupDialog ( ! showCompleteSignupDialog ) ;
184
- } , [ showCompleteSignupDialog ] ) ;
185
-
186
152
const handleBellClick = useCallback ( ( ) => {
187
153
if ( ! novuCenterState ) {
188
154
trackEvent ( {
189
155
eventName : AnalyticsEventNames . OpenNotificationCenter ,
190
156
} ) ;
191
157
}
192
158
setNovuCenterState ( ! novuCenterState ) ;
193
- } , [ novuBellRef , novuCenterState ] ) ;
159
+ } , [ novuCenterState , trackEvent ] ) ;
194
160
195
161
const Footer = ( ) => < div > </ div > ;
196
162
@@ -254,62 +220,7 @@ const WorkspaceHeader: React.FC = () => {
254
220
< div className = { `${ CLASS_NAME } __center` } > </ div >
255
221
< div className = { `${ CLASS_NAME } __right` } >
256
222
< div className = { `${ CLASS_NAME } __links` } >
257
- { upgradeButtonData . isCompleted &&
258
- upgradeButtonData . showUpgradeTrialButton && (
259
- < a
260
- href = { talkToUsLink }
261
- target = "_blank"
262
- rel = "noopener noreferrer"
263
- className = { `${ CLASS_NAME } __version` }
264
- >
265
- < ButtonProgress
266
- className = { `${ CLASS_NAME } __upgrade__btn` }
267
- onClick = { handleUpgradeClick }
268
- progress = { upgradeButtonData . trialLeftProgress }
269
- leftValue = { daysLeftText }
270
- yellowColorThreshold = { 50 }
271
- redColorThreshold = { 0 }
272
- >
273
- Talk to us
274
- </ ButtonProgress >
275
- </ a >
276
- ) }
277
- { upgradeButtonData . isCompleted &&
278
- upgradeButtonData . showUpgradeDefaultButton && (
279
- < a
280
- href = { talkToUsLink }
281
- target = "_blank"
282
- rel = "noopener noreferrer"
283
- className = { `${ CLASS_NAME } __version` }
284
- >
285
- < Button
286
- className = { `${ CLASS_NAME } __upgrade__btn` }
287
- buttonStyle = { EnumButtonStyle . Outline }
288
- onClick = { handleUpgradeClick }
289
- >
290
- Talk to us
291
- </ Button >
292
- </ a >
293
- ) }
294
- { upgradeButtonData . isCompleted &&
295
- upgradeButtonData . isPreviewPlan &&
296
- ! upgradeButtonData . showUpgradeDefaultButton && (
297
- < >
298
- < FeatureIndicator
299
- featureName = { BillingFeature . CodeGenerationBuilds }
300
- textStart = "Generate production-ready code for this architecture with just a few simple clicks"
301
- showTooltipLink = { false }
302
- element = { < CompletePreviewSignupButton /> }
303
- />
304
- < Button
305
- className = { `${ CLASS_NAME } __upgrade__btn` }
306
- buttonStyle = { EnumButtonStyle . Outline }
307
- onClick = { handleContactUsClick }
308
- >
309
- Contact us
310
- </ Button >
311
- </ >
312
- ) }
223
+ < UpgradeCtaButton />
313
224
</ div >
314
225
< hr className = { `${ CLASS_NAME } __vertical_border` } />
315
226
0 commit comments