mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-10 04:28:50 +01:00
feat: enforce at least one owner requirement for permission updates and add corresponding localization messages
This commit is contained in:
parent
669af746ed
commit
57084f2caa
3 changed files with 22 additions and 4 deletions
|
|
@ -165,6 +165,11 @@ export default function ManagePermissionsDialog({
|
|||
const totalShares = managedShares.length + (managedIsPublic ? 1 : 0);
|
||||
const originalTotalShares = currentShares.length + (isPublic ? 1 : 0);
|
||||
|
||||
// Check if there's at least one owner (user, group, or public with owner role)
|
||||
const hasAtLeastOneOwner =
|
||||
managedShares.some((share) => share.accessRoleId === ACCESS_ROLE_IDS.AGENT_OWNER) ||
|
||||
(managedIsPublic && managedPublicRole === ACCESS_ROLE_IDS.AGENT_OWNER);
|
||||
|
||||
return (
|
||||
<OGDialog open={isModalOpen} onOpenChange={setIsModalOpen}>
|
||||
<OGDialogTrigger asChild>
|
||||
|
|
@ -281,7 +286,12 @@ export default function ManagePermissionsDialog({
|
|||
</OGDialogClose>
|
||||
<Button
|
||||
onClick={handleSaveChanges}
|
||||
disabled={updatePermissionsMutation.isLoading || !hasChanges || isLoadingPermissions}
|
||||
disabled={
|
||||
updatePermissionsMutation.isLoading ||
|
||||
!hasChanges ||
|
||||
isLoadingPermissions ||
|
||||
!hasAtLeastOneOwner
|
||||
}
|
||||
className="min-w-[120px]"
|
||||
>
|
||||
{updatePermissionsMutation.isLoading ? (
|
||||
|
|
@ -300,6 +310,12 @@ export default function ManagePermissionsDialog({
|
|||
* {localize('com_ui_unsaved_changes')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!hasAtLeastOneOwner && hasChanges && (
|
||||
<div className="text-xs text-red-600 dark:text-red-400">
|
||||
* {localize('com_ui_at_least_one_owner_required')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</OGDialogContent>
|
||||
</OGDialog>
|
||||
|
|
|
|||
|
|
@ -963,5 +963,6 @@
|
|||
"com_ui_unsaved_changes": "Sie haben ungespeicherte Änderungen",
|
||||
"com_ui_share_with_everyone": "Mit allen teilen",
|
||||
"com_ui_make_agent_available_all_users": "Diesen Agenten für alle LibreChat-Benutzer verfügbar machen",
|
||||
"com_ui_public_access_level": "Öffentliche Zugriffsebene"
|
||||
"com_ui_public_access_level": "Öffentliche Zugriffsebene",
|
||||
"com_ui_at_least_one_owner_required": "Mindestens ein Besitzer ist erforderlich"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1095,5 +1095,6 @@
|
|||
"com_ui_unsaved_changes": "You have unsaved changes",
|
||||
"com_ui_share_with_everyone": "Share with everyone",
|
||||
"com_ui_make_agent_available_all_users": "Make this agent available to all LibreChat users",
|
||||
"com_ui_public_access_level": "Public access level"
|
||||
}
|
||||
"com_ui_public_access_level": "Public access level",
|
||||
"com_ui_at_least_one_owner_required": "At least one owner is required"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue