mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-29 17:19:36 +02:00
Bugfix/curator interface (#3198)
* mystery solved * update config * update * update * update user role * remove values
This commit is contained in:
parent
fe1400aa36
commit
682319d2e9
0
backend/DELETE
Normal file
0
backend/DELETE
Normal file
@ -259,7 +259,6 @@ def get_personas(
|
|||||||
) -> Sequence[Persona]:
|
) -> Sequence[Persona]:
|
||||||
stmt = select(Persona).distinct()
|
stmt = select(Persona).distinct()
|
||||||
stmt = _add_user_filters(stmt=stmt, user=user, get_editable=get_editable)
|
stmt = _add_user_filters(stmt=stmt, user=user, get_editable=get_editable)
|
||||||
|
|
||||||
if not include_default:
|
if not include_default:
|
||||||
stmt = stmt.where(Persona.builtin_persona.is_(False))
|
stmt = stmt.where(Persona.builtin_persona.is_(False))
|
||||||
if not include_slack_bot_personas:
|
if not include_slack_bot_personas:
|
||||||
|
@ -30,7 +30,6 @@ from danswer.utils.threadpool_concurrency import run_functions_tuples_in_paralle
|
|||||||
|
|
||||||
logger = setup_logger()
|
logger = setup_logger()
|
||||||
|
|
||||||
|
|
||||||
admin_router = APIRouter(prefix="/admin/llm")
|
admin_router = APIRouter(prefix="/admin/llm")
|
||||||
basic_router = APIRouter(prefix="/llm")
|
basic_router = APIRouter(prefix="/llm")
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ const DropdownOption: React.FC<DropdownOptionProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function UserDropdown({ page }: { page?: pageType }) {
|
export function UserDropdown({ page }: { page?: pageType }) {
|
||||||
const { user } = useUser();
|
const { user, isCurator } = useUser();
|
||||||
const [userInfoVisible, setUserInfoVisible] = useState(false);
|
const [userInfoVisible, setUserInfoVisible] = useState(false);
|
||||||
const userInfoRef = useRef<HTMLDivElement>(null);
|
const userInfoRef = useRef<HTMLDivElement>(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -95,7 +95,9 @@ export function UserDropdown({ page }: { page?: pageType }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct the current URL
|
// Construct the current URL
|
||||||
const currentUrl = `${pathname}${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
const currentUrl = `${pathname}${
|
||||||
|
searchParams.toString() ? `?${searchParams.toString()}` : ""
|
||||||
|
}`;
|
||||||
|
|
||||||
// Encode the current URL to use as a redirect parameter
|
// Encode the current URL to use as a redirect parameter
|
||||||
const encodedRedirect = encodeURIComponent(currentUrl);
|
const encodedRedirect = encodeURIComponent(currentUrl);
|
||||||
@ -106,9 +108,7 @@ export function UserDropdown({ page }: { page?: pageType }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const showAdminPanel = !user || user.role === UserRole.ADMIN;
|
const showAdminPanel = !user || user.role === UserRole.ADMIN;
|
||||||
const showCuratorPanel =
|
const showCuratorPanel = user && isCurator;
|
||||||
user &&
|
|
||||||
(user.role === UserRole.CURATOR || user.role === UserRole.GLOBAL_CURATOR);
|
|
||||||
const showLogout =
|
const showLogout =
|
||||||
user && !checkUserIsNoAuthUser(user.id) && !LOGOUT_DISABLED;
|
user && !checkUserIsNoAuthUser(user.id) && !LOGOUT_DISABLED;
|
||||||
|
|
||||||
@ -244,7 +244,11 @@ export function UserDropdown({ page }: { page?: pageType }) {
|
|||||||
setShowNotifications(true);
|
setShowNotifications(true);
|
||||||
}}
|
}}
|
||||||
icon={<BellIcon className="h-5 w-5 my-auto mr-2" />}
|
icon={<BellIcon className="h-5 w-5 my-auto mr-2" />}
|
||||||
label={`Notifications ${notifications && notifications.length > 0 ? `(${notifications.length})` : ""}`}
|
label={`Notifications ${
|
||||||
|
notifications && notifications.length > 0
|
||||||
|
? `(${notifications.length})`
|
||||||
|
: ""
|
||||||
|
}`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{showLogout &&
|
{showLogout &&
|
||||||
|
@ -47,7 +47,7 @@ export const AssistantsProvider: React.FC<{
|
|||||||
const [assistants, setAssistants] = useState<Persona[]>(
|
const [assistants, setAssistants] = useState<Persona[]>(
|
||||||
initialAssistants || []
|
initialAssistants || []
|
||||||
);
|
);
|
||||||
const { user, isLoadingUser, isAdmin } = useUser();
|
const { user, isLoadingUser, isAdmin, isCurator } = useUser();
|
||||||
const [editablePersonas, setEditablePersonas] = useState<Persona[]>([]);
|
const [editablePersonas, setEditablePersonas] = useState<Persona[]>([]);
|
||||||
const [allAssistants, setAllAssistants] = useState<Persona[]>([]);
|
const [allAssistants, setAllAssistants] = useState<Persona[]>([]);
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ export const AssistantsProvider: React.FC<{
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchPersonas = async () => {
|
const fetchPersonas = async () => {
|
||||||
if (!isAdmin) {
|
if (!isAdmin && !isCurator) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +101,8 @@ export const AssistantsProvider: React.FC<{
|
|||||||
if (allResponse.ok) {
|
if (allResponse.ok) {
|
||||||
const allPersonas = await allResponse.json();
|
const allPersonas = await allResponse.json();
|
||||||
setAllAssistants(allPersonas);
|
setAllAssistants(allPersonas);
|
||||||
|
} else {
|
||||||
|
console.error("Error fetching personas:", allResponse);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching personas:", error);
|
console.error("Error fetching personas:", error);
|
||||||
@ -108,7 +110,7 @@ export const AssistantsProvider: React.FC<{
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchPersonas();
|
fetchPersonas();
|
||||||
}, [isAdmin]);
|
}, [isAdmin, isCurator]);
|
||||||
|
|
||||||
const refreshRecentAssistants = async (currentAssistant: number) => {
|
const refreshRecentAssistants = async (currentAssistant: number) => {
|
||||||
const response = await fetch("/api/user/recent-assistants", {
|
const response = await fetch("/api/user/recent-assistants", {
|
||||||
|
@ -67,7 +67,10 @@ export function UserProvider({
|
|||||||
isLoadingUser,
|
isLoadingUser,
|
||||||
refreshUser,
|
refreshUser,
|
||||||
isAdmin: upToDateUser?.role === UserRole.ADMIN,
|
isAdmin: upToDateUser?.role === UserRole.ADMIN,
|
||||||
isCurator: upToDateUser?.role === UserRole.CURATOR,
|
// Curator status applies for either global or basic curator
|
||||||
|
isCurator:
|
||||||
|
upToDateUser?.role === UserRole.CURATOR ||
|
||||||
|
upToDateUser?.role === UserRole.GLOBAL_CURATOR,
|
||||||
isCloudSuperuser: upToDateUser?.is_cloud_superuser ?? false,
|
isCloudSuperuser: upToDateUser?.is_cloud_superuser ?? false,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user