77 ProjectPageQuery$data ,
88 ProjectPageQuery$variables ,
99} from '../__generated__/ProjectPageQuery.graphql' ;
10+ import BAIRadioGroup from '../components/BAIRadioGroup' ;
1011import { useBAIPaginationOptionStateOnSearchParam } from '../hooks/reactPaginationQueryOptions' ;
1112import { useCSVExport } from '../hooks/useCSVExport' ;
1213import { PlusOutlined } from '@ant-design/icons' ;
@@ -15,7 +16,6 @@ import { App } from 'antd';
1516import {
1617 availableProjectSorterValues ,
1718 BAIButton ,
18- BAICard ,
1919 BAIFetchKeyButton ,
2020 BAIFlex ,
2121 BAIProjectBulkEditModal ,
@@ -135,26 +135,22 @@ const ProjectPage = () => {
135135 } ,
136136 ) ;
137137 return (
138- < BAICard
139- activeTabKey = { queryParams . status }
140- onTabChange = { ( key ) => {
141- setQueryParams ( { status : key as 'active' | 'inactive' } ) ;
142- setTablePaginationOption ( { current : 1 } ) ;
143- setSelectedProjectList ( [ ] ) ;
144- } }
145- tabList = { [
146- {
147- key : 'active' ,
148- label : t ( 'general.Active' ) ,
149- } ,
150- {
151- key : 'inactive' ,
152- label : t ( 'general.Inactive' ) ,
153- } ,
154- ] }
155- >
156- < BAIFlex direction = "column" align = "stretch" gap = "sm" >
157- < BAIFlex justify = "between" wrap = "wrap" gap = "sm" >
138+ < BAIFlex direction = "column" align = "stretch" gap = "sm" >
139+ < BAIFlex justify = "between" align = "start" wrap = "wrap" gap = "xs" >
140+ < BAIFlex direction = "row" gap = "sm" align = "start" wrap = "wrap" >
141+ < BAIRadioGroup
142+ value = { queryParams . status }
143+ onChange = { ( e ) => {
144+ setQueryParams ( { status : e . target . value } ) ;
145+ setTablePaginationOption ( { current : 1 } ) ;
146+ setSelectedProjectList ( [ ] ) ;
147+ } }
148+ optionType = "button"
149+ options = { [
150+ { label : t ( 'general.Active' ) , value : 'active' } ,
151+ { label : t ( 'general.Inactive' ) , value : 'inactive' } ,
152+ ] }
153+ />
158154 < BAIPropertyFilter
159155 filterProperties = { [
160156 {
@@ -189,101 +185,101 @@ const ProjectPage = () => {
189185 setSelectedProjectList ( [ ] ) ;
190186 } }
191187 />
192- < BAIFlex gap = "xs" >
193- { selectedProjectList . length > 0 && (
194- < >
195- < BAISelectionLabel
196- count = { selectedProjectList . length }
197- onClearSelection = { ( ) => setSelectedProjectList ( [ ] ) }
198- />
199- < BAIButton onClick = { toggleBulkEditModal } >
200- { t ( 'project.BulkEdit' ) }
201- </ BAIButton >
202- </ >
203- ) }
204- < BAIFetchKeyButton
205- value = { fetchKey }
206- autoUpdateDelay = { null }
207- loading = { deferredFetchKey !== fetchKey }
208- onChange = { ( ) => {
209- updateFetchKey ( ) ;
210- } }
211- />
212- < BAIButton
213- type = "primary"
214- icon = { < PlusOutlined /> }
215- onClick = { toggleSettingModal }
216- >
217- { t ( 'project.CreateProject' ) }
218- </ BAIButton >
219- </ BAIFlex >
220188 </ BAIFlex >
221- < BAIProjectTable
222- updateFetchKey = { updateFetchKey }
223- isActiveTab = { isActiveTab }
224- projectFragment = { filterOutEmpty (
225- group_nodes ?. edges . map ( ( e ) => e ?. node ) ?? [ ] ,
189+ < BAIFlex gap = "xs" >
190+ { selectedProjectList . length > 0 && (
191+ < >
192+ < BAISelectionLabel
193+ count = { selectedProjectList . length }
194+ onClearSelection = { ( ) => setSelectedProjectList ( [ ] ) }
195+ />
196+ < BAIButton onClick = { toggleBulkEditModal } >
197+ { t ( 'project.BulkEdit' ) }
198+ </ BAIButton >
199+ </ >
226200 ) }
227- loading = {
228- deferredFetchKey !== fetchKey ||
229- deferredValueQueryVariables !== queryVariables
230- }
231- pagination = { {
232- pageSize : tablePaginationOption . pageSize ,
233- current : tablePaginationOption . current ,
234- total : group_nodes ?. count ?? 0 ,
235- onChange : ( current , pageSize ) => {
236- if ( _ . isNumber ( pageSize ) && _ . isNumber ( current ) ) {
237- setTablePaginationOption ( { current, pageSize } ) ;
238- setSelectedProjectList ( [ ] ) ;
239- }
240- } ,
241- } }
242- order = { queryParams . order }
243- onChangeOrder = { ( order ) => {
244- setQueryParams ( { order } ) ;
245- } }
246- onClickProjectEditButton = { ( project ) => {
247- group_nodes ?. edges . forEach ( ( edge ) => {
248- if ( edge ?. node ?. id === project . id ) {
249- setSelectedProject ( edge . node ) ;
250- toggleSettingModal ( ) ;
251- }
252- } ) ;
253- } }
254- exportSettings = {
255- ! _ . isEmpty ( supportedFields )
256- ? {
257- supportedFields,
258- onExport : async ( selectedExportKeys ) => {
259- await exportCSV ( selectedExportKeys ) . catch ( ( err ) => {
260- message . error ( t ( 'general.ErrorOccurred' ) ) ;
261- logger . error ( err ) ;
262- } ) ;
263- } ,
264- }
265- : undefined
266- }
267- rowSelection = { {
268- type : 'checkbox' ,
269- onChange : ( keys ) => {
270- if ( ! group_nodes ) {
271- return ;
272- }
273- setSelectedProjectList (
274- _ . filter (
275- _ . compact ( _ . map ( group_nodes . edges , ( e ) => e ?. node ) ) ,
276- ( node ) => keys . includes ( node . id ) ,
277- ) ,
278- ) ;
279- } ,
280- selectedRowKeys : _ . map ( selectedProjectList , 'id' ) ,
281- getCheckboxProps : ( record ) => ( {
282- disabled : _ . get ( record , 'type' ) === 'MODEL_STORE' ,
283- } ) ,
284- } }
285- />
201+ < BAIFetchKeyButton
202+ value = { fetchKey }
203+ autoUpdateDelay = { null }
204+ loading = { deferredFetchKey !== fetchKey }
205+ onChange = { ( ) => {
206+ updateFetchKey ( ) ;
207+ } }
208+ />
209+ < BAIButton
210+ type = "primary"
211+ icon = { < PlusOutlined /> }
212+ onClick = { toggleSettingModal }
213+ >
214+ { t ( 'project.CreateProject' ) }
215+ </ BAIButton >
216+ </ BAIFlex >
286217 </ BAIFlex >
218+ < BAIProjectTable
219+ updateFetchKey = { updateFetchKey }
220+ isActiveTab = { isActiveTab }
221+ projectFragment = { filterOutEmpty (
222+ group_nodes ?. edges . map ( ( e ) => e ?. node ) ?? [ ] ,
223+ ) }
224+ loading = {
225+ deferredFetchKey !== fetchKey ||
226+ deferredValueQueryVariables !== queryVariables
227+ }
228+ pagination = { {
229+ pageSize : tablePaginationOption . pageSize ,
230+ current : tablePaginationOption . current ,
231+ total : group_nodes ?. count ?? 0 ,
232+ onChange : ( current , pageSize ) => {
233+ if ( _ . isNumber ( pageSize ) && _ . isNumber ( current ) ) {
234+ setTablePaginationOption ( { current, pageSize } ) ;
235+ setSelectedProjectList ( [ ] ) ;
236+ }
237+ } ,
238+ } }
239+ order = { queryParams . order }
240+ onChangeOrder = { ( order ) => {
241+ setQueryParams ( { order } ) ;
242+ } }
243+ onClickProjectEditButton = { ( project ) => {
244+ group_nodes ?. edges . forEach ( ( edge ) => {
245+ if ( edge ?. node ?. id === project . id ) {
246+ setSelectedProject ( edge . node ) ;
247+ toggleSettingModal ( ) ;
248+ }
249+ } ) ;
250+ } }
251+ exportSettings = {
252+ ! _ . isEmpty ( supportedFields )
253+ ? {
254+ supportedFields,
255+ onExport : async ( selectedExportKeys ) => {
256+ await exportCSV ( selectedExportKeys ) . catch ( ( err ) => {
257+ message . error ( t ( 'general.ErrorOccurred' ) ) ;
258+ logger . error ( err ) ;
259+ } ) ;
260+ } ,
261+ }
262+ : undefined
263+ }
264+ rowSelection = { {
265+ type : 'checkbox' ,
266+ onChange : ( keys ) => {
267+ if ( ! group_nodes ) {
268+ return ;
269+ }
270+ setSelectedProjectList (
271+ _ . filter (
272+ _ . compact ( _ . map ( group_nodes . edges , ( e ) => e ?. node ) ) ,
273+ ( node ) => keys . includes ( node . id ) ,
274+ ) ,
275+ ) ;
276+ } ,
277+ selectedRowKeys : _ . map ( selectedProjectList , 'id' ) ,
278+ getCheckboxProps : ( record ) => ( {
279+ disabled : _ . get ( record , 'type' ) === 'MODEL_STORE' ,
280+ } ) ,
281+ } }
282+ />
287283 < BAIProjectSettingModal
288284 open = { openSettingModal }
289285 onOk = { ( ) => {
@@ -309,7 +305,7 @@ const ProjectPage = () => {
309305 toggleBulkEditModal ( ) ;
310306 } }
311307 />
312- </ BAICard >
308+ </ BAIFlex >
313309 ) ;
314310} ;
315311
0 commit comments