@@ -67,6 +67,7 @@ const drawerStyles = ({ palette, spacing }: Theme) =>
67
67
interface DrawerProps extends WithStyles < typeof drawerStyles > {
68
68
authenticated : boolean
69
69
drawerOpen : boolean
70
+ isFeedsManagerFeatureEnabled : boolean
70
71
toggleDrawer : ( ) => void
71
72
submitSignOut : ( ) => void
72
73
}
@@ -78,6 +79,7 @@ const Drawer = withStyles(drawerStyles)(
78
79
authenticated,
79
80
classes,
80
81
submitSignOut,
82
+ isFeedsManagerFeatureEnabled,
81
83
} : DrawerProps ) => {
82
84
return (
83
85
< MuiDrawer
@@ -102,6 +104,18 @@ const Drawer = withStyles(drawerStyles)(
102
104
className = { classes . menuitem }
103
105
/>
104
106
) ) }
107
+ { isFeedsManagerFeatureEnabled && (
108
+ < ListItem
109
+ button
110
+ component = { ( ) => (
111
+ < BaseLink href = { '/feeds_manager' } >
112
+ < ListItemText primary = "Feeds Manager" />
113
+ </ BaseLink >
114
+ ) }
115
+ className = { classes . menuitem }
116
+ />
117
+ ) }
118
+
105
119
{ authenticated && (
106
120
< ListItem
107
121
button
@@ -147,56 +161,58 @@ const navStyles = ({ palette, spacing }: Theme) =>
147
161
148
162
interface NavProps extends WithStyles < typeof navStyles > {
149
163
authenticated : boolean
164
+ isFeedsManagerFeatureEnabled : boolean
150
165
}
151
166
152
- const Nav = withStyles ( navStyles ) ( ( { authenticated , classes } : NavProps ) => {
153
- const { pathname } = useLocation ( )
154
- const isFeedsManagerFeatureEnabled = useFeatureFlag ( Feature . FeedsManager )
167
+ const Nav = withStyles ( navStyles ) (
168
+ ( { authenticated , classes , isFeedsManagerFeatureEnabled } : NavProps ) => {
169
+ const { pathname } = useLocation ( )
155
170
156
- return (
157
- < Typography variant = "body1" component = "div" >
158
- < List className = { classes . horizontalNav } >
159
- { NAV_ITEMS . map ( ( [ navItemPath , text ] ) => (
160
- < ListItem key = { navItemPath } className = { classes . horizontalNavItem } >
161
- < BaseLink
162
- key = { navItemPath }
163
- href = { navItemPath }
164
- className = { classNames (
165
- classes . horizontalNavLink ,
166
- pathname . startsWith ( navItemPath ) && classes . activeNavLink ,
167
- ) }
168
- >
169
- { text }
170
- </ BaseLink >
171
- </ ListItem >
172
- ) ) }
173
- { /* Feeds Manager link hidden behind a feature flag. This is temporary until we
171
+ return (
172
+ < Typography variant = "body1" component = "div" >
173
+ < List className = { classes . horizontalNav } >
174
+ { NAV_ITEMS . map ( ( [ navItemPath , text ] ) => (
175
+ < ListItem key = { navItemPath } className = { classes . horizontalNavItem } >
176
+ < BaseLink
177
+ key = { navItemPath }
178
+ href = { navItemPath }
179
+ className = { classNames (
180
+ classes . horizontalNavLink ,
181
+ pathname . startsWith ( navItemPath ) && classes . activeNavLink ,
182
+ ) }
183
+ >
184
+ { text }
185
+ </ BaseLink >
186
+ </ ListItem >
187
+ ) ) }
188
+ { /* Feeds Manager link hidden behind a feature flag. This is temporary until we
174
189
enable this for everyone */ }
175
- { isFeedsManagerFeatureEnabled && (
176
- < ListItem className = { classes . horizontalNavItem } >
177
- < BaseLink
178
- href = { '/feeds_manager' }
179
- className = { classNames (
180
- classes . horizontalNavLink ,
181
- pathname . includes ( '/feeds_manager' ) && classes . activeNavLink ,
182
- ) }
183
- >
184
- Feeds Manager
185
- </ BaseLink >
186
- </ ListItem >
187
- ) }
188
- { authenticated && (
189
- < >
190
+ { isFeedsManagerFeatureEnabled && (
190
191
< ListItem className = { classes . horizontalNavItem } >
191
- < SettingsMenu />
192
- < AccountMenu />
192
+ < BaseLink
193
+ href = { '/feeds_manager' }
194
+ className = { classNames (
195
+ classes . horizontalNavLink ,
196
+ pathname . includes ( '/feeds_manager' ) && classes . activeNavLink ,
197
+ ) }
198
+ >
199
+ Feeds Manager
200
+ </ BaseLink >
193
201
</ ListItem >
194
- </ >
195
- ) }
196
- </ List >
197
- </ Typography >
198
- )
199
- } )
202
+ ) }
203
+ { authenticated && (
204
+ < >
205
+ < ListItem className = { classes . horizontalNavItem } >
206
+ < SettingsMenu />
207
+ < AccountMenu />
208
+ </ ListItem >
209
+ </ >
210
+ ) }
211
+ </ List >
212
+ </ Typography >
213
+ )
214
+ } ,
215
+ )
200
216
201
217
const styles = ( { palette, spacing, zIndex } : Theme ) =>
202
218
createStyles ( {
@@ -218,34 +234,21 @@ interface Props extends WithStyles<typeof styles> {
218
234
onResize : ( width : number , height : number ) => void
219
235
}
220
236
221
- interface State {
222
- drawerOpen : boolean
223
- }
237
+ const Header = withStyles ( styles ) (
238
+ ( {
239
+ authenticated,
240
+ classes,
241
+ fetchCount,
242
+ drawerContainer,
243
+ onResize,
244
+ submitSignOut,
245
+ } : Props ) => {
246
+ const [ drawerOpen , setDrawerOpen ] = React . useState ( false )
247
+ const isFeedsManagerFeatureEnabled = useFeatureFlag ( Feature . FeedsManager )
224
248
225
- class Header extends React . Component < Props , State > {
226
- constructor ( props : Props ) {
227
- super ( props )
228
- this . state = {
229
- drawerOpen : false ,
249
+ const toggleDrawer = ( ) => {
250
+ setDrawerOpen ( ! drawerOpen )
230
251
}
231
- this . toggleDrawer = this . toggleDrawer . bind ( this )
232
- }
233
-
234
- toggleDrawer ( ) {
235
- this . setState ( {
236
- drawerOpen : ! this . state . drawerOpen ,
237
- } )
238
- }
239
-
240
- render ( ) {
241
- const {
242
- authenticated,
243
- classes,
244
- fetchCount,
245
- drawerContainer,
246
- onResize,
247
- submitSignOut,
248
- } = this . props
249
252
250
253
return (
251
254
< AppBar className = { classes . appBar } color = "default" position = "absolute" >
@@ -270,13 +273,18 @@ class Header extends React.Component<Props, State> {
270
273
< Hidden mdUp >
271
274
< IconButton
272
275
aria-label = "open drawer"
273
- onClick = { this . toggleDrawer }
276
+ onClick = { toggleDrawer }
274
277
>
275
278
< MenuIcon />
276
279
</ IconButton >
277
280
</ Hidden >
278
281
< Hidden smDown >
279
- < Nav authenticated = { authenticated } />
282
+ < Nav
283
+ authenticated = { authenticated }
284
+ isFeedsManagerFeatureEnabled = {
285
+ isFeedsManagerFeatureEnabled
286
+ }
287
+ />
280
288
</ Hidden >
281
289
</ Grid >
282
290
</ Grid >
@@ -286,16 +294,17 @@ class Header extends React.Component<Props, State> {
286
294
</ ReactResizeDetector >
287
295
< Portal container = { drawerContainer } >
288
296
< Drawer
289
- toggleDrawer = { this . toggleDrawer }
290
- drawerOpen = { this . state . drawerOpen }
297
+ isFeedsManagerFeatureEnabled = { isFeedsManagerFeatureEnabled }
298
+ toggleDrawer = { toggleDrawer }
299
+ drawerOpen = { drawerOpen }
291
300
authenticated = { authenticated }
292
301
submitSignOut = { submitSignOut }
293
302
/>
294
303
</ Portal >
295
304
</ AppBar >
296
305
)
297
- }
298
- }
306
+ } ,
307
+ )
299
308
300
309
const mapStateToProps = ( state : any ) => ( {
301
310
authenticated : state . authentication . allowed ,
0 commit comments