Simplify rights assignation for mobile application
This commit is contained in:
parent
7155d91bed
commit
867afb8058
@ -4,6 +4,7 @@ import {
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
Tooltip,
|
||||
} from "@mui/material";
|
||||
import React from "react";
|
||||
import { ServerApi } from "../api/ServerApi";
|
||||
@ -54,19 +55,31 @@ export function CreateTokenDialog(p: {
|
||||
|
||||
const submit = async () => {
|
||||
try {
|
||||
loadingMessage.show("Création du jeton en cours...");
|
||||
loadingMessage.show("Creating token...");
|
||||
const token = await TokensApi.Create(newToken);
|
||||
|
||||
clearForm();
|
||||
p.onCreated(token);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert("Failed to create token !");
|
||||
alert(`Failed to create token ! ${e}`);
|
||||
} finally {
|
||||
loadingMessage.hide();
|
||||
}
|
||||
};
|
||||
|
||||
const updateRightsForMobileApp = () => {
|
||||
setNewToken({
|
||||
...newToken,
|
||||
read_only: false,
|
||||
right_account: false,
|
||||
right_movement: false,
|
||||
right_attachment: true,
|
||||
right_auth: true,
|
||||
right_inbox: true,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={p.open} onClose={cancel}>
|
||||
<DialogTitle>Nouveau jeton</DialogTitle>
|
||||
@ -126,6 +139,9 @@ export function CreateTokenDialog(p: {
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<Tooltip title="Tailor the rights for the mobile application">
|
||||
<Button onClick={updateRightsForMobileApp}>For mobile app</Button>
|
||||
</Tooltip>
|
||||
<br />
|
||||
<CheckboxInput
|
||||
editable
|
||||
@ -188,9 +204,9 @@ export function CreateTokenDialog(p: {
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={cancel}>Annuler</Button>
|
||||
<Button onClick={cancel}>Cancel</Button>
|
||||
<Button onClick={submit} autoFocus disabled={!isValid}>
|
||||
Créer
|
||||
Create
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
@ -106,7 +106,7 @@ function TokensRouteInner(p: {
|
||||
snackbar("The token was successfully deleted!");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert("Failed to delete API token!");
|
||||
alert(`Failed to delete API token! ${e}`);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user