forked from sourcegraph/sourcegraph-public-snapshot
-
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.
feat(svelte): Add cody chat page (sourcegraph#64448)
Closes #srch-906 This commit adds the cody chat page to svelte. This is simply reusing the existing wrapper around the React component and renders it in a standalone page. When merged this will cause the cody chat page to be handled by new web app on dotcom by default. ## Test plan - Verified that chat loads and the tabs are clickable. - Verified that the scroll behavior works as in the React app. - Verified that the sidebar chat still works as expected (scroll behavior, default context loading/switching)
- Loading branch information
Showing
7 changed files
with
114 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<script lang="ts"> | ||
// @sg EnableRollout | ||
import Icon from '$lib/Icon.svelte' | ||
import LoadingSpinner from '$lib/LoadingSpinner.svelte' | ||
import { Alert, Button } from '$lib/wildcard' | ||
import ProductStatusBadge from '$lib/wildcard/ProductStatusBadge.svelte' | ||
import type { PageData } from './$types' | ||
export let data: PageData | ||
</script> | ||
|
||
<svelte:head> | ||
<title>Cody Chat - Sourcegraph</title> | ||
</svelte:head> | ||
|
||
<section> | ||
<header> | ||
<h2> | ||
<Icon icon={ISgCody} aria-hidden --icon-color="initial" /> | ||
<span>Cody Chat</span> | ||
<ProductStatusBadge status="beta" /> | ||
</h2> | ||
|
||
<div class="actions"> | ||
<a href={data.dashboardRoute}>Editor extensions</a> | ||
| ||
<Button variant="secondary"> | ||
<a slot="custom" let:buttonClass class={buttonClass} href={data.dashboardRoute}> Dashboard </a> | ||
</Button> | ||
</div> | ||
</header> | ||
|
||
{#await import('$lib/cody/CodyChat.svelte')} | ||
<LoadingSpinner center /> | ||
{:then module} | ||
<svelte:component this={module.default} /> | ||
{:catch} | ||
<Alert variant="warning">Failed to load Cody Chat</Alert> | ||
{/await} | ||
</section> | ||
|
||
<style lang="scss"> | ||
section { | ||
max-width: var(--viewport-lg); | ||
width: 100%; | ||
margin: 2rem auto 0 auto; | ||
display: flex; | ||
flex-direction: column; | ||
overflow: hidden; | ||
} | ||
header { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 1rem; | ||
} | ||
h2 > * { | ||
vertical-align: middle; | ||
} | ||
</style> |
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,20 @@ | ||
import { redirect } from '@sveltejs/kit' | ||
|
||
import type { PageLoad } from './$types' | ||
|
||
export const load: PageLoad = async ({ parent }) => { | ||
const dashboardRoute = window.context.sourcegraphDotComMode ? '/cody/manage' : '/cody/dashboard' | ||
const data = await parent() | ||
|
||
if (!data.user) { | ||
redirect(302, '/sign-in') | ||
} | ||
|
||
if (!window.context?.codyEnabledForCurrentUser) { | ||
redirect(303, dashboardRoute) | ||
} | ||
|
||
return { | ||
dashboardRoute, | ||
} | ||
} |
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