@@ -20,6 +20,8 @@ import ReactGA from 'react-ga4'
2020import {
2121 AppListConstants ,
2222 ComponentSizeType ,
23+ ExportToCsv ,
24+ ExportToCsvProps ,
2325 FilterSelectPicker ,
2426 GroupedFilterSelectPicker ,
2527 GroupedFilterSelectPickerProps ,
@@ -30,12 +32,14 @@ import {
3032 useGetUserRoles ,
3133} from '@devtron-labs/devtron-fe-common-lib'
3234
33- import { FILE_NAMES } from '@Components/common/ExportToCsv/constants'
34- import ExportToCsv from '@Components/common/ExportToCsv/ExportToCsv'
35-
3635import { getDevtronAppListDataToExport } from './AppListService'
3736import { AppListFiltersProps , AppListUrlFilters , AppStatuses } from './AppListType'
38- import { APP_STATUS_FILTER_OPTIONS , SELECT_CLUSTER_TIPPY , TEMPLATE_TYPE_FILTER_OPTIONS } from './Constants'
37+ import {
38+ APP_STATUS_FILTER_OPTIONS ,
39+ APPLIST_EXPORT_HEADERS ,
40+ SELECT_CLUSTER_TIPPY ,
41+ TEMPLATE_TYPE_FILTER_OPTIONS ,
42+ } from './Constants'
3943import { getAppListFilters , getAppTabNameFromAppType , useFilterOptions } from './list.utils'
4044
4145const AppListFilters = ( {
@@ -203,6 +207,34 @@ const AppListFilters = ({
203207 } ,
204208 }
205209
210+ const getExportToCsvApiPromise : ExportToCsvProps < ( typeof APPLIST_EXPORT_HEADERS ) [ number ] [ 'key' ] > [ 'apiPromise' ] = ( {
211+ signal,
212+ } ) =>
213+ getDevtronAppListDataToExport (
214+ filterConfig ,
215+ appListFiltersResponse ?. appListFilters . result . environments ,
216+ namespaceListResponse ?. result ,
217+ appListFiltersResponse ?. appListFilters . result . clusters ,
218+ appListFiltersResponse ?. appListFilters . result . teams ,
219+ appCount ,
220+ signal ,
221+ )
222+
223+ const renderExportToCSV = ( ) => {
224+ if ( ! showExportCsvButton ) {
225+ return null
226+ }
227+
228+ return (
229+ < ExportToCsv < ( typeof APPLIST_EXPORT_HEADERS ) [ number ] [ 'key' ] >
230+ headers = { APPLIST_EXPORT_HEADERS }
231+ apiPromise = { getExportToCsvApiPromise }
232+ fileName = "Devtron Apps"
233+ disabled = { ! appCount }
234+ />
235+ )
236+ }
237+
206238 return (
207239 < div className = "search-filter-section" >
208240 < div className = "flex left dc__gap-8" >
@@ -251,22 +283,7 @@ const AppListFilters = ({
251283 ) }
252284 </ div >
253285
254- { window . _env_ . FEATURE_GROUPED_APP_LIST_FILTERS_ENABLE && showExportCsvButton && (
255- < ExportToCsv
256- apiPromise = { ( ) =>
257- getDevtronAppListDataToExport (
258- filterConfig ,
259- appListFiltersResponse ?. appListFilters . result . environments ,
260- namespaceListResponse ?. result ,
261- appListFiltersResponse ?. appListFilters . result . clusters ,
262- appListFiltersResponse ?. appListFilters . result . teams ,
263- appCount ,
264- )
265- }
266- fileName = { FILE_NAMES . Apps }
267- disabled = { ! appCount }
268- />
269- ) }
286+ { window . _env_ . FEATURE_GROUPED_APP_LIST_FILTERS_ENABLE && renderExportToCSV ( ) }
270287
271288 { ! window . _env_ . FEATURE_GROUPED_APP_LIST_FILTERS_ENABLE && (
272289 < div className = "flexbox dc__gap-8 dc__align-items-center" >
@@ -384,20 +401,7 @@ const AppListFilters = ({
384401 { showExportCsvButton && (
385402 < >
386403 < div className = "dc__border-right h-16" />
387- < ExportToCsv
388- apiPromise = { ( ) =>
389- getDevtronAppListDataToExport (
390- filterConfig ,
391- appListFiltersResponse ?. appListFilters . result . environments ,
392- namespaceListResponse ?. result ,
393- appListFiltersResponse ?. appListFilters . result . clusters ,
394- appListFiltersResponse ?. appListFilters . result . teams ,
395- appCount ,
396- )
397- }
398- fileName = { FILE_NAMES . Apps }
399- disabled = { ! appCount }
400- />
404+ { renderExportToCSV ( ) }
401405 </ >
402406 ) }
403407 </ div >
0 commit comments