11import {
2- CommandBar ,
3- DefaultButton ,
2+ Label ,
3+ Toolbar ,
4+ ToolbarButton ,
5+ ToolbarGroup ,
46 Dialog ,
5- DialogFooter , DialogType , ICommandBarItemProps ,
6- Label , MessageBarType , PrimaryButton
7- } from '@fluentui/react' ;
8-
7+ DialogActions ,
8+ DialogBody ,
9+ DialogContent ,
10+ DialogSurface ,
11+ DialogTitle ,
12+ Button
13+ } from '@fluentui/react-components' ;
14+ import { Delete20Regular , Key20Regular , ArrowUpload20Regular , List20Regular } from '@fluentui/react-icons' ;
915import { useAppDispatch , useAppSelector } from '../../../../../store' ;
1016import { componentNames , eventTypes , telemetry } from '../../../../../telemetry' ;
1117import { PopupsComponent } from '../../../../services/context/popups-context' ;
@@ -19,6 +25,7 @@ import { useEffect, useState } from 'react';
1925import { ResourcePath } from '../../../../../types/resources' ;
2026import { setQueryResponseStatus } from '../../../../services/slices/query-status.slice' ;
2127import { isGeneratedCollectionInCollection } from './upload-collection.util' ;
28+ import CommonCollectionsPanel from './CommonCollectionsPanel' ;
2229
2330export interface APICollection {
2431 version : string ;
@@ -64,7 +71,6 @@ const APICollection: React.FC<PopupsComponent<APICollection>> = (props) => {
6471 trackDownload ( filename , componentNames . DOWNLOAD_POSTMAN_COLLECTION_BUTTON ) ;
6572 }
6673
67-
6874 const handleFileSelect = ( event : any ) => {
6975 const file = event . target . files [ 0 ] ;
7076 if ( file ) {
@@ -155,7 +161,7 @@ const APICollection: React.FC<PopupsComponent<APICollection>> = (props) => {
155161 showPopup ( {
156162 settings : {
157163 title : translateMessage ( 'Edit Collection' ) ,
158- width : 'xl '
164+ width : 'lg '
159165 }
160166 } ) ;
161167 } ;
@@ -164,57 +170,82 @@ const APICollection: React.FC<PopupsComponent<APICollection>> = (props) => {
164170 showEditScopePanel ( {
165171 settings : {
166172 title : translateMessage ( 'Edit Scope' ) ,
167- width : 'xl '
173+ width : 'lg '
168174 }
169175 } ) ;
170176 } ;
171177
172- const options : ICommandBarItemProps [ ] = [
178+ const options = [
173179 {
174180 key : 'remove' ,
175181 text : translateMessage ( 'Edit collection' ) ,
176- iconProps : { iconName : 'Delete' } ,
182+ icon : < Delete20Regular /> ,
177183 disabled : items . length === 0 ,
178184 onClick : openEditCollectionPanel
179185 } ,
180186 {
181187 key : 'set-scope' ,
182188 text : translateMessage ( 'Edit scope' ) ,
183- iconProps : { iconName : 'Permissions' } ,
189+ icon : < Key20Regular /> ,
184190 disabled : items . length === 0 ,
185191 onClick : openEditScopePanel
186192 } ,
187193 {
188194 key : 'upload' ,
189195 text : translateMessage ( 'Upload a new list' ) ,
190- iconProps : { iconName : 'Upload' } ,
196+ icon : < ArrowUpload20Regular /> ,
191197 onClick : ( ) => document . getElementById ( 'file-input' ) ?. click ( )
192198 }
193199 ] ;
194200
195- const farItems : ICommandBarItemProps [ ] = [
201+ const farItems = [
196202 {
197203 key : 'preview-permissions' ,
198204 text : translateMessage ( 'Preview permissions' ) ,
199- iconProps : { iconName : 'ListMirrored' } ,
205+ icon : < List20Regular /> ,
200206 disabled : items . length === 0 ,
201207 onClick : ( ) => viewPermissions ( {
202208 settings : {
203209 title : translateMessage ( 'Preview Permissions' ) ,
204- width : 'xl '
210+ width : 'lg '
205211 }
206212 } ) }
207213 ] ;
208214
209215 return (
210- < >
211- < CommandBar
212- items = { options }
213- ariaLabel = 'Selection actions'
214- primaryGroupAriaLabel = 'Selection actions'
215- farItemsGroupAriaLabel = 'More selection actions'
216- farItems = { farItems }
217- />
216+ < CommonCollectionsPanel
217+ primaryButtonText = 'Download postman collection'
218+ primaryButtonAction = { generateCollection }
219+ primaryButtonDisabled = { items . length === 0 }
220+ closePopup = { props . dismissPopup }
221+ >
222+ < Toolbar aria-label = 'Selection actions' style = { { justifyContent : 'space-between' } } >
223+ < ToolbarGroup >
224+ { options . map ( option => (
225+ < ToolbarButton
226+ key = { option . key }
227+ icon = { option . icon }
228+ disabled = { option . disabled }
229+ onClick = { option . onClick }
230+ style = { { marginInlineEnd : '30px' } }
231+ >
232+ { option . text }
233+ </ ToolbarButton >
234+ ) ) }
235+ </ ToolbarGroup >
236+ < ToolbarGroup >
237+ { farItems . map ( item => (
238+ < ToolbarButton
239+ key = { item . key }
240+ icon = { item . icon }
241+ disabled = { item . disabled }
242+ onClick = { item . onClick }
243+ >
244+ { item . text }
245+ </ ToolbarButton >
246+ ) ) }
247+ </ ToolbarGroup >
248+ </ Toolbar >
218249
219250 < input
220251 key = { fileInputKey }
@@ -224,57 +255,45 @@ const APICollection: React.FC<PopupsComponent<APICollection>> = (props) => {
224255 onChange = { handleFileSelect }
225256 />
226257
227- { ! isDialogHidden && (
228- < Dialog
229- hidden = { isDialogHidden }
230- onDismiss = { ( ) => setIsDialogHidden ( true ) }
231- dialogContentProps = { {
232- type : DialogType . normal ,
233- title : translateMessage ( 'Upload collection' ) ,
234- closeButtonAriaLabel : 'Close' ,
235- subText : translateMessage ( 'You have an existing collection. Would you like to merge or replace it?' )
236- } }
237- >
238- < DialogFooter >
239- < PrimaryButton onClick = { mergeWithExistingCollection } text = { translateMessage ( 'Merge with existing' ) } />
240- < DefaultButton onClick = { overwriteCollection } text = { translateMessage ( 'Replace existing' ) } />
241- </ DialogFooter >
242- </ Dialog >
243- ) }
244-
245258 { items && items . length > 0 ?
246- ( < div style = { { height : '80vh' } } >
259+ ( < div >
247260 < Paths
248261 resources = { items }
249262 columns = { columns }
250263 />
251264 </ div >
252265 ) :
253266 (
254- < Label
255- style = { { display : 'flex' , width : '100%' ,
256- height : '80vh' ,
257- justifyContent : 'center' ,
258- alignItems : 'center' } } >
267+ < Label style = { {
268+ height : '80vh' ,
269+ display : 'flex' ,
270+ width : '100%' ,
271+ justifyContent : 'center' ,
272+ alignItems : 'center'
273+ } } >
259274 { translateMessage ( 'Add queries in the API Explorer and History tab' ) }
260275 </ Label >
261276 ) }
262- < DialogFooter
263- styles = { {
264- actionsRight : { bottom : 0 , justifyContent : 'start' }
265- } } >
266- < PrimaryButton onClick = { generateCollection } disabled = { items . length === 0 } >
267- { translateMessage ( 'Download postman collection' ) }
268- </ PrimaryButton >
269277
270- < DefaultButton
271- onClick = {
272- ( ) => props . closePopup ( )
273- } >
274- { translateMessage ( 'Close' ) }
275- </ DefaultButton >
276- </ DialogFooter >
277- </ >
278+ < Dialog open = { ! isDialogHidden } onOpenChange = { toggleIsDialogHidden } >
279+ < DialogSurface >
280+ < DialogBody >
281+ < DialogTitle > { translateMessage ( 'Upload collection' ) } </ DialogTitle >
282+ < DialogContent >
283+ { translateMessage ( 'You have an existing collection. Would you like to merge or replace it?' ) }
284+ </ DialogContent >
285+ < DialogActions >
286+ < Button appearance = "primary" onClick = { mergeWithExistingCollection } >
287+ { translateMessage ( 'Merge with existing' ) }
288+ </ Button >
289+ < Button onClick = { overwriteCollection } >
290+ { translateMessage ( 'Replace existing' ) }
291+ </ Button >
292+ </ DialogActions >
293+ </ DialogBody >
294+ </ DialogSurface >
295+ </ Dialog >
296+ </ CommonCollectionsPanel >
278297 )
279298}
280299
0 commit comments