mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-09-11 14:36:35 +03:00
test
This commit is contained in:
parent
d273426c01
commit
75f5d7530f
@ -1,6 +1,6 @@
|
||||
/* eslint-disable max-lines */
|
||||
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import Spinner from "@/lib/components/ui/Spinner";
|
||||
import { Tabs } from "@/lib/components/ui/Tabs/Tabs";
|
||||
@ -20,6 +20,14 @@ export const BrainManagementTabs = (): JSX.Element => {
|
||||
brainId,
|
||||
});
|
||||
|
||||
const knowledgeTabDisabled = (): boolean => {
|
||||
return (
|
||||
!hasEditRights ||
|
||||
(brain?.integration_description?.max_files === 0 &&
|
||||
brain.brain_type !== "doc")
|
||||
);
|
||||
};
|
||||
|
||||
const brainManagementTabs: Tab[] = [
|
||||
{
|
||||
label: "Settings",
|
||||
@ -39,13 +47,14 @@ export const BrainManagementTabs = (): JSX.Element => {
|
||||
isSelected: selectedTab === "Knowledge",
|
||||
onClick: () => setSelectedTab("Knowledge"),
|
||||
iconName: "file",
|
||||
disabled:
|
||||
!hasEditRights ||
|
||||
(!brain?.integration_description?.max_files &&
|
||||
brain?.brain_type !== "doc"),
|
||||
disabled: knowledgeTabDisabled(),
|
||||
},
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
brainManagementTabs[2].disabled = knowledgeTabDisabled();
|
||||
}, [hasEditRights]);
|
||||
|
||||
if (!brainId) {
|
||||
return <div />;
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ export const usePermissionsController = ({
|
||||
isUpdatingApiDefinition: boolean;
|
||||
}>();
|
||||
|
||||
const { hasEditRights, isOwnedByCurrentUser, isPublicBrain } =
|
||||
getBrainPermissions({
|
||||
brainId,
|
||||
userAccessibleBrains: allBrains,
|
||||
});
|
||||
const { hasEditRights, isOwnedByCurrentUser } = getBrainPermissions({
|
||||
brainId,
|
||||
userAccessibleBrains: allBrains,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setValue("isApiDefinitionReadOnly", !hasEditRights);
|
||||
@ -35,6 +34,5 @@ export const usePermissionsController = ({
|
||||
return {
|
||||
hasEditRights,
|
||||
isOwnedByCurrentUser,
|
||||
isPublicBrain,
|
||||
};
|
||||
};
|
||||
|
@ -34,11 +34,10 @@ export const useBrainManagementTabs = (customBrainId?: UUID) => {
|
||||
const { t } = useTranslation(["delete_or_unsubscribe_from_brain"]);
|
||||
const brainId = customBrainId ?? (params?.brainId as UUID | undefined);
|
||||
|
||||
const { hasEditRights, isOwnedByCurrentUser, isPublicBrain } =
|
||||
getBrainPermissions({
|
||||
brainId,
|
||||
userAccessibleBrains: allBrains,
|
||||
});
|
||||
const { hasEditRights, isOwnedByCurrentUser } = getBrainPermissions({
|
||||
brainId,
|
||||
userAccessibleBrains: allBrains,
|
||||
});
|
||||
|
||||
const handleUnSubscription = async () => {
|
||||
if (brainId === undefined) {
|
||||
@ -87,6 +86,5 @@ export const useBrainManagementTabs = (customBrainId?: UUID) => {
|
||||
hasEditRights,
|
||||
isOwnedByCurrentUser,
|
||||
isDeleteOrUnsubscribeRequestPending,
|
||||
isPublicBrain,
|
||||
};
|
||||
};
|
||||
|
@ -14,7 +14,6 @@ export const getBrainPermissions = ({
|
||||
brainId,
|
||||
userAccessibleBrains,
|
||||
}: GetBrainPermissionsProps): {
|
||||
isPublicBrain: boolean;
|
||||
hasEditRights: boolean;
|
||||
isOwnedByCurrentUser: boolean;
|
||||
} => {
|
||||
@ -28,11 +27,10 @@ export const getBrainPermissions = ({
|
||||
userAccessibleBrains,
|
||||
});
|
||||
|
||||
const isPublicBrain =
|
||||
userAccessibleBrains.find((brain) => brain.id === brainId)?.status ===
|
||||
"public";
|
||||
|
||||
const hasEditRights = isOwnedByCurrentUser || userHasBrainEditorRights;
|
||||
|
||||
return { isPublicBrain, hasEditRights, isOwnedByCurrentUser };
|
||||
return {
|
||||
hasEditRights,
|
||||
isOwnedByCurrentUser,
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user