-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat-test-coverage
- Loading branch information
Showing
53 changed files
with
1,026 additions
and
820 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
apps/nextjs/src/components/AppComponents/Chat/chat-list/demo-limit-message.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { ChatModerationProvider } from "@/components/ContextProviders/ChatModerationContext"; | ||
|
||
import { DemoLimitMessage } from "./demo-limit-message"; | ||
|
||
const meta: Meta<typeof DemoLimitMessage> = { | ||
title: "Components/Chat/DemoLimitMessage", | ||
component: DemoLimitMessage, | ||
tags: ["autodocs"], | ||
decorators: [ | ||
(Story) => ( | ||
<ChatModerationProvider chatId="test-chat-id"> | ||
<Story /> | ||
</ChatModerationProvider> | ||
), | ||
], | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof DemoLimitMessage>; | ||
|
||
export const Default: Story = { | ||
args: {}, | ||
}; |
22 changes: 22 additions & 0 deletions
22
apps/nextjs/src/components/AppComponents/Chat/chat-list/demo-limit-message.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use client"; | ||
|
||
import { ChatMessage } from "@/components/AppComponents/Chat/chat-message"; | ||
|
||
export function DemoLimitMessage({ id }: Readonly<{ id: string }>) { | ||
return ( | ||
<div className="w-full flex-col gap-11"> | ||
<ChatMessage | ||
chatId={id} | ||
ailaStreamingStatus="Idle" | ||
message={{ | ||
id: "demo-limit", | ||
role: "assistant", | ||
content: | ||
'{"type": "error", "message": "**Your lesson is complete**\\nYou can no longer edit this lesson. [Create new lesson.](/aila)"}', | ||
}} | ||
persistedModerations={[]} | ||
separator={<span className="my-10 flex" />} | ||
/> | ||
</div> | ||
); | ||
} |
40 changes: 40 additions & 0 deletions
40
apps/nextjs/src/components/AppComponents/Chat/chat-list/in-chat-download-buttons.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { DemoContext } from "@/components/ContextProviders/Demo"; | ||
|
||
import { InChatDownloadButtons } from "./in-chat-download-buttons"; | ||
|
||
const DemoDecorator: Story["decorators"] = (Story, { parameters }) => ( | ||
<DemoContext.Provider | ||
value={{ | ||
isDemoUser: false, | ||
isSharingEnabled: true, | ||
...parameters.demoContext, | ||
}} | ||
> | ||
<Story /> | ||
</DemoContext.Provider> | ||
); | ||
|
||
const meta: Meta<typeof InChatDownloadButtons> = { | ||
title: "Components/Chat/InChatDownloadButtons", | ||
component: InChatDownloadButtons, | ||
tags: ["autodocs"], | ||
args: { | ||
id: "test-chat-id", | ||
}, | ||
decorators: [DemoDecorator], | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof InChatDownloadButtons>; | ||
|
||
export const Default: Story = {}; | ||
|
||
export const SharingDisabled: Story = { | ||
parameters: { | ||
demoContext: { | ||
isSharingEnabled: false, | ||
}, | ||
}, | ||
}; |
63 changes: 63 additions & 0 deletions
63
apps/nextjs/src/components/AppComponents/Chat/chat-list/in-chat-download-buttons.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { OakBox, OakFlex, OakIcon, OakSpan } from "@oaknational/oak-components"; | ||
import Link from "next/link"; | ||
|
||
import { useDemoUser } from "@/components/ContextProviders/Demo"; | ||
|
||
import { useDialog } from "../../DialogContext"; | ||
|
||
export const InChatDownloadButtons = ({ id }: { readonly id: string }) => { | ||
const demo = useDemoUser(); | ||
const { setDialogWindow } = useDialog(); | ||
|
||
return ( | ||
<OakFlex $flexDirection="column" $gap="all-spacing-7" $mv="space-between-l"> | ||
{demo.isSharingEnabled && ( | ||
<Link | ||
href={demo.isSharingEnabled ? `/aila/download/${id}` : "#"} | ||
onClick={() => { | ||
if (!demo.isSharingEnabled) { | ||
setDialogWindow("demo-share-locked"); | ||
} | ||
}} | ||
> | ||
<InnerInChatButton iconName="download">Download</InnerInChatButton> | ||
</Link> | ||
)} | ||
<button | ||
onClick={() => { | ||
if (demo.isSharingEnabled) { | ||
setDialogWindow("share-chat"); | ||
} else { | ||
setDialogWindow("demo-share-locked"); | ||
} | ||
}} | ||
> | ||
<InnerInChatButton iconName="share">Share</InnerInChatButton> | ||
</button> | ||
</OakFlex> | ||
); | ||
}; | ||
|
||
const InnerInChatButton = ({ | ||
iconName, | ||
children, | ||
}: { | ||
readonly iconName: "download" | "share"; | ||
readonly children: string; | ||
}) => { | ||
return ( | ||
<OakFlex | ||
$pa="inner-padding-m" | ||
$gap="all-spacing-3" | ||
$background="white" | ||
$borderRadius="border-radius-m" | ||
$alignItems="center" | ||
$dropShadow="drop-shadow-standard" | ||
> | ||
<OakBox $transform="scale"> | ||
<OakIcon iconName={iconName} $width="all-spacing-7" /> | ||
</OakBox> | ||
<OakSpan $font="body-2">{children}</OakSpan> | ||
</OakFlex> | ||
); | ||
}; |
Oops, something went wrong.