diff --git a/packages/app/src/settings/api/index.jsx b/packages/app/src/settings/api/index.jsx index 32bbed72..b6ad2b85 100644 --- a/packages/app/src/settings/api/index.jsx +++ b/packages/app/src/settings/api/index.jsx @@ -13,322 +13,312 @@ import ServerKeysModel from "@models/api" import "./index.less" const ServerKeyCreator = (props) => { - const [name, setName] = React.useState("") - const [access, setAccess] = React.useState(null) + const [name, setName] = React.useState("") + const [access, setAccess] = React.useState(null) - const [result, setResult] = React.useState(null) - const [error, setError] = React.useState(null) + const [result, setResult] = React.useState(null) + const [error, setError] = React.useState(null) - const canSubmit = () => { - return name && access - } + const canSubmit = () => { + return name && access + } - const onSubmit = async () => { - if (!canSubmit()) { - return - } + const onSubmit = async () => { + if (!canSubmit()) { + return + } - const result = await ServerKeysModel.createNewServerKey({ - name, - access - }) + const result = await ServerKeysModel.createNewServerKey({ + name, + access, + }) - if (result) { - setResult(result) - } - } + if (result) { + setResult(result) + } + } - const onRegenerate = async () => { - app.layout.modal.confirm({ - headerText: "Regenerate secret token", - descriptionText: "When a key is regenerated, the old secret token will be replaced with a new one. This action cannot be undone.", - onConfirm: async () => { - await ServerKeysModel.regenerateSecretToken(result.access_id) - .then((data) => { - app.message.info("Secret token regenerated") - setResult(data) - }) - .catch((error) => { - app.message.error(error.message) - setError(error.message) - }) - } - }) - } + const onRegenerate = async () => { + app.layout.modal.confirm({ + headerText: "Regenerate secret token", + descriptionText: + "When a key is regenerated, the old secret token will be replaced with a new one. This action cannot be undone.", + onConfirm: async () => { + await ServerKeysModel.regenerateSecretToken(result.access_id) + .then((data) => { + app.message.info("Secret token regenerated") + setResult(data) + }) + .catch((error) => { + app.message.error(error.message) + setError(error.message) + }) + }, + }) + } - const onDelete = async () => { - app.layout.modal.confirm({ - headerText: "Delete server key", - descriptionText: "Deleting this server key will remove it from your account. This action cannot be undone.", - onConfirm: async () => { - await ServerKeysModel.deleteServerKey(result.access_id) - .then(() => { - app.message.info("Server key deleted") - props.close() - }) - .catch((error) => { - app.message.error(error.message) - setError(error.message) - }) - }, - }) - } + const onDelete = async () => { + app.layout.modal.confirm({ + headerText: "Delete server key", + descriptionText: + "Deleting this server key will remove it from your account. This action cannot be undone.", + onConfirm: async () => { + await ServerKeysModel.deleteServerKey(result.access_id) + .then(() => { + app.message.info("Server key deleted") + props.close() + }) + .catch((error) => { + app.message.error(error.message) + setError(error.message) + }) + }, + }) + } - async function generateAuthJSON() { - const data = { - name: result.name, - access: result.access, - access_id: result.access_id, - secret_token: result.secret_token - } + async function generateAuthJSON() { + const data = { + name: result.name, + access: result.access, + access_id: result.access_id, + secret_token: result.secret_token, + } - await textToDownload(JSON.stringify(data), `comtyapi-${result.name}-auth.json`) - } + await textToDownload( + JSON.stringify(data), + `comtyapi-${result.name}-auth.json`, + ) + } - React.useEffect(() => { - if (props.data) { - setResult(props.data) - } - }, []) + React.useEffect(() => { + if (props.data) { + setResult(props.data) + } + }, []) - if (result) { - return
Name: {result.name}
+Name: {result.name}
-{name}
- {access_id} -{name}
+ {access_id} +- {mainOrigin} -
-{mainOrigin}
+Manage your API keys
-Manage your API keys
+