-
Notifications
You must be signed in to change notification settings - Fork 79
feat(FR-2613): migrate VFolder trash lifecycle mutations to V2 GraphQL API #6817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
graphite-app
merged 1 commit into
main
from
04-21-feat_fr-2613_migrate_vfolder_trash_lifecycle_mutations_to_v2_graphql_api
Apr 30, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| /** | ||
| @license | ||
| Copyright (c) 2015-2026 Lablup Inc. All rights reserved. | ||
| */ | ||
| import { DeleteForeverVFolderModalV2Fragment$key } from '../__generated__/DeleteForeverVFolderModalV2Fragment.graphql'; | ||
| import { DeleteForeverVFolderModalV2Mutation } from '../__generated__/DeleteForeverVFolderModalV2Mutation.graphql'; | ||
| import { Alert, App, theme, Typography } from 'antd'; | ||
| import { | ||
| BAIConfirmModalWithInput, | ||
| BAIConfirmModalWithInputProps, | ||
| BAIFlex, | ||
| toLocalId, | ||
| useErrorMessageResolver, | ||
| } from 'backend.ai-ui'; | ||
| import * as _ from 'lodash-es'; | ||
| import React from 'react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import { graphql, useFragment, useMutation } from 'react-relay'; | ||
|
|
||
| interface DeleteForeverVFolderModalV2Props extends Omit< | ||
| BAIConfirmModalWithInputProps, | ||
| 'confirmText' | 'content' | 'title' | 'onOk' | 'onCancel' | ||
| > { | ||
| vfolderFrgmts?: DeleteForeverVFolderModalV2Fragment$key; | ||
| onRequestClose?: (success: boolean) => void; | ||
| } | ||
|
|
||
| const DeleteForeverVFolderModalV2: React.FC< | ||
| DeleteForeverVFolderModalV2Props | ||
| > = ({ vfolderFrgmts, onRequestClose, ...modalProps }) => { | ||
| 'use memo'; | ||
| const { t } = useTranslation(); | ||
| const { message } = App.useApp(); | ||
| const { token } = theme.useToken(); | ||
| const { getErrorMessage } = useErrorMessageResolver(); | ||
|
|
||
| const vfolders = useFragment( | ||
| graphql` | ||
| fragment DeleteForeverVFolderModalV2Fragment on VirtualFolderNode | ||
| @relay(plural: true) { | ||
| id | ||
| name | ||
| } | ||
| `, | ||
| vfolderFrgmts, | ||
| ); | ||
|
|
||
| const [commitBulkPurgeMutation, isInFlightBulkPurge] = | ||
| useMutation<DeleteForeverVFolderModalV2Mutation>(graphql` | ||
| mutation DeleteForeverVFolderModalV2Mutation( | ||
| $input: BulkPurgeVFoldersV2Input! | ||
| ) { | ||
| bulkPurgeVfoldersV2(input: $input) { | ||
| purgedCount | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| const purgeable = vfolders ?? []; | ||
| // For single-folder deletion the user must type the folder's own name — | ||
| // matches the BAIConfirmModalWithInput convention used elsewhere for | ||
| // irreversible per-resource actions. Bulk deletion falls back to a | ||
| // generic confirmation word since there is no single name to bind to. | ||
| const confirmText = | ||
| purgeable.length === 1 | ||
| ? (purgeable[0]?.name ?? t('data.folders.DeleteForeverConfirmText')) | ||
| : t('data.folders.DeleteForeverConfirmText'); | ||
|
|
||
| return ( | ||
| <BAIConfirmModalWithInput | ||
|
ironAiken2 marked this conversation as resolved.
|
||
| {...modalProps} | ||
| title={t('dialog.title.DeleteForever')} | ||
| okText={t('data.folders.DeleteForever')} | ||
| confirmLoading={isInFlightBulkPurge} | ||
| confirmText={confirmText} | ||
| content={ | ||
| <BAIFlex | ||
| direction="column" | ||
| gap="md" | ||
| align="stretch" | ||
| style={{ marginBottom: token.marginXS, width: '100%' }} | ||
| > | ||
| <Alert | ||
| type="warning" | ||
| title={t('dialog.warning.DeleteForeverDesc')} | ||
| style={{ width: '100%' }} | ||
| /> | ||
| <Typography.Text> | ||
| {purgeable.length === 1 | ||
| ? t('data.folders.DeleteForeverDescription', { | ||
| folderName: purgeable[0]?.name, | ||
| }) | ||
| : t('data.folders.DeleteForeverMultipleDescription', { | ||
| folderLength: purgeable.length, | ||
| })} | ||
| </Typography.Text> | ||
| <BAIFlex> | ||
| <Typography.Text style={{ marginRight: token.marginXXS }}> | ||
| {t('data.folders.TypeToConfirmDeleteForever')} | ||
| </Typography.Text> | ||
| (<Typography.Text code>{confirmText}</Typography.Text>) | ||
| </BAIFlex> | ||
| </BAIFlex> | ||
| } | ||
| onOk={() => { | ||
| if (purgeable.length === 0) { | ||
| onRequestClose?.(false); | ||
| return; | ||
| } | ||
| const ids = _.map(purgeable, (vfolder) => toLocalId(vfolder.id)); | ||
| commitBulkPurgeMutation({ | ||
| variables: { input: { ids } }, | ||
| onCompleted: (data, errors) => { | ||
| if (errors && errors.length > 0) { | ||
| const firstError = errors[0]; | ||
| message.error(firstError?.message ?? getErrorMessage(firstError)); | ||
| return; | ||
| } | ||
| const purgedCount = data?.bulkPurgeVfoldersV2?.purgedCount ?? 0; | ||
| if (purgedCount === 0) { | ||
| message.error( | ||
| t('data.folders.FailedToDeleteFolders', { | ||
| folderNames: _.map(purgeable, 'name').join(', '), | ||
| }), | ||
| ); | ||
| return; | ||
| } | ||
| if (purgeable.length === 1) { | ||
| message.success( | ||
| t('data.folders.FolderDeletedForever', { | ||
| folderName: purgeable[0]?.name, | ||
| }), | ||
| ); | ||
| } else { | ||
| message.success( | ||
| t('data.folders.MultipleFolderDeletedForever', { | ||
| count: purgedCount, | ||
| total: purgeable.length, | ||
| }), | ||
| ); | ||
| } | ||
| onRequestClose?.(true); | ||
| }, | ||
| onError: (error) => { | ||
| message.error(getErrorMessage(error)); | ||
| }, | ||
| }); | ||
| }} | ||
| onCancel={() => onRequestClose?.(false)} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default DeleteForeverVFolderModalV2; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.