Skip to content

Commit cbbfba5

Browse files
committed
fix(FR-2272): add export-csv feature flag to useCSVExport hook (#5920)
Resolves #5911 ([FR-2272](https://lablup.atlassian.net/browse/FR-2272)) ## Summary - Add `export-csv` feature flag to backend client for manager >= 26.2.0 - Guard `useCSVExport` hook to skip CSV export API calls when the backend doesn't support the feature ## Test plan - [ ] Verify CSV export works normally on manager >= 26.2.0 - [ ] Verify no CSV export API calls are made on older manager versions [FR-2272]: https://lablup.atlassian.net/browse/FR-2272?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent d5261e4 commit cbbfba5

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

react/src/hooks/useCSVExport.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useSuspendedBackendaiClient } from '.';
12
import { useCurrentUserRole } from './backendai';
23
import { useSuspenseTanQuery } from './reactQueryAlias';
34
import {
@@ -28,16 +29,24 @@ export const useCSVExport = (nodeKey: SupportedNodeKeys) => {
2829
'use memo';
2930

3031
const { t } = useTranslation();
32+
const baiClient = useSuspendedBackendaiClient();
3133
const baiRequestWithPromise = useBAISignedRequestWithPromise();
3234
const { getErrorMessage } = useErrorMessageResolver();
3335
const userRole = useCurrentUserRole();
3436

3537
const isAdmin = userRole === 'superadmin' || userRole === 'admin';
38+
const isExportCSVSupported = baiClient.supports('export-csv');
3639

3740
const { data: supportedFields } = useSuspenseTanQuery<Array<string>>({
38-
queryKey: ['CSVExport', 'supportedFields', nodeKey, isAdmin],
41+
queryKey: [
42+
'CSVExport',
43+
'supportedFields',
44+
nodeKey,
45+
isAdmin,
46+
isExportCSVSupported,
47+
],
3948
queryFn: () => {
40-
if (!isAdmin) return [];
49+
if (!isAdmin || !isExportCSVSupported) return [];
4150
return baiRequestWithPromise({
4251
method: 'GET',
4352
url: `/export/reports/${nodeKey}`,

src/lib/backend.ai-client-esm.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ class Client {
890890
if (this.isManagerVersionCompatibleWith('26.2.0')) {
891891
this._features['fair-share-scheduling'] = true;
892892
this._features['session-scheduling-history'] = true;
893+
this._features['export-csv'] = true;
893894
}
894895
}
895896

0 commit comments

Comments
 (0)