Skip to content

Commit

Permalink
feat(explorer): advance delete options for users
Browse files Browse the repository at this point in the history
  • Loading branch information
HFO4 committed Feb 7, 2023
1 parent 8ff644d commit 09a5168
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 101 deletions.
7 changes: 6 additions & 1 deletion public/locales/en-US/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@
"directoryDownloadError": "Error: {{msg}}",
"directoryDownloadErrorNotification": "Error occurs while download {{name}}: {{msg}}",
"directoryDownloadAutoscroll": "Auto scroll",
"directoryDownloadCancelled": "Download cancelled"
"directoryDownloadCancelled": "Download cancelled",
"advanceOptions": "Advanced options",
"forceDelete": "Force delete ",
"forceDeleteDes": "Force delete file records, regardless of whether the physical file was successfully deleted.",
"unlinkOnly": "Unlink only",
"unlinkOnlyDes": "Delete file records only, physical files will not be deleted."
},
"uploader": {
"fileNotMatchError": "The selected file does not match the original file.",
Expand Down
4 changes: 3 additions & 1 deletion public/locales/en-US/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,9 @@
"decompressSize": "Maximum file size to be decompressed",
"decompressSizeDes": "The maximum total file size of decompression jobs that can be created by the user, fill in 0 to indicate no limit.",
"redirectedSource": "Use redirected source link",
"redirectedSourceDes": "When enabled, the source link to the file obtained by the user will be redirected by Cloudreve with a shorter link. When disabled, the source link to the file obtained by the user becomes the original URL to the file. Some policies produce non-redirected source links that do not remain persistent, see <0>Comparing Storage Policies</0>."
"redirectedSourceDes": "When enabled, the source link to the file obtained by the user will be redirected by Cloudreve with a shorter link. When disabled, the source link to the file obtained by the user becomes the original URL to the file. Some policies produce non-redirected source links that do not remain persistent, see <0>Comparing Storage Policies</0>.",
"advanceDelete": "Allow advanced file deletion options",
"advanceDeleteDes": "Once enabled, users can choose whether to force deletion and whether to unlink only physical links when deleting files. These options are similar to the administration dashboard when deleting files."
},
"user": {
"deleted": "User deleted.",
Expand Down
7 changes: 6 additions & 1 deletion public/locales/zh-CN/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@
"directoryDownloadError": "遇到错误:{{msg}}",
"directoryDownloadErrorNotification": "下载 {{name}} 遇到错误:{{msg}}",
"directoryDownloadAutoscroll": "自动滚动",
"directoryDownloadCancelled": "已取消下载"
"directoryDownloadCancelled": "已取消下载",
"advanceOptions": "高级选项",
"forceDelete": "强制删除文件",
"forceDeleteDes": "强制删除文件记录,无论物理文件是否被成功删除",
"unlinkOnly": "仅解除链接",
"unlinkOnlyDes": "仅删除文件记录,物理文件不会被删除"
},
"uploader": {
"fileNotMatchError": "所选择文件与原始文件不符",
Expand Down
4 changes: 3 additions & 1 deletion public/locales/zh-CN/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,9 @@
"decompressSize": "待解压文件最大大小",
"decompressSizeDes": "用户可创建的解压缩任务的文件最大总大小,填写为 0 表示不限制",
"redirectedSource": "使用重定向的外链",
"redirectedSourceDes": "开启后,用户获取的文件外链将由 Cloudreve 中转,链接较短。关闭后,用户获取的文件外链会变成文件的原始链接。部分存储策略获取的非中转外链无法保持永久有效,请参阅 <0>比较存储策略</0>。"
"redirectedSourceDes": "开启后,用户获取的文件外链将由 Cloudreve 中转,链接较短。关闭后,用户获取的文件外链会变成文件的原始链接。部分存储策略获取的非中转外链无法保持永久有效,请参阅 <0>比较存储策略</0>。",
"advanceDelete": "允许使用高级文件删除选项",
"advanceDeleteDes": "开启后,用户在前台删除文件时可以选择是否强制删除、是否仅解除物理链接。这些选项与后台管理面板删除文件时类似,请只开放给可信用户组。"
},
"user": {
"deleted": "用户已删除",
Expand Down
7 changes: 6 additions & 1 deletion public/locales/zh-TW/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@
"directoryDownloadError": "遇到錯誤:{{msg}}",
"directoryDownloadErrorNotification": "下載 {{name}} 遇到錯誤:{{msg}}",
"directoryDownloadAutoscroll": "自動滾動",
"directoryDownloadCancelled": "已取消下載"
"directoryDownloadCancelled": "已取消下載",
"advanceOptions": "高級選項",
"forceDelete": "強制刪除文件",
"forceDeleteDes": "強制刪除文件記錄,無論物理文件是否被成功刪除",
"unlinkOnly": "僅解除鏈接",
"unlinkOnlyDes": "僅刪除文件記錄,物理文件不會被刪除"
},
"uploader": {
"fileNotMatchError": "所選擇文件與原始文件不符",
Expand Down
4 changes: 3 additions & 1 deletion public/locales/zh-TW/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,9 @@
"decompressSize": "待解壓文件最大大小",
"decompressSizeDes": "用戶可創建的解壓縮任務的文件最大總大小,填寫為 0 表示不限制",
"redirectedSource": "使用重定向的外鏈",
"redirectedSourceDes": "開啟後,用戶獲取的文件外鏈將由 Cloudreve 中轉,連結較短。關閉後,用戶獲取的文件外鏈會變成文件的原始連結。部分儲存策略獲取的非中轉外鏈無法保持永久有效,請參閱 <0>比較儲存策略</0>。"
"redirectedSourceDes": "開啟後,用戶獲取的文件外鏈將由 Cloudreve 中轉,連結較短。關閉後,用戶獲取的文件外鏈會變成文件的原始連結。部分儲存策略獲取的非中轉外鏈無法保持永久有效,請參閱 <0>比較儲存策略</0>。",
"advanceDelete": "允許使用高級文件刪除選項",
"advanceDeleteDes": "開啓後,用戶在前臺刪除文件時可以選擇是否強制刪除、是否僅解除物理鏈接。這些選項與後臺管理面板刪除文件時類似,請只開放給可信用戶組。"
},
"user": {
"deleted": "用戶已刪除",
Expand Down
3 changes: 2 additions & 1 deletion src/component/Admin/Group/EditGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default function EditGroupPreload() {
"one_time_download",
"share_download",
"aria2",
"redirected_source"
"redirected_source",
"advance_delete"
].forEach((v) => {
if (response.data.OptionsSerialized[v] !== undefined) {
response.data.OptionsSerialized[v] = response.data
Expand Down
29 changes: 27 additions & 2 deletions src/component/Admin/Group/GroupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import API from "../../../middleware/Api";
import SizeInput from "../Common/SizeInput";
import { Trans, useTranslation } from "react-i18next";
import { Link } from "@material-ui/core";
import { Link as RouterLink } from "react-router-dom";

const useStyles = makeStyles((theme) => ({
root: {
Expand Down Expand Up @@ -158,7 +157,8 @@ export default function GroupForm(props) {
"one_time_download",
"share_download",
"aria2",
"redirected_source"
"redirected_source",
"advance_delete"
].forEach((v) => {
if (groupCopy.OptionsSerialized[v] !== undefined) {
groupCopy.OptionsSerialized[v] =
Expand Down Expand Up @@ -626,6 +626,31 @@ export default function GroupForm(props) {
</FormControl>
</div>
)}

{group.ID !== 3 && (
<div className={classes.form}>
<FormControl fullWidth>
<FormControlLabel
control={
<Switch
checked={
group.OptionsSerialized
.advance_delete ===
"true"
}
onChange={handleOptionCheckChange(
"advance_delete"
)}
/>
}
label={t("advanceDelete")}
/>
<FormHelperText id="component-helper-text">
{t("advanceDeleteDes")}
</FormHelperText>
</FormControl>
</div>
)}
</div>
</div>
<div className={classes.root}>
Expand Down
101 changes: 9 additions & 92 deletions src/component/FileManager/Modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import PathSelector from "./PathSelector";
import API, { AppError } from "../../middleware/Api";
import API from "../../middleware/Api";
import {
Button,
CircularProgress,
Expand Down Expand Up @@ -33,6 +33,7 @@ import OptionSelector from "../Modals/OptionSelector";
import { getDownloadURL } from "../../services/file";
import { Trans, withTranslation } from "react-i18next";
import RemoteDownload from "../Modals/RemoteDownload";
import Delete from "../Modals/Delete";

const styles = (theme) => ({
wrapper: {
Expand Down Expand Up @@ -149,51 +150,6 @@ class ModalsCompoment extends Component {
});
};

submitRemove = (e) => {
e.preventDefault();
this.props.setModalsLoading(true);
const dirs = [],
items = [];
// eslint-disable-next-line
this.props.selected.map((value) => {
if (value.type === "dir") {
dirs.push(value.id);
} else {
items.push(value.id);
}
});
API.delete("/object", {
data: {
items: items,
dirs: dirs,
},
})
.then((response) => {
if (response.rawData.code === 0) {
this.onClose();
setTimeout(this.props.refreshFileList, 500);
} else {
this.props.toggleSnackbar(
"top",
"right",
response.rawData.msg,
"warning"
);
}
this.props.setModalsLoading(false);
this.props.refreshStorage();
})
.catch((error) => {
this.props.toggleSnackbar(
"top",
"right",
error.message,
"error"
);
this.props.setModalsLoading(false);
});
};

submitMove = (e) => {
if (e != null) {
e.preventDefault();
Expand Down Expand Up @@ -708,54 +664,15 @@ class ModalsCompoment extends Component {
</div>
</DialogActions>
</Dialog>
<Dialog
<Delete
open={this.props.modalsStatus.remove}
onClose={this.onClose}
aria-labelledby="form-dialog-title"
>
<DialogTitle id="form-dialog-title">
{t("modals.deleteTitle")}
</DialogTitle>

<DialogContent>
<DialogContentText>
{this.props.selected.length === 1 && (
<Trans
i18nKey="modals.deleteOneDescription"
values={{
name: this.props.selected[0].name,
}}
components={[<strong key={0} />]}
/>
)}
{this.props.selected.length > 1 &&
t("modals.deleteMultipleDescription", {
num: this.props.selected.length,
})}
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={this.onClose}>
{t("cancel", { ns: "common" })}
</Button>
<div className={classes.wrapper}>
<Button
onClick={this.submitRemove}
color="primary"
disabled={this.props.modalsLoading}
>
{t("ok", { ns: "common" })}
{this.props.modalsLoading && (
<CircularProgress
size={24}
className={classes.buttonProgress}
/>
)}
</Button>
</div>
</DialogActions>
</Dialog>

modalsLoading={this.props.modalsLoading}
setModalsLoading={this.props.setModalsLoading}
selected={this.props.selected}
refreshFileList={this.props.refreshFileList}
refreshStorage={this.props.refreshStorage}
/>
<CreatShare
open={this.props.modalsStatus.share}
onClose={this.onClose}
Expand Down
Loading

0 comments on commit 09a5168

Please sign in to comment.