|
1 | | -import { DialPopup } from '@/components/Popup/Popup'; |
2 | | -import { PopupSize } from '@/types/popup'; |
3 | 1 | import { |
4 | | - DialPrimaryButton, |
5 | 2 | DialNeutralButton, |
| 3 | + DialPrimaryButton, |
6 | 4 | } from '@/components/Button/ButtonWrappers'; |
7 | | -import { type FC, useState, useMemo, useCallback } from 'react'; |
8 | | -import type { DialFile } from '@/models/file'; |
9 | | -import { DialFileNodeType } from '@/models/file'; |
10 | | -import { DialRadioGroup } from '@/components/RadioGroup/RadioGroup'; |
11 | | -import { RadioGroupOrientation } from '@/types/radio-group'; |
12 | | -import type { RadioButtonWithContent } from '@/models/radio'; |
13 | 5 | import { DialDropdown } from '@/components/Dropdown/Dropdown'; |
14 | | -import type { DropdownItem } from '@/models/dropdown'; |
15 | | -import { DialGrid } from '@/components/Grid/Grid'; |
16 | | -import type { ColDef } from 'ag-grid-community'; |
| 6 | +import { BASE_FILE_MANAGER_ICON_SIZE } from '@/components/FileManager/constants'; |
17 | 7 | import { DialFileName } from '@/components/FileName/FileName'; |
18 | 8 | import { DialFolderName } from '@/components/FolderName/FolderName'; |
19 | | -import { BASE_FILE_MANAGER_ICON_SIZE } from '@/components/FileManager/constants'; |
| 9 | +import { DialGrid } from '@/components/Grid/Grid'; |
| 10 | +import { DialPopup } from '@/components/Popup/Popup'; |
| 11 | +import { DialRadioGroup } from '@/components/RadioGroup/RadioGroup'; |
| 12 | +import { DIAL_ICON_SIZE } from '@/constants/icon'; |
| 13 | +import type { DropdownItem } from '@/models/dropdown'; |
| 14 | +import type { DialFile } from '@/models/file'; |
| 15 | +import { DialFileNodeType } from '@/models/file'; |
| 16 | +import type { RadioButtonWithContent } from '@/models/radio'; |
20 | 17 | import { DropdownTrigger } from '@/types/dropdown'; |
21 | | -import { IconChevronDown, IconCircleFilled } from '@tabler/icons-react'; |
22 | | -import classNames from 'classnames'; |
23 | 18 | import { |
24 | 19 | DialFileManagerConflictActions, |
25 | 20 | DialFileManagerConflictStrategies, |
26 | 21 | } from '@/types/file-manager'; |
27 | | -import { DIAL_ICON_SIZE } from '@/constants/icon'; |
| 22 | +import { PopupSize } from '@/types/popup'; |
| 23 | +import { RadioGroupOrientation } from '@/types/radio-group'; |
| 24 | +import { IconChevronDown, IconCircleFilled } from '@tabler/icons-react'; |
| 25 | +import type { ColDef } from 'ag-grid-community'; |
| 26 | +import classNames from 'classnames'; |
| 27 | +import { type FC, useCallback, useMemo, useState } from 'react'; |
28 | 28 |
|
29 | 29 | export interface FileConflictDecision { |
30 | 30 | file: DialFile; |
@@ -384,7 +384,24 @@ export const ConflictResolutionPopup: FC<ConflictResolutionPopupProps> = ({ |
384 | 384 | ], |
385 | 385 | ); |
386 | 386 |
|
| 387 | + const resetState = useCallback(() => { |
| 388 | + setFileDecisions( |
| 389 | + new Map( |
| 390 | + conflictingFiles.map((file) => [ |
| 391 | + file.path, |
| 392 | + DialFileManagerConflictActions.Replace, |
| 393 | + ]), |
| 394 | + ), |
| 395 | + ); |
| 396 | + }, [conflictingFiles]); |
| 397 | + |
| 398 | + const handleClose = useCallback(() => { |
| 399 | + resetState(); |
| 400 | + onClose(); |
| 401 | + }, [resetState, onClose]); |
| 402 | + |
387 | 403 | const handleConfirm = useCallback(() => { |
| 404 | + resetState(); |
388 | 405 | if (isSingleFile) { |
389 | 406 | if (singleFileMode === DialFileManagerConflictActions.Replace) { |
390 | 407 | onReplace(); |
@@ -412,20 +429,21 @@ export const ConflictResolutionPopup: FC<ConflictResolutionPopupProps> = ({ |
412 | 429 | } |
413 | 430 | } |
414 | 431 | }, [ |
| 432 | + resetState, |
415 | 433 | isSingleFile, |
416 | 434 | singleFileMode, |
417 | | - strategy, |
418 | | - fileDecisions, |
419 | | - conflictingFiles, |
420 | 435 | onReplace, |
421 | 436 | onDuplicate, |
| 437 | + strategy, |
422 | 438 | onDecideForEach, |
| 439 | + conflictingFiles, |
| 440 | + fileDecisions, |
423 | 441 | ]); |
424 | 442 |
|
425 | 443 | return ( |
426 | 444 | <DialPopup |
427 | 445 | open={open} |
428 | | - onClose={onClose} |
| 446 | + onClose={handleClose} |
429 | 447 | size={isSingleFile ? PopupSize.Sm : PopupSize.Md} |
430 | 448 | className={classNames([!isSingleFile && 'w-[600px]'])} |
431 | 449 | header={title} |
|
0 commit comments