Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
shreeyash07 committed Nov 11, 2024
1 parent 209f711 commit 8a4486e
Show file tree
Hide file tree
Showing 16 changed files with 514 additions and 40 deletions.
2 changes: 1 addition & 1 deletion backend
Submodule backend updated 50 files
+68 −10 .github/workflows/ci.yml
+75 −0 .github/workflows/helm-publish.yml
+3 −0 .gitignore
+1 −1 .python-version
+3 −2 Dockerfile
+1 −1 chatbotcore/custom_embeddings.py
+0 −1 chatbotcore/database.py
+1 −1 chatbotcore/doc_loaders.py
+9 −8 chatbotcore/llm.py
+0 −0 chatbotcore/utils.py
+0 −0 common/utils.py
+9 −0 content/enums.py
+1 −1 content/migrations/0002_alter_content_document_type.py
+7 −3 content/models.py
+17 −0 content/queries.py
+6 −0 content/serializers.py
+38 −0 content/tasks.py
+24 −0 content/types.py
+18 −0 content/views.py
+69 −28 docker-compose.yml
+4 −3 gh-docker-compose.yml
+7 −0 helm/Chart.yaml
+34 −0 helm/templates/_helpers.tpl
+57 −0 helm/templates/api/deployment.yaml
+26 −0 helm/templates/api/ingress.yaml
+24 −0 helm/templates/api/service.yaml
+46 −0 helm/templates/config/configmap.yaml
+21 −0 helm/templates/config/secret.yaml
+41 −0 helm/templates/redis/deployment.yaml
+24 −0 helm/templates/redis/service.yaml
+57 −0 helm/templates/streamlit/deployment.yaml
+26 −0 helm/templates/streamlit/ingress.yaml
+24 −0 helm/templates/streamlit/service.yaml
+48 −0 helm/templates/worker/deployment.yaml
+38 −0 helm/values-test.yaml
+109 −0 helm/values.yaml
+3 −0 main/__init__.py
+13 −0 main/celery.py
+2 −0 main/graphql/enums.py
+2 −3 main/graphql/schema.py
+35 −2 main/settings.py
+2 −12 main/urls.py
+259 −9 poetry.lock
+5 −2 pyproject.toml
+7 −0 scripts/run_prod.sh
+3 −0 scripts/run_worker.sh
+1 −11 user/mutations.py
+1 −19 user/queries.py
+0 −20 user/serializers.py
+16 −6 user/types.py
2 changes: 2 additions & 0 deletions src/App/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import '@togglecorp/toggle-ui/build/index.css';

import {
useCallback,
useEffect,
Expand Down
Binary file added src/assets/loginCover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions src/components/Container/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { _cs } from '@togglecorp/fujs';

import Header from '#components/Header';
import { type Props as HeadingProps } from '#components/Heading';

import styles from './styles.module.css';

interface Props {
actions?: React.ReactNode;
actionsContainerClassName?: string;
className?: string;
containerRef?: React.RefObject<HTMLDivElement>;
children?: React.ReactNode;
withHeaderBorder?: boolean,
showHeader?: boolean,
headerDescription?: string;
heading?: React.ReactNode;
headingClassName?: string;
headingContainerClassName?: string;
headingLevel?: HeadingProps['level'],
headingSectionClassName?: string;
icons?: React.ReactNode;
iconsContainerClassName?: string;
headingDescription?: React.ReactNode;
headingDescriptionContainerClassName?: string;
headerDescriptionContainerClassName?: string;
}

function Container(props: Props) {
const {
actions,
actionsContainerClassName,
className,
containerRef,
children,
withHeaderBorder = false,
showHeader,
headerDescription,
heading,
headingLevel,
headingSectionClassName,
headingClassName,
headingContainerClassName,
headingDescription,
headerDescriptionContainerClassName,
headingDescriptionContainerClassName,
icons,
iconsContainerClassName,
} = props;

if (!children) {
return null;
}

return (
<div
ref={containerRef}
className={className}
>
{showHeader && (
<Header
icons={icons}
iconsContainerClassName={iconsContainerClassName}
actions={actions}
actionsContainerClassName={actionsContainerClassName}
heading={heading}
headingLevel={headingLevel}
headingClassName={headingClassName}
headingSectionClassName={headingSectionClassName}
headingContainerClassName={headingContainerClassName}
headingDescription={headingDescription}
headingDescriptionContainerClassName={headingDescriptionContainerClassName}
childrenContainerClassName={_cs(
headerDescriptionContainerClassName,
)}
>
{headerDescription}
</Header>
)}
{withHeaderBorder && <div className={styles.border} />}
{children}
</div>
);
}

export default Container;
Empty file.
123 changes: 123 additions & 0 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { useMemo } from 'react';
import {
_cs,
isNotDefined,
} from '@togglecorp/fujs';

import Heading, { Props as HeadingProps } from '#components/Heading';
import useBasicLayout from '#hooks/useBasicLayout';

import styles from './styles.module.css';

interface Props {
className?: string;
elementRef?: React.Ref<HTMLDivElement>;

children?: React.ReactNode;
childrenContainerClassName?: string;

actions?: React.ReactNode;
actionsContainerClassName?: string;

icons?: React.ReactNode;
iconsContainerClassName?: string;

heading: React.ReactNode;
headingLevel?: HeadingProps['level'];
headingSectionClassName?: string;
headingContainerClassName?: string;
headingClassName?: string;
headingDescription?: React.ReactNode;
headingDescriptionContainerClassName?: string;
}

function Header(props: Props) {
const {
className,
elementRef,
actions,
actionsContainerClassName,
children,
childrenContainerClassName,
headingLevel,
heading,
headingClassName,
headingSectionClassName,
headingContainerClassName,
headingDescription,
headingDescriptionContainerClassName,
icons,
iconsContainerClassName,
} = props;

const headingChildren = useMemo(
() => {
if (isNotDefined(heading) && isNotDefined(headingDescription)) {
return null;
}

return (
<>
<Heading
level={headingLevel}
className={headingClassName}
>
{heading}
</Heading>
{headingDescription && (
<div className={headingDescriptionContainerClassName}>
{headingDescription}
</div>
)}
</>
);
},
[
heading,
headingDescription,
headingClassName,
headingDescriptionContainerClassName,
headingLevel,
],
);

const {
content,
containerClassName,
} = useBasicLayout({
actions,
actionsContainerClassName,
children: headingChildren,
childrenContainerClassName: headingContainerClassName,
className: headingSectionClassName,
icons,
iconsContainerClassName,
});

if (!content && !children) {
return null;
}

return (
<div
className={_cs(
styles.header,
className,
)}
ref={elementRef}
>
{content && (
<div className={containerClassName}>
{content}
</div>
)}
{children && (
<div className={childrenContainerClassName}>
{children}
</div>
)}
</div>
);
}

export default Header;
4 changes: 4 additions & 0 deletions src/components/Header/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.header {
display: flex;
flex-direction: column;
}
55 changes: 55 additions & 0 deletions src/components/Heading/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
ElementType,
ReactNode,
useRef,
} from 'react';
import { _cs } from '@togglecorp/fujs';

import styles from './styles.module.css';

export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;

const levelToClassName: Record<HeadingLevel, string> = {
1: styles.levelOne,
2: styles.levelTwo,
3: styles.levelThree,
4: styles.levelFour,
5: styles.levelFive,
6: styles.levelSix,
};

export interface Props {
className?: string;
level?: HeadingLevel;
children: ReactNode;
}

function Heading(props: Props) {
const {
className,
level = 3,
children,
} = props;

const HeadingTag = `h${level}` as ElementType;
const headingElementRef = useRef<HTMLHeadingElement>(null);

if (!children) {
return null;
}

return (
<HeadingTag
className={_cs(
styles.heading,
levelToClassName[level],
className,
)}
ref={headingElementRef}
>
{children}
</HeadingTag>
);
}

export default Heading;
31 changes: 31 additions & 0 deletions src/components/Heading/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.heading {
--font-size: var(--cms-ui-font-size-3xl);
--line-height: var(--cms-ui-line-height-sm);
margin: 0;
line-height: var(--line-height);
font-size: var(--font-size);

&.level-one {
--font-size: var(--cms-ui-font-size-5xl);
}

&.level-two {
--font-size: var(--cms-ui-font-size-4xl);
}

&.level-three {
--font-size: var(--cms-ui-font-size-3xl);
}

&.level-four {
--font-size: var(--cms-ui-font-size-2xl);
}

&.level-five {
--font-size: var(--cms-ui-font-size-xl);
}

&.level-six {
--font-size: var(--cms-ui-font-size-lg);
}
}
11 changes: 9 additions & 2 deletions src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
gql,
useMutation,
} from '@apollo/client';
import { _cs, isDefined, isNotDefined } from '@togglecorp/fujs';
import {
_cs,
isDefined,
isNotDefined,
} from '@togglecorp/fujs';
import { Button } from '@togglecorp/toggle-ui';

import UserContext from '#contexts/user';
Expand Down Expand Up @@ -35,8 +39,9 @@ const LOGOUT_MUTATION = gql`

function Navbar(props: Props) {
const { className } = props;

const { userAuth, removeUserAuth } = useContext(UserContext);
console.log('user', userAuth);

const [
logout,
{ loading },
Expand All @@ -60,9 +65,11 @@ function Navbar(props: Props) {
},
},
);

const handleLogoutClick = useCallback(() => {
logout();
}, [logout]);

return (
<nav className={_cs(styles.navbar, className)}>
<div>
Expand Down
Loading

0 comments on commit 8a4486e

Please sign in to comment.