mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-09-11 14:36:35 +03:00
Merge branch 'main' into fix/messageIcon
This commit is contained in:
commit
555fbc235a
@ -59,7 +59,7 @@ class NotionConnector(IntegrationBrain, Integration):
|
|||||||
def _load_credentials(self) -> dict[str, str]:
|
def _load_credentials(self) -> dict[str, str]:
|
||||||
"""Load the Notion credentials"""
|
"""Load the Notion credentials"""
|
||||||
self.integration_details = self.get_integration_brain(
|
self.integration_details = self.get_integration_brain(
|
||||||
self.brain_id, self.user_id
|
self.brain_id
|
||||||
)
|
)
|
||||||
if self.credentials is None:
|
if self.credentials is None:
|
||||||
logger.info("Loading Notion credentials")
|
logger.info("Loading Notion credentials")
|
||||||
@ -343,7 +343,7 @@ class NotionConnector(IntegrationBrain, Integration):
|
|||||||
"""
|
"""
|
||||||
Update all the brains with the latest data from Notion
|
Update all the brains with the latest data from Notion
|
||||||
"""
|
"""
|
||||||
integration = self.get_integration_brain(self.brain_id, self.user_id)
|
integration = self.get_integration_brain(self.brain_id)
|
||||||
last_synced = integration.last_synced
|
last_synced = integration.last_synced
|
||||||
|
|
||||||
query_dict = {
|
query_dict = {
|
||||||
|
@ -26,7 +26,7 @@ class SQLConnector(IntegrationBrain):
|
|||||||
def _load_credentials(self) -> dict[str, str]:
|
def _load_credentials(self) -> dict[str, str]:
|
||||||
"""Load the Notion credentials"""
|
"""Load the Notion credentials"""
|
||||||
self.integration_details = self.get_integration_brain(
|
self.integration_details = self.get_integration_brain(
|
||||||
self.brain_id, self.user_id
|
self.brain_id
|
||||||
)
|
)
|
||||||
if self.credentials is None:
|
if self.credentials is None:
|
||||||
logger.info("Loading Notion credentials")
|
logger.info("Loading Notion credentials")
|
||||||
|
@ -33,14 +33,18 @@ class IntegrationBrain(IntegrationBrainInterface):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.db = get_supabase_client()
|
self.db = get_supabase_client()
|
||||||
|
|
||||||
def get_integration_brain(self, brain_id, user_id):
|
def get_integration_brain(self, brain_id, user_id = None):
|
||||||
response = (
|
query = (
|
||||||
self.db.table("integrations_user")
|
self.db.table("integrations_user")
|
||||||
.select("*")
|
.select("*")
|
||||||
.filter("brain_id", "eq", brain_id)
|
.filter("brain_id", "eq", brain_id)
|
||||||
.filter("user_id", "eq", user_id)
|
|
||||||
.execute()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if user_id:
|
||||||
|
query.filter("user_id", "eq", user_id)
|
||||||
|
|
||||||
|
response = query.execute()
|
||||||
|
|
||||||
if len(response.data) == 0:
|
if len(response.data) == 0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class BrainsInterface(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_brain_details(self, brain_id: UUID) -> BrainEntity | None:
|
def get_brain_details(self, brain_id: UUID, user_id: UUID) -> BrainEntity | None:
|
||||||
"""
|
"""
|
||||||
Get all public brains
|
Get all public brains
|
||||||
"""
|
"""
|
||||||
|
@ -9,7 +9,7 @@ from modules.brain.entity.integration_brain import (
|
|||||||
|
|
||||||
class IntegrationBrainInterface(ABC):
|
class IntegrationBrainInterface(ABC):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_integration_brain(self, brain_id: UUID, user_id: UUID) -> IntegrationEntity:
|
def get_integration_brain(self, brain_id: UUID) -> IntegrationEntity:
|
||||||
"""Get the integration brain entity
|
"""Get the integration brain entity
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -58,9 +58,9 @@ class BrainService:
|
|||||||
def get_brain_by_id(self, brain_id: UUID):
|
def get_brain_by_id(self, brain_id: UUID):
|
||||||
return self.brain_repository.get_brain_by_id(brain_id)
|
return self.brain_repository.get_brain_by_id(brain_id)
|
||||||
|
|
||||||
def get_integration_brain(self, brain_id, user_id) -> IntegrationEntity | None:
|
def get_integration_brain(self, brain_id) -> IntegrationEntity | None:
|
||||||
return self.integration_brains_repository.get_integration_brain(
|
return self.integration_brains_repository.get_integration_brain(
|
||||||
brain_id, user_id
|
brain_id
|
||||||
)
|
)
|
||||||
|
|
||||||
def find_brain_from_question(
|
def find_brain_from_question(
|
||||||
@ -323,34 +323,25 @@ class BrainService:
|
|||||||
def update_brain_last_update_time(self, brain_id: UUID):
|
def update_brain_last_update_time(self, brain_id: UUID):
|
||||||
self.brain_repository.update_brain_last_update_time(brain_id)
|
self.brain_repository.update_brain_last_update_time(brain_id)
|
||||||
|
|
||||||
def get_brain_details(self, brain_id: UUID, user_id: UUID) -> BrainEntity | None:
|
def get_brain_details(self, brain_id: UUID, user_id: UUID = None) -> BrainEntity | None:
|
||||||
brain = self.brain_repository.get_brain_details(brain_id)
|
brain = self.brain_repository.get_brain_details(brain_id)
|
||||||
if brain == None:
|
if brain == None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if brain.brain_type == BrainType.API:
|
|
||||||
brain_definition = api_brain_definition_service.get_api_brain_definition(
|
|
||||||
brain_id
|
|
||||||
)
|
|
||||||
brain.brain_definition = brain_definition
|
|
||||||
|
|
||||||
if brain.brain_type == BrainType.COMPOSITE:
|
|
||||||
brain.connected_brains_ids = (
|
|
||||||
self.composite_brains_connections_repository.get_connected_brains(
|
|
||||||
brain_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if brain.brain_type == BrainType.INTEGRATION:
|
if brain.brain_type == BrainType.INTEGRATION:
|
||||||
brain.integration = (
|
brain.integration = (
|
||||||
self.integration_brains_repository.get_integration_brain(
|
self.integration_brains_repository.get_integration_brain(
|
||||||
brain_id, user_id
|
brain_id, user_id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
brain.integration_description = (
|
|
||||||
self.integration_description_repository.get_integration_description(
|
if (brain.integration):
|
||||||
brain.integration.integration_id
|
brain.integration_description = (
|
||||||
|
self.integration_description_repository.get_integration_description(
|
||||||
|
brain.integration.integration_id
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
return brain
|
return brain
|
||||||
|
|
||||||
def get_connected_brains(self, brain_id: UUID) -> list[BrainEntity]:
|
def get_connected_brains(self, brain_id: UUID) -> list[BrainEntity]:
|
||||||
|
@ -1,30 +1,26 @@
|
|||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
import { useFormContext } from "react-hook-form";
|
import { Controller } from "react-hook-form";
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
import Field from "@/lib/components/ui/Field";
|
import { TextInput } from "@/lib/components/ui/TextInput/TextInput";
|
||||||
import { emailPattern } from "@/lib/config/patterns";
|
|
||||||
import { useAuthModes } from "@/lib/hooks/useAuthModes";
|
import { useAuthModes } from "@/lib/hooks/useAuthModes";
|
||||||
|
|
||||||
import { EmailAuthContextType } from "../../../types";
|
|
||||||
|
|
||||||
export const EmailInput = (): JSX.Element => {
|
export const EmailInput = (): JSX.Element => {
|
||||||
const { register } = useFormContext<EmailAuthContextType>();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const { password, magicLink } = useAuthModes();
|
const { password, magicLink } = useAuthModes();
|
||||||
if (!password && !magicLink) {
|
if (!password && !magicLink) {
|
||||||
return <Fragment />;
|
return <Fragment />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Field
|
<Controller
|
||||||
{...register("email", {
|
name="email"
|
||||||
required: true,
|
defaultValue=""
|
||||||
pattern: emailPattern,
|
render={({ field }) => (
|
||||||
})}
|
<TextInput
|
||||||
placeholder={t("email", { ns: "login" })}
|
label="Email"
|
||||||
label={t("email", { ns: "translation" })}
|
inputValue={field.value as string}
|
||||||
inputClassName="py-1 mt-1 mb-3"
|
setInputValue={field.onChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
import { useFormContext } from "react-hook-form";
|
import { Controller, useFormContext } from "react-hook-form";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import { EmailAuthContextType } from "@/app/(auth)/login/types";
|
import { EmailAuthContextType } from "@/app/(auth)/login/types";
|
||||||
import Button from "@/lib/components/ui/Button";
|
import Button from "@/lib/components/ui/Button";
|
||||||
import Field from "@/lib/components/ui/Field";
|
import { TextInput } from "@/lib/components/ui/TextInput/TextInput";
|
||||||
import { useAuthModes } from "@/lib/hooks/useAuthModes";
|
import { useAuthModes } from "@/lib/hooks/useAuthModes";
|
||||||
|
|
||||||
import { usePasswordLogin } from "./hooks/usePasswordLogin";
|
import { usePasswordLogin } from "./hooks/usePasswordLogin";
|
||||||
@ -13,7 +13,7 @@ export const PasswordLogin = (): JSX.Element => {
|
|||||||
const { t } = useTranslation(["login"]);
|
const { t } = useTranslation(["login"]);
|
||||||
const { password } = useAuthModes();
|
const { password } = useAuthModes();
|
||||||
const { handlePasswordLogin } = usePasswordLogin();
|
const { handlePasswordLogin } = usePasswordLogin();
|
||||||
const { register, watch } = useFormContext<EmailAuthContextType>();
|
const { watch } = useFormContext<EmailAuthContextType>();
|
||||||
|
|
||||||
if (!password) {
|
if (!password) {
|
||||||
return <Fragment />;
|
return <Fragment />;
|
||||||
@ -21,17 +21,22 @@ export const PasswordLogin = (): JSX.Element => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Field
|
<Controller
|
||||||
{...register("password", { required: true })}
|
name="password"
|
||||||
placeholder={t("password", { ns: "login" })}
|
defaultValue=""
|
||||||
label={t("password", { ns: "login" })}
|
render={({ field }) => (
|
||||||
inputClassName="py-1 mt-1 mb-3"
|
<TextInput
|
||||||
type="password"
|
label="Password"
|
||||||
|
inputValue={field.value as string}
|
||||||
|
setInputValue={field.onChange}
|
||||||
|
crypted={true}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
isLoading={watch("isPasswordSubmitting")}
|
isLoading={watch("isPasswordSubmitting")}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
className="py-2 font-normal w-full mb-1"
|
className="py-2 font-normal w-full mb-1 mt-2"
|
||||||
onClick={() => void handlePasswordLogin()}
|
onClick={() => void handlePasswordLogin()}
|
||||||
>
|
>
|
||||||
{t("login")}
|
{t("login")}
|
||||||
|
46
frontend/app/(auth)/login/page.module.scss
Normal file
46
frontend/app/(auth)/login/page.module.scss
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
@use "@/styles/Spacings.module.scss";
|
||||||
|
@use "@/styles/Typography.module.scss";
|
||||||
|
|
||||||
|
.login_page_wrapper {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.section {
|
||||||
|
max-width: 500px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
row-gap: Spacings.$spacing03;
|
||||||
|
|
||||||
|
.logo_link {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
@include Typography.Big;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.primary_text {
|
||||||
|
color: var(--primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form_container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: Spacings.$spacing03;
|
||||||
|
}
|
||||||
|
|
||||||
|
.divider {
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.restriction_message {
|
||||||
|
text-align: center;
|
||||||
|
font-size: Typography.$tiny;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,17 +5,19 @@ import { FormProvider, useForm } from "react-hook-form";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import { QuivrLogo } from "@/lib/assets/QuivrLogo";
|
import { QuivrLogo } from "@/lib/assets/QuivrLogo";
|
||||||
import { Divider } from "@/lib/components/ui/Divider";
|
import { useUserSettingsContext } from "@/lib/context/UserSettingsProvider/hooks/useUserSettingsContext";
|
||||||
import { useAuthModes } from "@/lib/hooks/useAuthModes";
|
import { useAuthModes } from "@/lib/hooks/useAuthModes";
|
||||||
|
|
||||||
import { EmailLogin } from "./components/EmailLogin";
|
import { EmailLogin } from "./components/EmailLogin";
|
||||||
import { GoogleLoginButton } from "./components/GoogleLogin";
|
import { GoogleLoginButton } from "./components/GoogleLogin";
|
||||||
import { useLogin } from "./hooks/useLogin";
|
import { useLogin } from "./hooks/useLogin";
|
||||||
|
import styles from "./page.module.scss";
|
||||||
import { EmailAuthContextType } from "./types";
|
import { EmailAuthContextType } from "./types";
|
||||||
|
|
||||||
const Main = (): JSX.Element => {
|
const Main = (): JSX.Element => {
|
||||||
useLogin();
|
useLogin();
|
||||||
const { googleSso, password, magicLink } = useAuthModes();
|
const { googleSso } = useAuthModes();
|
||||||
|
const { isDarkMode } = useUserSettingsContext();
|
||||||
|
|
||||||
const methods = useForm<EmailAuthContextType>({
|
const methods = useForm<EmailAuthContextType>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@ -26,30 +28,26 @@ const Main = (): JSX.Element => {
|
|||||||
const { t } = useTranslation(["translation", "login"]);
|
const { t } = useTranslation(["translation", "login"]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-screen h-screen bg-ivory" data-testid="sign-in-card">
|
<div className={styles.login_page_wrapper}>
|
||||||
<main className="h-full flex flex-col items-center justify-center">
|
<section className={styles.section}>
|
||||||
<section className="w-full md:w-1/2 lg:w-1/3 flex flex-col gap-2">
|
<Link href="/" className={styles.logo_link}>
|
||||||
<Link href="/" className="flex justify-center">
|
<QuivrLogo size={80} color={isDarkMode ? "white" : "black"} />
|
||||||
<QuivrLogo size={80} color="black" />
|
</Link>
|
||||||
</Link>
|
<p className={styles.title}>
|
||||||
<p className="text-center text-4xl font-medium">
|
{t("talk_to", { ns: "login" })}{" "}
|
||||||
{t("talk_to", { ns: "login" })}{" "}
|
<span className={styles.primary_text}>Quivr</span>
|
||||||
<span className="text-primary">Quivr</span>
|
</p>
|
||||||
</p>
|
<div className={styles.form_container}>
|
||||||
<div className="mt-5 flex flex-col">
|
<FormProvider {...methods}>
|
||||||
<FormProvider {...methods}>
|
<EmailLogin />
|
||||||
<EmailLogin />
|
</FormProvider>
|
||||||
</FormProvider>
|
|
||||||
{googleSso && (password || magicLink) && (
|
{googleSso && <GoogleLoginButton />}
|
||||||
<Divider text={t("or")} className="my-3 uppercase" />
|
</div>
|
||||||
)}
|
<p className={styles.restriction_message}>
|
||||||
{googleSso && <GoogleLoginButton />}
|
{t("restriction_message", { ns: "login" })}
|
||||||
</div>
|
</p>
|
||||||
<p className="text-[10px] text-center">
|
</section>
|
||||||
{t("restriction_message", { ns: "login" })}
|
|
||||||
</p>
|
|
||||||
</section>
|
|
||||||
</main>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,60 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import Link from "next/link";
|
|
||||||
import { Suspense } from "react";
|
import { Suspense } from "react";
|
||||||
import { FormProvider, useForm } from "react-hook-form";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
import { QuivrLogo } from "@/lib/assets/QuivrLogo";
|
import Login from "../(auth)/login/page";
|
||||||
import { Divider } from "@/lib/components/ui/Divider";
|
|
||||||
import { useAuthModes } from "@/lib/hooks/useAuthModes";
|
|
||||||
|
|
||||||
import { EmailLogin } from "../(auth)/login/components/EmailLogin";
|
|
||||||
import { GoogleLoginButton } from "../(auth)/login/components/GoogleLogin";
|
|
||||||
import { useLogin } from "../(auth)/login/hooks/useLogin";
|
|
||||||
import { EmailAuthContextType } from "../(auth)/login/types";
|
|
||||||
|
|
||||||
const Main = (): JSX.Element => {
|
const Main = (): JSX.Element => {
|
||||||
useLogin();
|
return <Login />;
|
||||||
const { googleSso, password, magicLink } = useAuthModes();
|
|
||||||
|
|
||||||
const methods = useForm<EmailAuthContextType>({
|
|
||||||
defaultValues: {
|
|
||||||
email: "",
|
|
||||||
password: "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const { t } = useTranslation(["translation", "login"]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="w-screen h-screen bg-ivory" data-testid="sign-in-card">
|
|
||||||
<main className="h-full flex flex-col items-center justify-center">
|
|
||||||
<section className="w-full md:w-1/2 lg:w-1/3 flex flex-col gap-2">
|
|
||||||
<Link href="/" className="flex justify-center">
|
|
||||||
<QuivrLogo size={80} color="black" />
|
|
||||||
</Link>
|
|
||||||
<p className="text-center text-4xl font-medium">
|
|
||||||
{t("talk_to", { ns: "login" })}{" "}
|
|
||||||
<span className="text-primary">Quivr</span>
|
|
||||||
</p>
|
|
||||||
<div className="mt-5 flex flex-col">
|
|
||||||
<FormProvider {...methods}>
|
|
||||||
<EmailLogin />
|
|
||||||
</FormProvider>
|
|
||||||
{googleSso && (password || magicLink) && (
|
|
||||||
<Divider text={t("or")} className="my-3 uppercase" />
|
|
||||||
)}
|
|
||||||
{googleSso && <GoogleLoginButton />}
|
|
||||||
</div>
|
|
||||||
<p className="text-[10px] text-center">
|
|
||||||
{t("restriction_message", { ns: "login" })}
|
|
||||||
</p>
|
|
||||||
</section>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const Login = (): JSX.Element => {
|
const Home = (): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<Suspense fallback="Loading...">
|
<Suspense fallback="Loading...">
|
||||||
<Main />
|
<Main />
|
||||||
@ -62,4 +15,4 @@ const Login = (): JSX.Element => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Login;
|
export default Home;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable max-lines */
|
/* eslint-disable max-lines */
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
import Spinner from "@/lib/components/ui/Spinner";
|
import Spinner from "@/lib/components/ui/Spinner";
|
||||||
import { Tabs } from "@/lib/components/ui/Tabs/Tabs";
|
import { Tabs } from "@/lib/components/ui/Tabs/Tabs";
|
||||||
@ -20,6 +20,14 @@ export const BrainManagementTabs = (): JSX.Element => {
|
|||||||
brainId,
|
brainId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const knowledgeTabDisabled = (): boolean => {
|
||||||
|
return (
|
||||||
|
!hasEditRights ||
|
||||||
|
(brain?.integration_description?.max_files === 0 &&
|
||||||
|
brain.brain_type !== "doc")
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const brainManagementTabs: Tab[] = [
|
const brainManagementTabs: Tab[] = [
|
||||||
{
|
{
|
||||||
label: "Settings",
|
label: "Settings",
|
||||||
@ -39,13 +47,14 @@ export const BrainManagementTabs = (): JSX.Element => {
|
|||||||
isSelected: selectedTab === "Knowledge",
|
isSelected: selectedTab === "Knowledge",
|
||||||
onClick: () => setSelectedTab("Knowledge"),
|
onClick: () => setSelectedTab("Knowledge"),
|
||||||
iconName: "file",
|
iconName: "file",
|
||||||
disabled:
|
disabled: knowledgeTabDisabled(),
|
||||||
!hasEditRights ||
|
|
||||||
(!brain?.integration_description?.max_files &&
|
|
||||||
brain?.brain_type !== "doc"),
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
brainManagementTabs[2].disabled = knowledgeTabDisabled();
|
||||||
|
}, [hasEditRights]);
|
||||||
|
|
||||||
if (!brainId) {
|
if (!brainId) {
|
||||||
return <div />;
|
return <div />;
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,10 @@ export const usePermissionsController = ({
|
|||||||
isUpdatingApiDefinition: boolean;
|
isUpdatingApiDefinition: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { hasEditRights, isOwnedByCurrentUser, isPublicBrain } =
|
const { hasEditRights, isOwnedByCurrentUser } = getBrainPermissions({
|
||||||
getBrainPermissions({
|
brainId,
|
||||||
brainId,
|
userAccessibleBrains: allBrains,
|
||||||
userAccessibleBrains: allBrains,
|
});
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setValue("isApiDefinitionReadOnly", !hasEditRights);
|
setValue("isApiDefinitionReadOnly", !hasEditRights);
|
||||||
@ -35,6 +34,5 @@ export const usePermissionsController = ({
|
|||||||
return {
|
return {
|
||||||
hasEditRights,
|
hasEditRights,
|
||||||
isOwnedByCurrentUser,
|
isOwnedByCurrentUser,
|
||||||
isPublicBrain,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -34,11 +34,10 @@ export const useBrainManagementTabs = (customBrainId?: UUID) => {
|
|||||||
const { t } = useTranslation(["delete_or_unsubscribe_from_brain"]);
|
const { t } = useTranslation(["delete_or_unsubscribe_from_brain"]);
|
||||||
const brainId = customBrainId ?? (params?.brainId as UUID | undefined);
|
const brainId = customBrainId ?? (params?.brainId as UUID | undefined);
|
||||||
|
|
||||||
const { hasEditRights, isOwnedByCurrentUser, isPublicBrain } =
|
const { hasEditRights, isOwnedByCurrentUser } = getBrainPermissions({
|
||||||
getBrainPermissions({
|
brainId,
|
||||||
brainId,
|
userAccessibleBrains: allBrains,
|
||||||
userAccessibleBrains: allBrains,
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const handleUnSubscription = async () => {
|
const handleUnSubscription = async () => {
|
||||||
if (brainId === undefined) {
|
if (brainId === undefined) {
|
||||||
@ -87,6 +86,5 @@ export const useBrainManagementTabs = (customBrainId?: UUID) => {
|
|||||||
hasEditRights,
|
hasEditRights,
|
||||||
isOwnedByCurrentUser,
|
isOwnedByCurrentUser,
|
||||||
isDeleteOrUnsubscribeRequestPending,
|
isDeleteOrUnsubscribeRequestPending,
|
||||||
isPublicBrain,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,6 @@ export const getBrainPermissions = ({
|
|||||||
brainId,
|
brainId,
|
||||||
userAccessibleBrains,
|
userAccessibleBrains,
|
||||||
}: GetBrainPermissionsProps): {
|
}: GetBrainPermissionsProps): {
|
||||||
isPublicBrain: boolean;
|
|
||||||
hasEditRights: boolean;
|
hasEditRights: boolean;
|
||||||
isOwnedByCurrentUser: boolean;
|
isOwnedByCurrentUser: boolean;
|
||||||
} => {
|
} => {
|
||||||
@ -28,11 +27,10 @@ export const getBrainPermissions = ({
|
|||||||
userAccessibleBrains,
|
userAccessibleBrains,
|
||||||
});
|
});
|
||||||
|
|
||||||
const isPublicBrain =
|
|
||||||
userAccessibleBrains.find((brain) => brain.id === brainId)?.status ===
|
|
||||||
"public";
|
|
||||||
|
|
||||||
const hasEditRights = isOwnedByCurrentUser || userHasBrainEditorRights;
|
const hasEditRights = isOwnedByCurrentUser || userHasBrainEditorRights;
|
||||||
|
|
||||||
return { isPublicBrain, hasEditRights, isOwnedByCurrentUser };
|
return {
|
||||||
|
hasEditRights,
|
||||||
|
isOwnedByCurrentUser,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
@ -44,8 +44,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.brain_title {
|
.brain_title {
|
||||||
font-size: Typography.$medium;
|
@include Typography.EllipsisOverflow;
|
||||||
|
font-size: Typography.$small;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
font-size: Typography.$tiny;
|
font-size: Typography.$tiny;
|
||||||
|
|
||||||
&.primary {
|
&.primary {
|
||||||
background-color: var(--primary-1);
|
background-color: var(--background-special-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.gold {
|
&.gold {
|
||||||
|
@ -10,6 +10,7 @@ type TextInputProps = {
|
|||||||
simple?: boolean;
|
simple?: boolean;
|
||||||
onSubmit?: () => void;
|
onSubmit?: () => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
crypted?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TextInput = ({
|
export const TextInput = ({
|
||||||
@ -20,6 +21,7 @@ export const TextInput = ({
|
|||||||
simple,
|
simple,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
disabled,
|
disabled,
|
||||||
|
crypted,
|
||||||
}: TextInputProps): JSX.Element => {
|
}: TextInputProps): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -31,7 +33,7 @@ export const TextInput = ({
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
className={styles.text_input}
|
className={styles.text_input}
|
||||||
type="text"
|
type={crypted ? "password" : "text"}
|
||||||
value={inputValue}
|
value={inputValue}
|
||||||
onChange={(e) => setInputValue(e.target.value)}
|
onChange={(e) => setInputValue(e.target.value)}
|
||||||
placeholder={label}
|
placeholder={label}
|
||||||
|
@ -18,12 +18,10 @@ export const UserSettingsProvider = ({
|
|||||||
}): JSX.Element => {
|
}): JSX.Element => {
|
||||||
const [isDarkMode, setIsDarkMode] = useState<boolean>(() => {
|
const [isDarkMode, setIsDarkMode] = useState<boolean>(() => {
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
const localIsDarkMode = localStorage.getItem("isDarkMode");
|
return true;
|
||||||
|
|
||||||
return parseBoolean(localIsDarkMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user