Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/curator interface #3198

Merged
merged 6 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added backend/DELETE
Empty file.
1 change: 0 additions & 1 deletion backend/danswer/db/persona.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion backend/danswer/server/manage/llm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

logger = setup_logger()


admin_router = APIRouter(prefix="/admin/llm")
basic_router = APIRouter(prefix="/llm")

Expand Down
16 changes: 10 additions & 6 deletions web/src/components/UserDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand Down Expand Up @@ -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 &&
Expand Down
8 changes: 5 additions & 3 deletions web/src/components/context/AssistantsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[]>([]);

Expand Down Expand Up @@ -83,7 +83,7 @@ export const AssistantsProvider: React.FC<{

useEffect(() => {
const fetchPersonas = async () => {
if (!isAdmin) {
if (!isAdmin && !isCurator) {
return;
}

Expand All @@ -101,14 +101,16 @@ 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);
}
};

fetchPersonas();
}, [isAdmin]);
}, [isAdmin, isCurator]);

const refreshRecentAssistants = async (currentAssistant: number) => {
const response = await fetch("/api/user/recent-assistants", {
Expand Down
5 changes: 4 additions & 1 deletion web/src/components/user/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}}
>
Expand Down
Loading