Simplify rights assignation for mobile application
This commit is contained in:
parent
7155d91bed
commit
867afb8058
@ -4,6 +4,7 @@ import {
|
|||||||
DialogActions,
|
DialogActions,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
|
Tooltip,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { ServerApi } from "../api/ServerApi";
|
import { ServerApi } from "../api/ServerApi";
|
||||||
@ -54,19 +55,31 @@ export function CreateTokenDialog(p: {
|
|||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
try {
|
try {
|
||||||
loadingMessage.show("Création du jeton en cours...");
|
loadingMessage.show("Creating token...");
|
||||||
const token = await TokensApi.Create(newToken);
|
const token = await TokensApi.Create(newToken);
|
||||||
|
|
||||||
clearForm();
|
clearForm();
|
||||||
p.onCreated(token);
|
p.onCreated(token);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
alert("Failed to create token !");
|
alert(`Failed to create token ! ${e}`);
|
||||||
} finally {
|
} finally {
|
||||||
loadingMessage.hide();
|
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 (
|
return (
|
||||||
<Dialog open={p.open} onClose={cancel}>
|
<Dialog open={p.open} onClose={cancel}>
|
||||||
<DialogTitle>Nouveau jeton</DialogTitle>
|
<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 />
|
<br />
|
||||||
<CheckboxInput
|
<CheckboxInput
|
||||||
editable
|
editable
|
||||||
@ -188,9 +204,9 @@ export function CreateTokenDialog(p: {
|
|||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={cancel}>Annuler</Button>
|
<Button onClick={cancel}>Cancel</Button>
|
||||||
<Button onClick={submit} autoFocus disabled={!isValid}>
|
<Button onClick={submit} autoFocus disabled={!isValid}>
|
||||||
Créer
|
Create
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
@ -106,7 +106,7 @@ function TokensRouteInner(p: {
|
|||||||
snackbar("The token was successfully deleted!");
|
snackbar("The token was successfully deleted!");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(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