feat(permissions): add reset to defaults button in permissions modals (#25931)
Adds a 'Reset to Defaults' button to both the Edit Default Permissions modal and the Edit User Group permissions modal. - Default permissions modal: resets to stock/env-var configuration - User group modal: resets to current global default permissions Backend: new GET /api/v1/users/default/permissions/defaults endpoint that returns DEFAULT_USER_PERMISSIONS (env-var-based initial defaults).
This commit is contained in:
@@ -85,6 +85,33 @@ export const updateUserDefaultPermissions = async (token: string, permissions: o
|
||||
return res;
|
||||
};
|
||||
|
||||
export const getUserDefaultPermissionsDefaults = async (token: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/users/default/permissions/defaults`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
error = err.detail;
|
||||
return null;
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const updateUserRole = async (token: string, id: string, role: string) => {
|
||||
let error = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user