Bugfix/curator interface (#3198)

* mystery solved

* update config

* update

* update

* update user role

* remove values
This commit is contained in:
pablodanswer 2024-11-21 18:33:09 -08:00 committed by GitHub
parent fe1400aa36
commit 682319d2e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 19 additions and 12 deletions

0
backend/DELETE Normal file
View File

View File

@ -259,7 +259,6 @@ def get_personas(
) -> Sequence[Persona]:
stmt = select(Persona).distinct()
stmt = _add_user_filters(stmt=stmt, user=user, get_editable=get_editable)
if not include_default:
stmt = stmt.where(Persona.builtin_persona.is_(False))
if not include_slack_bot_personas:

View File

@ -30,7 +30,6 @@ from danswer.utils.threadpool_concurrency import run_functions_tuples_in_paralle
logger = setup_logger()
admin_router = APIRouter(prefix="/admin/llm")
basic_router = APIRouter(prefix="/llm")

View File

@ -57,7 +57,7 @@ const DropdownOption: React.FC<DropdownOptionProps> = ({
};
export function UserDropdown({ page }: { page?: pageType }) {
const { user } = useUser();
const { user, isCurator } = useUser();
const [userInfoVisible, setUserInfoVisible] = useState(false);
const userInfoRef = useRef<HTMLDivElement>(null);
const router = useRouter();
@ -95,7 +95,9 @@ export function UserDropdown({ page }: { page?: pageType }) {
}
// 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
const encodedRedirect = encodeURIComponent(currentUrl);
@ -106,9 +108,7 @@ export function UserDropdown({ page }: { page?: pageType }) {
};
const showAdminPanel = !user || user.role === UserRole.ADMIN;
const showCuratorPanel =
user &&
(user.role === UserRole.CURATOR || user.role === UserRole.GLOBAL_CURATOR);
const showCuratorPanel = user && isCurator;
const showLogout =
user && !checkUserIsNoAuthUser(user.id) && !LOGOUT_DISABLED;
@ -244,7 +244,11 @@ export function UserDropdown({ page }: { page?: pageType }) {
setShowNotifications(true);
}}
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 &&

View File

@ -47,7 +47,7 @@ export const AssistantsProvider: React.FC<{
const [assistants, setAssistants] = useState<Persona[]>(
initialAssistants || []
);
const { user, isLoadingUser, isAdmin } = useUser();
const { user, isLoadingUser, isAdmin, isCurator } = useUser();
const [editablePersonas, setEditablePersonas] = useState<Persona[]>([]);
const [allAssistants, setAllAssistants] = useState<Persona[]>([]);
@ -83,7 +83,7 @@ export const AssistantsProvider: React.FC<{
useEffect(() => {
const fetchPersonas = async () => {
if (!isAdmin) {
if (!isAdmin && !isCurator) {
return;
}
@ -101,6 +101,8 @@ export const AssistantsProvider: React.FC<{
if (allResponse.ok) {
const allPersonas = await allResponse.json();
setAllAssistants(allPersonas);
} else {
console.error("Error fetching personas:", allResponse);
}
} catch (error) {
console.error("Error fetching personas:", error);
@ -108,7 +110,7 @@ export const AssistantsProvider: React.FC<{
};
fetchPersonas();
}, [isAdmin]);
}, [isAdmin, isCurator]);
const refreshRecentAssistants = async (currentAssistant: number) => {
const response = await fetch("/api/user/recent-assistants", {

View File

@ -67,7 +67,10 @@ export function UserProvider({
isLoadingUser,
refreshUser,
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,
}}
>