|
1 | 1 | import * as React from 'react'; |
| 2 | +import { Button } from '@box/blueprint-web'; |
| 3 | +import { Pencil } from '@box/blueprint-web-assets/icons/Fill'; |
| 4 | +import { useIntl } from 'react-intl'; |
2 | 5 | import Sort from './Sort'; |
3 | 6 | import Add from './Add'; |
4 | 7 | import GridViewSlider from '../../../components/grid-view/GridViewSlider'; |
5 | 8 | import ViewModeChangeButton from './ViewModeChangeButton'; |
6 | | -import { VIEW_FOLDER, VIEW_MODE_GRID } from '../../../constants'; |
| 9 | +import { VIEW_FOLDER, VIEW_MODE_GRID, VIEW_METADATA } from '../../../constants'; |
| 10 | +import { useFeatureEnabled } from '../feature-checking'; |
| 11 | + |
7 | 12 | import type { ViewMode } from '../flowTypes'; |
8 | 13 | import type { SortBy, SortDirection, View, Collection } from '../../../common/types/core'; |
| 14 | + |
| 15 | +import messages from './messages'; |
| 16 | + |
9 | 17 | import './SubHeaderRight.scss'; |
10 | 18 |
|
11 | 19 | export interface SubHeaderRightProps { |
@@ -43,36 +51,49 @@ const SubHeaderRight = ({ |
43 | 51 | view, |
44 | 52 | viewMode, |
45 | 53 | }: SubHeaderRightProps) => { |
| 54 | + const { formatMessage } = useIntl(); |
| 55 | + const isMetadataViewV2Feature = useFeatureEnabled('contentExplorer.metadataViewV2'); |
46 | 56 | const { items = [] }: Collection = currentCollection; |
47 | 57 | const hasGridView: boolean = !!gridColumnCount; |
48 | 58 | const hasItems: boolean = items.length > 0; |
49 | 59 | const isFolder: boolean = view === VIEW_FOLDER; |
50 | 60 | const showSort: boolean = isFolder && hasItems; |
51 | 61 | const showAdd: boolean = (!!canUpload || !!canCreateNewFolder) && isFolder; |
| 62 | + const isMetadataView: boolean = view === VIEW_METADATA; |
52 | 63 | return ( |
53 | 64 | <div className="be-sub-header-right"> |
54 | | - {hasItems && viewMode === VIEW_MODE_GRID && ( |
55 | | - <GridViewSlider |
56 | | - columnCount={gridColumnCount} |
57 | | - gridMaxColumns={gridMaxColumns} |
58 | | - gridMinColumns={gridMinColumns} |
59 | | - maxColumnCount={maxGridColumnCountForWidth} |
60 | | - onChange={onGridViewSliderChange} |
61 | | - /> |
| 65 | + {!isMetadataView && ( |
| 66 | + <> |
| 67 | + {hasItems && viewMode === VIEW_MODE_GRID && ( |
| 68 | + <GridViewSlider |
| 69 | + columnCount={gridColumnCount} |
| 70 | + gridMaxColumns={gridMaxColumns} |
| 71 | + gridMinColumns={gridMinColumns} |
| 72 | + maxColumnCount={maxGridColumnCountForWidth} |
| 73 | + onChange={onGridViewSliderChange} |
| 74 | + /> |
| 75 | + )} |
| 76 | + {hasItems && hasGridView && ( |
| 77 | + <ViewModeChangeButton viewMode={viewMode} onViewModeChange={onViewModeChange} /> |
| 78 | + )} |
| 79 | + {showSort && <Sort onSortChange={onSortChange} portalElement={portalElement} />} |
| 80 | + {showAdd && ( |
| 81 | + <Add |
| 82 | + isDisabled={!isFolder} |
| 83 | + onCreate={onCreate} |
| 84 | + onUpload={onUpload} |
| 85 | + portalElement={portalElement} |
| 86 | + showCreate={canCreateNewFolder} |
| 87 | + showUpload={canUpload} |
| 88 | + /> |
| 89 | + )} |
| 90 | + </> |
62 | 91 | )} |
63 | | - {hasItems && hasGridView && ( |
64 | | - <ViewModeChangeButton viewMode={viewMode} onViewModeChange={onViewModeChange} /> |
65 | | - )} |
66 | | - {showSort && <Sort onSortChange={onSortChange} portalElement={portalElement} />} |
67 | | - {showAdd && ( |
68 | | - <Add |
69 | | - isDisabled={!isFolder} |
70 | | - onCreate={onCreate} |
71 | | - onUpload={onUpload} |
72 | | - portalElement={portalElement} |
73 | | - showCreate={canCreateNewFolder} |
74 | | - showUpload={canUpload} |
75 | | - /> |
| 92 | + |
| 93 | + {isMetadataView && isMetadataViewV2Feature && ( |
| 94 | + <Button icon={Pencil} size="large" variant="primary"> |
| 95 | + {formatMessage(messages.metadata)} |
| 96 | + </Button> |
76 | 97 | )} |
77 | 98 | </div> |
78 | 99 | ); |
|
0 commit comments