mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-27 08:21:00 +02:00
Added frontend logical polish (#2274)
This commit is contained in:
parent
762b7b1047
commit
355326f935
@ -125,9 +125,7 @@ export const DocumentSetCreationForm = ({
|
|||||||
placeholder="Describe what the document set represents"
|
placeholder="Describe what the document set represents"
|
||||||
autoCompleteDisabled={true}
|
autoCompleteDisabled={true}
|
||||||
/>
|
/>
|
||||||
{isPaidEnterpriseFeaturesEnabled &&
|
{isPaidEnterpriseFeaturesEnabled && (
|
||||||
userGroups &&
|
|
||||||
userGroups.length > 0 && (
|
|
||||||
<IsPublicGroupSelector
|
<IsPublicGroupSelector
|
||||||
formikProps={props}
|
formikProps={props}
|
||||||
objectName="document set"
|
objectName="document set"
|
||||||
|
@ -15,10 +15,12 @@ export type IsPublicGroupSelectorFormType = {
|
|||||||
export const IsPublicGroupSelector = <T extends IsPublicGroupSelectorFormType>({
|
export const IsPublicGroupSelector = <T extends IsPublicGroupSelectorFormType>({
|
||||||
formikProps,
|
formikProps,
|
||||||
objectName,
|
objectName,
|
||||||
|
publicToWhom = "Users",
|
||||||
enforceGroupSelection = true,
|
enforceGroupSelection = true,
|
||||||
}: {
|
}: {
|
||||||
formikProps: FormikProps<T>;
|
formikProps: FormikProps<T>;
|
||||||
objectName: string;
|
objectName: string;
|
||||||
|
publicToWhom?: string;
|
||||||
enforceGroupSelection?: boolean;
|
enforceGroupSelection?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const { data: userGroups, isLoading: userGroupsIsLoading } = useUserGroups();
|
const { data: userGroups, isLoading: userGroupsIsLoading } = useUserGroups();
|
||||||
@ -72,34 +74,35 @@ export const IsPublicGroupSelector = <T extends IsPublicGroupSelectorFormType>({
|
|||||||
<>
|
<>
|
||||||
<BooleanFormField
|
<BooleanFormField
|
||||||
name="is_public"
|
name="is_public"
|
||||||
label="Is Public?"
|
label={
|
||||||
|
publicToWhom === "Curators"
|
||||||
|
? `Make this ${objectName} Curator Accessible?`
|
||||||
|
: `Make this ${objectName} Public?`
|
||||||
|
}
|
||||||
disabled={!isAdmin}
|
disabled={!isAdmin}
|
||||||
subtext={
|
subtext={
|
||||||
<span className="block mt-2 text-sm text-gray-500">
|
<span className="block mt-2 text-sm text-gray-500">
|
||||||
If set, then this {objectName} will be visible to{" "}
|
If set, then this {objectName} will be usable by{" "}
|
||||||
<b>all users</b>. If turned off, then only users who explicitly
|
<b>All {publicToWhom}</b>. Otherwise, only <b>Admins</b> and{" "}
|
||||||
have been given access to this {objectName} (e.g. through a User
|
<b>{publicToWhom}</b> who have explicitly been given access to
|
||||||
Group) will have access.
|
this {objectName} (e.g. via a User Group) will have access.
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(!formikProps.values.is_public ||
|
{(!formikProps.values.is_public || isCurator) &&
|
||||||
isCurator ||
|
formikProps.values.groups.length > 0 && (
|
||||||
formikProps.values.groups.length > 0) &&
|
|
||||||
(userGroupsIsLoading ? (
|
|
||||||
<div className="animate-pulse bg-gray-200 h-8 w-32 rounded"></div>
|
|
||||||
) : (
|
|
||||||
userGroups &&
|
|
||||||
userGroups.length > 0 && (
|
|
||||||
<>
|
<>
|
||||||
<div className="flex mt-4 gap-x-2 items-center">
|
<div className="flex mt-4 gap-x-2 items-center">
|
||||||
<div className="block font-medium text-base">
|
<div className="block font-medium text-base">
|
||||||
Assign group access for this {objectName}
|
Assign group access for this {objectName}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{userGroupsIsLoading ? (
|
||||||
|
<div className="animate-pulse bg-gray-200 h-8 w-32 rounded"></div>
|
||||||
|
) : (
|
||||||
<Text className="mb-3">
|
<Text className="mb-3">
|
||||||
{isAdmin || !enforceGroupSelection ? (
|
{isAdmin || !enforceGroupSelection ? (
|
||||||
<>
|
<>
|
||||||
@ -113,11 +116,16 @@ export const IsPublicGroupSelector = <T extends IsPublicGroupSelectorFormType>({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Text>
|
</Text>
|
||||||
|
)}
|
||||||
<FieldArray
|
<FieldArray
|
||||||
name="groups"
|
name="groups"
|
||||||
render={(arrayHelpers: ArrayHelpers) => (
|
render={(arrayHelpers: ArrayHelpers) => (
|
||||||
<div className="flex gap-2 flex-wrap mb-4">
|
<div className="flex gap-2 flex-wrap mb-4">
|
||||||
{userGroups.map((userGroup: UserGroup) => {
|
{userGroupsIsLoading ? (
|
||||||
|
<div className="animate-pulse bg-gray-200 h-8 w-32 rounded"></div>
|
||||||
|
) : (
|
||||||
|
userGroups &&
|
||||||
|
userGroups.map((userGroup: UserGroup) => {
|
||||||
const ind = formikProps.values.groups.indexOf(
|
const ind = formikProps.values.groups.indexOf(
|
||||||
userGroup.id
|
userGroup.id
|
||||||
);
|
);
|
||||||
@ -150,7 +158,8 @@ export const IsPublicGroupSelector = <T extends IsPublicGroupSelectorFormType>({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@ -160,8 +169,7 @@ export const IsPublicGroupSelector = <T extends IsPublicGroupSelectorFormType>({
|
|||||||
className="text-error text-sm mt-1"
|
className="text-error text-sm mt-1"
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)}
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -16,6 +16,33 @@ import {
|
|||||||
} from "./icons/icons";
|
} from "./icons/icons";
|
||||||
import { pageType } from "@/app/chat/sessionSidebar/types";
|
import { pageType } from "@/app/chat/sessionSidebar/types";
|
||||||
|
|
||||||
|
interface DropdownOptionProps {
|
||||||
|
href?: string;
|
||||||
|
onClick?: () => void;
|
||||||
|
icon: React.ReactNode;
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DropdownOption: React.FC<DropdownOptionProps> = ({
|
||||||
|
href,
|
||||||
|
onClick,
|
||||||
|
icon,
|
||||||
|
label,
|
||||||
|
}) => {
|
||||||
|
const content = (
|
||||||
|
<div className="flex py-3 px-4 cursor-pointer rounded hover:bg-hover-light">
|
||||||
|
{icon}
|
||||||
|
{label}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return href ? (
|
||||||
|
<Link href={href}>{content}</Link>
|
||||||
|
) : (
|
||||||
|
<div onClick={onClick}>{content}</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export function UserDropdown({
|
export function UserDropdown({
|
||||||
user,
|
user,
|
||||||
page,
|
page,
|
||||||
@ -100,44 +127,31 @@ export function UserDropdown({
|
|||||||
overscroll-contain
|
overscroll-contain
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
{showAdminPanel && (
|
{showAdminPanel ? (
|
||||||
<>
|
<DropdownOption
|
||||||
<Link
|
|
||||||
href="/admin/indexing/status"
|
href="/admin/indexing/status"
|
||||||
className="flex py-3 px-4 cursor-pointer !
|
icon={<LightSettingsIcon className="h-5 w-5 my-auto mr-2" />}
|
||||||
rounded hover:bg-hover-light"
|
label="Admin Panel"
|
||||||
>
|
/>
|
||||||
<LightSettingsIcon className="h-5 w-5 my-auto mr-2" />
|
) : (
|
||||||
Admin Panel
|
showCuratorPanel && (
|
||||||
</Link>
|
<DropdownOption
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{showCuratorPanel && (
|
|
||||||
<>
|
|
||||||
<Link
|
|
||||||
href="/admin/indexing/status"
|
href="/admin/indexing/status"
|
||||||
className="flex py-3 px-4 cursor-pointer !
|
icon={<LightSettingsIcon className="h-5 w-5 my-auto mr-2" />}
|
||||||
rounded hover:bg-hover-light"
|
label="Curator Panel"
|
||||||
>
|
/>
|
||||||
<LightSettingsIcon className="h-5 w-5 my-auto mr-2" />
|
)
|
||||||
Curator Panel
|
|
||||||
</Link>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{showLogout && (
|
{(showAdminPanel || showCuratorPanel) && (
|
||||||
<>
|
|
||||||
{(!(page == "search" || page == "chat") || showAdminPanel) && (
|
|
||||||
<div className="border-t border-border my-1" />
|
<div className="border-t border-border my-1" />
|
||||||
)}
|
)}
|
||||||
<div
|
{showLogout && (
|
||||||
|
<DropdownOption
|
||||||
onClick={handleLogout}
|
onClick={handleLogout}
|
||||||
className="mt-1 flex py-3 px-4 cursor-pointer hover:bg-hover-light"
|
icon={<FiLogOut className="my-auto mr-2 text-lg" />}
|
||||||
>
|
label="Log out"
|
||||||
<FiLogOut className="my-auto mr-2 text-lg" />
|
/>
|
||||||
Log out
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@ -236,6 +236,7 @@ export default function CreateCredential({
|
|||||||
<IsPublicGroupSelector
|
<IsPublicGroupSelector
|
||||||
formikProps={formikProps}
|
formikProps={formikProps}
|
||||||
objectName="credential"
|
objectName="credential"
|
||||||
|
publicToWhom="Curators"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user