Skip to content

Commit

Permalink
feat(webdav): improve icons and zh-TW translation for #147
Browse files Browse the repository at this point in the history
  • Loading branch information
HFO4 committed Feb 7, 2023
1 parent e4b6e58 commit b6b59dd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
3 changes: 3 additions & 0 deletions public/locales/zh-TW/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@
"rootFolder": "相對根目錄",
"createdAt": "創建日期",
"action": "操作",
"readonlyOn": "開啓只讀",
"readonlyOff": "關閉只讀",
"delete": "刪除",
"listEmpty": "沒有記錄",
"createNewAccount": "創建新帳號",
"taskType": "任務類型",
Expand Down
50 changes: 33 additions & 17 deletions src/component/Setting/WebDAV.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Alert from "@material-ui/lab/Alert";
import Auth from "../../middleware/Auth";
import API from "../../middleware/Api";
import IconButton from "@material-ui/core/IconButton";
import { Delete, ToggleOff, ToggleOn } from "@material-ui/icons";
import { Delete } from "@material-ui/icons";
import CreateWebDAVAccount from "../Modals/CreateWebDAVAccount";
import TimeAgo from "timeago-react";
import Link from "@material-ui/core/Link";
Expand All @@ -25,6 +25,7 @@ import { useTranslation } from "react-i18next";
import AppPromotion from "./AppPromotion";
import Tooltip from "@material-ui/core/Tooltip";
import ToggleIcon from "material-ui-toggle-icon";
import { Pencil, PencilOff } from "mdi-material-ui";

const useStyles = makeStyles((theme) => ({
layout: {
Expand Down Expand Up @@ -118,13 +119,15 @@ export default function WebDAV() {
API.patch("/webdav/accounts", {
id: account.ID,
readonly: !account.Readonly,
}).then((response) => {
account.Readonly = response.data.readonly;
const accountCopy = [...accounts];
setAccounts(accountCopy);
}).catch((error) => {
ToggleSnackbar("top", "right", error.message, "error");
});
})
.then((response) => {
account.Readonly = response.data.readonly;
const accountCopy = [...accounts];
setAccounts(accountCopy);
})
.catch((error) => {
ToggleSnackbar("top", "right", error.message, "error");
});
};

const addAccount = (account) => {
Expand Down Expand Up @@ -252,23 +255,36 @@ export default function WebDAV() {
placement="top"
title={
row.Readonly
? t("setting.readonlyOff")
: t("setting.readonlyOn")
? t(
"setting.readonlyOff"
)
: t(
"setting.readonlyOn"
)
}
onClick={() =>
toggleAccountReadonly(id)
}>
toggleAccountReadonly(
id
)
}
>
<IconButton>
<ToggleIcon
on={row.Readonly}
on={
row.Readonly
}
onIcon={
<ToggleOn
fontSize={"small"}
<PencilOff
fontSize={
"small"
}
/>
}
offIcon={
<ToggleOff
fontSize={"small"}
<Pencil
fontSize={
"small"
}
/>
}
/>
Expand Down

0 comments on commit b6b59dd

Please sign in to comment.