mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 12:55:19 +00:00
Merge pull request #16503 from athoik/user_groups_nav
feat: Allow navigating to user group from user edit
This commit is contained in:
commit
86a3e0a0b8
4 changed files with 25 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { getContext } from 'svelte';
|
import { onMount, getContext } from 'svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
import User from '$lib/components/icons/User.svelte';
|
import User from '$lib/components/icons/User.svelte';
|
||||||
import UserCircleSolid from '$lib/components/icons/UserCircleSolid.svelte';
|
import UserCircleSolid from '$lib/components/icons/UserCircleSolid.svelte';
|
||||||
import GroupModal from './EditGroupModal.svelte';
|
import GroupModal from './EditGroupModal.svelte';
|
||||||
|
import { querystringValue } from '$lib/utils';
|
||||||
|
|
||||||
export let users = [];
|
export let users = [];
|
||||||
export let group = {
|
export let group = {
|
||||||
|
|
@ -44,6 +45,13 @@
|
||||||
setGroups();
|
setGroups();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const groupId = querystringValue('id');
|
||||||
|
if (groupId && groupId === group.id) {
|
||||||
|
showEdit = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<GroupModal
|
<GroupModal
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
import { onMount, getContext } from 'svelte';
|
import { onMount, getContext } from 'svelte';
|
||||||
|
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
import { updateUserById, getUserGroupsById } from '$lib/apis/users';
|
import { updateUserById, getUserGroupsById } from '$lib/apis/users';
|
||||||
|
|
||||||
import Modal from '$lib/components/common/Modal.svelte';
|
import Modal from '$lib/components/common/Modal.svelte';
|
||||||
|
|
@ -127,7 +129,13 @@
|
||||||
<div class="flex flex-wrap gap-1 my-0.5 -mx-1">
|
<div class="flex flex-wrap gap-1 my-0.5 -mx-1">
|
||||||
{#each userGroups as userGroup}
|
{#each userGroups as userGroup}
|
||||||
<span class="px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-850 text-xs">
|
<span class="px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-850 text-xs">
|
||||||
{userGroup.name}
|
<a
|
||||||
|
href={'/admin/users/groups?id=' + userGroup.id}
|
||||||
|
on:click|preventDefault={() =>
|
||||||
|
goto('/admin/users/groups?id=' + userGroup.id)}
|
||||||
|
>
|
||||||
|
{userGroup.name}
|
||||||
|
</a>
|
||||||
</span>
|
</span>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1583,3 +1583,9 @@ export const extractContentFromFile = async (file, pdfjsLib = null) => {
|
||||||
throw new Error('Unsupported or non-text file type: ' + (file.name || type));
|
throw new Error('Unsupported or non-text file type: ' + (file.name || type));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const querystringValue = (key: string): string | null => {
|
||||||
|
const querystring = window.location.search;
|
||||||
|
const urlParams = new URLSearchParams(querystring);
|
||||||
|
return urlParams.get(key);
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
|
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
|
||||||
import { WEBUI_NAME, config, user, socket } from '$lib/stores';
|
import { WEBUI_NAME, config, user, socket } from '$lib/stores';
|
||||||
|
|
||||||
import { generateInitialsImage, canvasPixelTest } from '$lib/utils';
|
import { generateInitialsImage, canvasPixelTest, querystringValue } from '$lib/utils';
|
||||||
|
|
||||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||||
import OnBoarding from '$lib/components/OnBoarding.svelte';
|
import OnBoarding from '$lib/components/OnBoarding.svelte';
|
||||||
|
|
@ -33,12 +33,6 @@
|
||||||
|
|
||||||
let ldapUsername = '';
|
let ldapUsername = '';
|
||||||
|
|
||||||
const querystringValue = (key) => {
|
|
||||||
const querystring = window.location.search;
|
|
||||||
const urlParams = new URLSearchParams(querystring);
|
|
||||||
return urlParams.get(key);
|
|
||||||
};
|
|
||||||
|
|
||||||
const setSessionUser = async (sessionUser) => {
|
const setSessionUser = async (sessionUser) => {
|
||||||
if (sessionUser) {
|
if (sessionUser) {
|
||||||
console.log(sessionUser);
|
console.log(sessionUser);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue