Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinesmilelk authored and zhanba committed Feb 28, 2024
1 parent 45c8c1e commit e00ec11
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
11 changes: 7 additions & 4 deletions packages/libro-jupyter/src/file/file-create-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
}: ModalItemProps<ModalItemType>) => {
const fileService = useInject(JupyterFileService);
const viewManager = useInject(ViewManager);
const [fileType, setFileType] = useState<FileType>(data.fileType);
const [fileType, setFileType] = useState<FileType>(data?.fileType);
const [fileView, setFileView] = useState<FileView>();
const inputRef = useRef<InputRef>(null);
const [form] = Form.useForm();
Expand All @@ -37,7 +37,10 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
await form.validateFields();
close();
try {
await fileService.newFile(values.fileName + (fileType || ''), new URI(data.path));
await fileService.newFile(
values.fileName + (fileType || ''),
new URI(data?.path),
);
if (fileView) {
fileView.model.refresh();
}
Expand All @@ -50,7 +53,7 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
if (!value || !value.length) {
throw new Error('请输入文件名');
} else {
const targetURI = new URI(data.path + value + (fileType || ''));
const targetURI = new URI(data?.path + value + (fileType || ''));
const fileRes = await fileService.resolve(targetURI);
if (fileRes.isFile) {
throw new Error('文件名称已存在,请重新输入');
Expand Down Expand Up @@ -86,7 +89,7 @@ export const FileCreateModalComponent: React.FC<ModalItemProps<ModalItemType>> =
>
<div className="libro-create-file-path-container">
<div className="libro-create-file-des">创建位置:</div>
<span className="libro-create-file-path">{data.path}</span>
<span className="libro-create-file-path">{data?.path}</span>
</div>
<div className="libro-create-file-des">文件类型:</div>
<Row>
Expand Down
6 changes: 3 additions & 3 deletions packages/libro-jupyter/src/file/file-createdir-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const FileCreateDirModalComponent: React.FC<
await form.validateFields();
close();
try {
await fileService.newFileDir(values.dirName, new URI(data.path));
await fileService.newFileDir(values.dirName, new URI(data?.path));
if (fileView) {
fileView.model.refresh();
}
Expand All @@ -40,7 +40,7 @@ export const FileCreateDirModalComponent: React.FC<
if (!value || !value.length) {
throw new Error('请输入文件夹名');
} else {
const targetURI = new URI(data.path + value);
const targetURI = new URI(data?.path + value);
const fileRes = await fileService.resolve(targetURI);
if (fileRes.isDirectory) {
throw new Error('文件夹名称已存在,请重新输入');
Expand Down Expand Up @@ -75,7 +75,7 @@ export const FileCreateDirModalComponent: React.FC<
width={524}
>
<div className="libro-create-file-des">创建位置:</div>
<span className="libro-create-file-path">{data.path}</span>
<span className="libro-create-file-path">{data?.path}</span>
<Form
layout="vertical"
autoComplete="off"
Expand Down
13 changes: 7 additions & 6 deletions packages/libro-jupyter/src/file/file-rename-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ export const FileRenameModalComponent: React.FC<ModalItemProps<ModalItemType>> =
await form.validateFields();
close();
try {
await fileService.rename(data.resource, values.rename);

if (fileView) {
fileView.model.refresh();
if (data && data.resource) {
await fileService.rename(data.resource, values.rename);
if (fileView) {
fileView.model.refresh();
}
}
} catch {
message.error('重命名文件/文件夹失败');
Expand All @@ -54,7 +55,7 @@ export const FileRenameModalComponent: React.FC<ModalItemProps<ModalItemType>> =
if (!value || !value.length) {
throw new Error('请输入文件夹名');
} else {
if (value === data.fileName) {
if (value === data?.fileName) {
throw new Error('文件/文件夹名称已存在,请重新输入');
}
}
Expand All @@ -81,7 +82,7 @@ export const FileRenameModalComponent: React.FC<ModalItemProps<ModalItemType>> =
name="rename"
label="文件/文件夹名称"
rules={[{ required: true, validator: validateRename }]}
initialValue={data.fileName}
initialValue={data?.fileName}
>
<Input
ref={inputRef}
Expand Down

0 comments on commit e00ec11

Please sign in to comment.