Web:Client: fix restore backup file input

This commit is contained in:
Timofey Boyko 2023-06-29 17:12:41 +03:00
parent 1df8d8c7b5
commit 16c2d0ac92
4 changed files with 36 additions and 7 deletions

View File

@ -136,7 +136,11 @@ export type FilesSelectorProps = {
fileTitle: string,
openNewTab: boolean
) => void;
onSelectFile?: (fileInfo: { id: string | number; title: string }) => void;
onSelectFile?: (fileInfo: {
id: string | number;
title: string;
path?: string[];
}) => void;
withFooterInput?: boolean;
withFooterCheckbox?: boolean;

View File

@ -100,6 +100,7 @@ const FilesSelector = ({
const [selectedFileInfo, setSelectedFileInfo] = React.useState<{
id: number | string;
title: string;
path?: string[];
} | null>(null);
const [total, setTotal] = React.useState<number>(0);
@ -357,7 +358,22 @@ const FilesSelector = ({
selectedItemId &&
onSave(null, selectedItemId, fileName, isChecked);
onSelectTreeNode && onSelectTreeNode(selectedTreeNode);
onSelectFile && selectedFileInfo && onSelectFile(selectedFileInfo);
const info: {
id: string | number;
title: string;
path?: string[];
} = {
id: selectedFileInfo?.id || "",
title: selectedFileInfo?.title || "",
path: [],
};
breadCrumbs.forEach((item, index) => {
if (index !== 0 && info.path) info.path.push(item.label);
});
onSelectFile && selectedFileInfo && onSelectFile(info);
!withoutImmediatelyClose && onCloseAction();
}
};

View File

@ -72,10 +72,13 @@ SelectFileInput.defaultProps = {
};
export default inject(
({ clientLoadingStore, treeFoldersStore, selectFileDialogStore }) => {
(
{ clientLoadingStore, treeFoldersStore, selectFileDialogStore },
{ fileName: fileNameProps }
) => {
const { setFirstLoad } = clientLoadingStore;
const { folderId, setFolderId, setFile, fileInfo } = selectFileDialogStore;
const fileName = fileInfo?.title;
const fileName = fileInfo?.title || fileNameProps;
const { setExpandedPanelKeys } = treeFoldersStore;
return {
setFirstLoad,

View File

@ -59,6 +59,7 @@ const RestoreBackup = (props) => {
useState(false);
const [isVisibleSelectFileDialog, setIsVisibleSelectFileDialog] =
useState(false);
const [path, setPath] = useState("");
const startRestoreBackup = useCallback(async () => {
try {
@ -149,7 +150,7 @@ const RestoreBackup = (props) => {
onClick={onChangeRadioButton}
selected={radioButtonState}
spacing="16px"
isDisabled={!isEnableRestore}
// isDisabled={!isEnableRestore}
/>
</>
);
@ -160,12 +161,17 @@ const RestoreBackup = (props) => {
{radioButtonState === BACKUP_ROOM && (
<RoomsModule
isDisabled={!isEnableRestore}
// isDisabled={!isEnableRestore}
t={t}
fileName={path}
isPanelVisible={isVisibleSelectFileDialog}
onClose={onModalClose}
onClickInput={onClickInput}
onSelectFile={(file) => setRestoreResource(file.id)}
onSelectFile={(file) => {
const newPath = file.path.join("/");
setPath(`${newPath}/${file.title}`);
setRestoreResource(file.id);
}}
/>
)}
{radioButtonState === DISK_SPACE && (