mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-22 02:06:12 +01:00
refactor: Replace marketplace interface config with permission-based system
- Add MARKETPLACE permission type to handle marketplace access control - Update interface configuration to use role-based marketplace settings (admin/user) - Replace direct marketplace boolean config with permission-based checks - Modify frontend components to use marketplace permissions instead of interface config - Update agent query hooks to use marketplace permissions for determining permission levels - Add marketplace configuration structure similar to peoplePicker in YAML config - Backend now sets MARKETPLACE permissions based on interface configuration - When marketplace enabled: users get agents with EDIT permissions in dropdown lists (builder mode) - When marketplace disabled: users get agents with VIEW permissions in dropdown lists (browse mode)
This commit is contained in:
parent
73fb4181fe
commit
bbafa8e306
12 changed files with 128 additions and 15 deletions
|
|
@ -529,6 +529,20 @@ export const interfaceSchema = z
|
|||
.optional(),
|
||||
})
|
||||
.optional(),
|
||||
marketplace: z
|
||||
.object({
|
||||
admin: z
|
||||
.object({
|
||||
use: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
user: z
|
||||
.object({
|
||||
use: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
.default({
|
||||
endpointsMenu: true,
|
||||
|
|
@ -554,6 +568,14 @@ export const interfaceSchema = z
|
|||
groups: false,
|
||||
},
|
||||
},
|
||||
marketplace: {
|
||||
admin: {
|
||||
use: false,
|
||||
},
|
||||
user: {
|
||||
use: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type TInterfaceConfig = z.infer<typeof interfaceSchema>;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ export enum PermissionTypes {
|
|||
* Type for People Picker Permissions
|
||||
*/
|
||||
PEOPLE_PICKER = 'PEOPLE_PICKER',
|
||||
/**
|
||||
* Type for Marketplace Permissions
|
||||
*/
|
||||
MARKETPLACE = 'MARKETPLACE',
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -115,6 +119,11 @@ export const peoplePickerPermissionsSchema = z.object({
|
|||
});
|
||||
export type TPeoplePickerPermissions = z.infer<typeof peoplePickerPermissionsSchema>;
|
||||
|
||||
export const marketplacePermissionsSchema = z.object({
|
||||
[Permissions.USE]: z.boolean().default(false),
|
||||
});
|
||||
export type TMarketplacePermissions = z.infer<typeof marketplacePermissionsSchema>;
|
||||
|
||||
// Define a single permissions schema that holds all permission types.
|
||||
export const permissionsSchema = z.object({
|
||||
[PermissionTypes.PROMPTS]: promptPermissionsSchema,
|
||||
|
|
@ -126,4 +135,5 @@ export const permissionsSchema = z.object({
|
|||
[PermissionTypes.RUN_CODE]: runCodePermissionsSchema,
|
||||
[PermissionTypes.WEB_SEARCH]: webSearchPermissionsSchema,
|
||||
[PermissionTypes.PEOPLE_PICKER]: peoplePickerPermissionsSchema,
|
||||
[PermissionTypes.MARKETPLACE]: marketplacePermissionsSchema,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -79,6 +79,9 @@ const defaultRolesSchema = z.object({
|
|||
[Permissions.VIEW_USERS]: z.boolean().default(true),
|
||||
[Permissions.VIEW_GROUPS]: z.boolean().default(true),
|
||||
}),
|
||||
[PermissionTypes.MARKETPLACE]: z.object({
|
||||
[Permissions.USE]: z.boolean().default(false),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
[SystemRoles.USER]: roleSchema.extend({
|
||||
|
|
@ -127,6 +130,9 @@ export const roleDefaults = defaultRolesSchema.parse({
|
|||
[Permissions.VIEW_USERS]: true,
|
||||
[Permissions.VIEW_GROUPS]: true,
|
||||
},
|
||||
[PermissionTypes.MARKETPLACE]: {
|
||||
[Permissions.USE]: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
[SystemRoles.USER]: {
|
||||
|
|
@ -144,6 +150,9 @@ export const roleDefaults = defaultRolesSchema.parse({
|
|||
[Permissions.VIEW_USERS]: false,
|
||||
[Permissions.VIEW_GROUPS]: false,
|
||||
},
|
||||
[PermissionTypes.MARKETPLACE]: {
|
||||
[Permissions.USE]: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue