mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
feat: public sharing permissions
Co-Authored-By: Taylor Wilsdon <6508528+taylorwilsdon@users.noreply.github.com>
This commit is contained in:
@@ -15,14 +15,44 @@
|
||||
export let accessRoles = ['read'];
|
||||
export let accessControl = null;
|
||||
|
||||
export let allowPublic = true;
|
||||
|
||||
let selectedGroupId = '';
|
||||
let groups = [];
|
||||
|
||||
$: if (!allowPublic && accessControl === null) {
|
||||
accessControl = {
|
||||
read: {
|
||||
group_ids: [],
|
||||
user_ids: []
|
||||
},
|
||||
write: {
|
||||
group_ids: [],
|
||||
user_ids: []
|
||||
}
|
||||
};
|
||||
onChange(accessControl);
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
groups = await getGroups(localStorage.token);
|
||||
|
||||
if (accessControl === null) {
|
||||
accessControl = null;
|
||||
if (allowPublic) {
|
||||
accessControl = null;
|
||||
} else {
|
||||
accessControl = {
|
||||
read: {
|
||||
group_ids: [],
|
||||
user_ids: []
|
||||
},
|
||||
write: {
|
||||
group_ids: [],
|
||||
user_ids: []
|
||||
}
|
||||
};
|
||||
onChange(accessControl);
|
||||
}
|
||||
} else {
|
||||
accessControl = {
|
||||
read: {
|
||||
@@ -104,17 +134,21 @@
|
||||
} else {
|
||||
accessControl = {
|
||||
read: {
|
||||
group_ids: []
|
||||
group_ids: [],
|
||||
user_ids: []
|
||||
},
|
||||
write: {
|
||||
group_ids: []
|
||||
group_ids: [],
|
||||
user_ids: []
|
||||
}
|
||||
};
|
||||
}
|
||||
}}
|
||||
>
|
||||
<option class=" text-gray-700" value="private" selected>{$i18n.t('Private')}</option>
|
||||
<option class=" text-gray-700" value="public" selected>{$i18n.t('Public')}</option>
|
||||
{#if allowPublic}
|
||||
<option class=" text-gray-700" value="public" selected>{$i18n.t('Public')}</option>
|
||||
{/if}
|
||||
</select>
|
||||
|
||||
<div class=" text-xs text-gray-400 font-medium">
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
export let show = false;
|
||||
export let accessControl = null;
|
||||
export let accessRoles = ['read'];
|
||||
export let allowPublic = true;
|
||||
|
||||
export let onChange = () => {};
|
||||
</script>
|
||||
@@ -38,7 +39,7 @@
|
||||
</div>
|
||||
|
||||
<div class="w-full px-5 pb-4 dark:text-white">
|
||||
<AccessControl bind:accessControl {onChange} {accessRoles} />
|
||||
<AccessControl bind:accessControl {onChange} {accessRoles} {allowPublic} />
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user