Docs: Bot route updates

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/11106
GitOrigin-RevId: aed07c10184dfb3d40ddb0d6fcbf818c7b169ed4
This commit is contained in:
Sean Park-Ross 2024-12-03 11:51:26 +00:00 committed by Sean Park-Ross
parent 713e12572b
commit 0eff0576dd
8 changed files with 74 additions and 58 deletions

View File

@ -146,7 +146,7 @@ The `type` determines the interface for the input validation, which initially on
The `definition` field provides the necessary context for communicating and submitting the data for input validation. It The `definition` field provides the necessary context for communicating and submitting the data for input validation. It
is an object with the following fields. is an object with the following fields.
- `url` - _Required_, a [string value](https://hasura.io/docs/2.0/api-reference/syntax-defs/#webhookurl) which - `url` - _Required_, a [string value](/api-reference/syntax-defs/#webhookurl) which
supports templating environment variables. supports templating environment variables.
- `headers` - _Optional_, a list of headers to be sent to the URL. - `headers` - _Optional_, a list of headers to be sent to the URL.
- `forward_client_headers` - _Optional_, default is `false`. If set to `true` the client headers are forwarded to the - `forward_client_headers` - _Optional_, default is `false`. If set to `true` the client headers are forwarded to the

View File

@ -5,10 +5,22 @@ const path = require('path');
const lightCodeTheme = require('prism-react-renderer/themes/vsLight'); const lightCodeTheme = require('prism-react-renderer/themes/vsLight');
const darkCodeTheme = require('prism-react-renderer/themes/dracula'); const darkCodeTheme = require('prism-react-renderer/themes/dracula');
const DOCS_SERVER_ROOT_URLS = {
development: 'localhost:8000',
production: 'website-api.hasura.io',
staging: 'website-api.stage.hasura.io',
};
const DOCS_SERVER_URLS = {
development: `http://${DOCS_SERVER_ROOT_URLS.development}`,
production: `https://${DOCS_SERVER_ROOT_URLS.production}`,
staging: `https://${DOCS_SERVER_ROOT_URLS.staging}`,
};
const BOT_ROUTES = { const BOT_ROUTES = {
development: 'ws://localhost:8000/bot/query', development: `ws://${DOCS_SERVER_ROOT_URLS.development}/bot/query`,
production: 'wss://website-api.hasura.io/docs-services/docs-server/bot/query', production: `wss://${DOCS_SERVER_ROOT_URLS.production}/docs-services/docs-server/bot/query`,
staging: 'wss://website-api.stage.hasura.io/docs-services/docs-server/bot/query', staging: `wss://${DOCS_SERVER_ROOT_URLS.staging}/docs-services/docs-server/bot/query`,
}; };
/** @type {import('@docusaurus/types').Config} */ /** @type {import('@docusaurus/types').Config} */
@ -16,7 +28,7 @@ const config = {
title: 'Hasura GraphQL Docs', title: 'Hasura GraphQL Docs',
tagline: 'Instant GraphQL on all your data', tagline: 'Instant GraphQL on all your data',
url: 'https://hasura.io', url: 'https://hasura.io',
baseUrl: '/docs/2.0', baseUrl: process.env.CF_PAGES === '1' ? '/' : '/docs/2.0',
trailingSlash: true, trailingSlash: true,
onBrokenLinks: 'throw', onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'throw', onBrokenMarkdownLinks: 'throw',
@ -29,19 +41,25 @@ const config = {
if (process.env.CF_PAGES === '1') { if (process.env.CF_PAGES === '1') {
return BOT_ROUTES.staging; // if we're on CF pages, use the staging environment return BOT_ROUTES.staging; // if we're on CF pages, use the staging environment
} else { } else {
switch (process.env.release_mode) { const mode = process.env.release_mode;
case 'development': if (mode === 'staging') {
return BOT_ROUTES.development; // if we're on the development environment, use the local server return BOT_ROUTES.production; // use production route for staging
case 'production':
return BOT_ROUTES.production;
case 'staging':
return BOT_ROUTES.production; // if we're in full staging on GCP and not cloudflare pages, use the production environment
default:
return BOT_ROUTES.development; // default to development if no match (env var not generally set on local dev)
} }
return BOT_ROUTES[mode ?? 'development'];
} }
})(), })(),
hasuraVersion: 2, docsServerURL: (() => {
if (process.env.CF_PAGES === '1') {
return DOCS_SERVER_URLS.staging; // if we're on CF pages, use the staging environment
} else {
const mode = process.env.release_mode;
if (mode === 'staging') {
return DOCS_SERVER_URLS.production; // use production route for staging
}
return DOCS_SERVER_URLS[mode ?? 'development'];
}
})(),
hasuraVersion: 3,
DEV_TOKEN: process.env.DEV_TOKEN, DEV_TOKEN: process.env.DEV_TOKEN,
}, },
scripts: [], scripts: [],
@ -167,8 +185,8 @@ const config = {
announcementBar: { announcementBar: {
id: 'announcementBar-1', // Increment on change id: 'announcementBar-1', // Increment on change
content: `The new version of Hasura has launched. <a target="_blank" rel="noopener" href="https://hasura.io/docs/3.0/getting-started/quickstart/?utm_source=hasura&utm_medium=v2_docs">Get started with Hasura DDN here.</a>`, content: `The new version of Hasura has launched. <a target="_blank" rel="noopener" href="https://hasura.io/docs/3.0/getting-started/quickstart/?utm_source=hasura&utm_medium=v2_docs">Get started with Hasura DDN here.</a>`,
// isCloseable: true, isCloseable: false,
// backgroundColor: '#fafbfc', // backgroundColor: '#478BCA',
// textColor: '#091E42', // textColor: '#091E42',
}, },
// announcementBar: { // announcementBar: {

View File

@ -332,8 +332,7 @@ export function AiChatBot({ style }) {
</div> </div>
{messages.length > 3 && !isResponding && ( {messages.length > 3 && !isResponding && (
<form <form
id="bad-response-form" id={'bad-response-form'}
className="bad-response-form"
onSubmit={e => { onSubmit={e => {
e.preventDefault(); e.preventDefault();
handleBadBotResponse(); handleBadBotResponse();
@ -341,8 +340,8 @@ export function AiChatBot({ style }) {
> >
<div className={'flex'}> <div className={'flex'}>
<button <button
className="thumbs-down-button"
type="button" type="button"
className="thumbs-down-button"
onClick={() => { onClick={() => {
setBadResponse({ setBadResponse({
responseText: null, responseText: null,
@ -358,13 +357,14 @@ export function AiChatBot({ style }) {
<div className="bad-response-container"> <div className="bad-response-container">
<textarea <textarea
rows={4} rows={4}
className={'w-full bg-none text-gray-700 placeholder-gray-500'}
onChange={e => onChange={e =>
setBadResponse(prevState => ({ ...prevState, responseText: e.target.value })) setBadResponse(prevState => ({ ...prevState, responseText: e.target.value }))
} }
placeholder={'Sorry about that. Please tell us how we can improve.'} placeholder={'Sorry about that. Please tell us how we can improve.'}
></textarea> ></textarea>
<button className="feedback-submit-button" type={'submit'}> <button type={'submit'} className={'feedback-submit-button'}>
Submit Feedback Submit
</button> </button>
</div> </div>
)} )}

View File

@ -179,7 +179,7 @@
cursor: pointer; cursor: pointer;
} }
.chat-popup .bad-response-form .thumbs-down-button { .chat-popup #bad-response-form .thumbs-down-button {
background-color: transparent; background-color: transparent;
border: none; border: none;
} }

View File

@ -4,9 +4,11 @@ import GraphQLWithHasuraBanner from '@site/src/components/GraphQLWithHasuraBanne
import CustomFooter from '@site/src/components/CustomFooter'; import CustomFooter from '@site/src/components/CustomFooter';
import styles from './styles.module.scss'; import styles from './styles.module.scss';
import { Redirect } from '@docusaurus/router'; import { Redirect } from '@docusaurus/router';
import { AiChatBot } from "@site/src/components/AiChatBot/AiChatBot"; import { AiChatBot } from '@site/src/components/AiChatBot/AiChatBot';
import BrowserOnly from '@docusaurus/BrowserOnly'; import BrowserOnly from '@docusaurus/BrowserOnly';
import { NewVersionModal } from "@site/src/components/NewVersionModal/NewVersionModal"; import { NewVersionModal } from '@site/src/components/NewVersionModal/NewVersionModal';
import useBaseUrl from '@docusaurus/useBaseUrl';
const CustomDocItem = props => { const CustomDocItem = props => {
useEffect(() => { useEffect(() => {
// This function is adds <wbr> tags to code blocks within a table // This function is adds <wbr> tags to code blocks within a table
@ -56,13 +58,13 @@ const CustomDocItem = props => {
// redirect them to the index if they attempt to directly navigate to a path with // redirect them to the index if they attempt to directly navigate to a path with
// _heading_ in it // _heading_ in it
if (props.location.pathname.includes('_heading_')) { if (props.location.pathname.includes('_heading_')) {
return <Redirect to="/docs/2.0/index/" />; return <Redirect to={useBaseUrl('/index/')} />;
} }
return ( return (
<div <div
className={ className={
props.location.pathname === `/docs/2.0/index/` props.location.pathname === useBaseUrl('/index/')
? `custom_doc_item_wrapper custom_doc_item_wrapper-x-wide` ? `custom_doc_item_wrapper custom_doc_item_wrapper-x-wide`
: `custom_doc_item_wrapper ${styles['custom_doc_item_wrapper']}` : `custom_doc_item_wrapper ${styles['custom_doc_item_wrapper']}`
} }
@ -70,19 +72,13 @@ const CustomDocItem = props => {
<ActualDocItem {...props} /> <ActualDocItem {...props} />
<div <div
className={ className={
props.location.pathname === `/docs/2.0/index/` || props.location.pathname.includes('overview') props.location.pathname === useBaseUrl('/index/') || props.location.pathname.includes('overview')
? `custom_doc_item_footer-x-wide` ? `custom_doc_item_footer-x-wide`
: styles['custom_doc_item_footer'] : styles['custom_doc_item_footer']
} }
> >
{/*<PageHelpful />*/} <BrowserOnly fallback={<div>Loading...</div>}>{() => <AiChatBot style={{}} />}</BrowserOnly>
<GraphQLWithHasuraBanner /> <BrowserOnly fallback={<div>Loading...</div>}>{() => <NewVersionModal />}</BrowserOnly>
<BrowserOnly fallback={<div>Loading...</div>}>
{() => <AiChatBot/>}
</BrowserOnly>
<BrowserOnly fallback={<div>Loading...</div>}>
{() => <NewVersionModal/>}
</BrowserOnly>
<CustomFooter /> <CustomFooter />
</div> </div>
</div> </div>

View File

@ -1,16 +1,16 @@
import styles from "./styles.module.scss"; import styles from './styles.module.scss';
import React from "react"; import React from 'react';
import useBaseUrl from '@docusaurus/useBaseUrl';
export const ScrollToFeedbackButton = ({path}: {path: string}) => {
export const ScrollToFeedbackButton = ({ path }: { path: string }) => {
const scrollToFeedback = () => { const scrollToFeedback = () => {
const feedbackElement = document.getElementById('feedback'); const feedbackElement = document.getElementById('feedback');
const y = feedbackElement.getBoundingClientRect().top + window.scrollY - 100; const y = feedbackElement.getBoundingClientRect().top + window.scrollY - 100;
window.scrollTo({top: y, behavior: 'smooth'}); window.scrollTo({ top: y, behavior: 'smooth' });
} };
// Do not show on Intro page // Do not show on Intro page
if (path === '/docs/2.0/index/') { if (path === useBaseUrl('/index/')) {
return null; return null;
} }
@ -18,5 +18,5 @@ export const ScrollToFeedbackButton = ({path}: {path: string}) => {
<div className={styles.scrollToWrapper} onClick={scrollToFeedback}> <div className={styles.scrollToWrapper} onClick={scrollToFeedback}>
Feedback 👋 Feedback 👋
</div> </div>
) );
} };

View File

@ -15,9 +15,11 @@
color: var(--ifm-color-black); color: var(--ifm-color-black);
border: 1px solid transparent; border: 1px solid transparent;
border-radius: 112px; border-radius: 112px;
padding: .75rem 1.4rem; padding: 0.75rem 1.4rem;
/* shadow/default */ /* shadow/default */
box-shadow: 0px 1px 2px 0px rgba(28, 38, 63, 0.06), 0px 1px 3px 0px rgba(28, 38, 63, 0.10); box-shadow:
0px 1px 2px 0px rgba(28, 38, 63, 0.06),
0px 1px 3px 0px rgba(28, 38, 63, 0.1);
/* /*
Unfortunately we can't make announcement bar render above the navbar Unfortunately we can't make announcement bar render above the navbar
IE need to use border-bottom instead of shadow IE need to use border-bottom instead of shadow
@ -50,14 +52,15 @@ html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
.announcementBarContent { .announcementBarContent {
flex: 1 1 auto; flex: 1 1 auto;
color: var(--primary-neutral-600); color: var(--primary-neutral-600);
font-size: .938rem; font-size: 0.938rem;
font-weight: 500; font-weight: 500;
padding: 0; padding: 0;
} }
.announcementBarContent a { .announcementBarContent a {
color: #1E56E3; color: #1e56e3;
text-decoration: none; text-decoration: none;
text-decoration: underline;
} }
@media print { @media print {
@ -94,14 +97,14 @@ html[data-announcement-bar-initially-dismissed='true'] .announcementBar {
[data-theme='dark'] .announcementBar { [data-theme='dark'] .announcementBar {
box-shadow: none; box-shadow: none;
border: 1px solid #333E4B; border: 1px solid #333e4b;
background-color: #28334F; background-color: #28334f;
} }
[data-theme='dark'] .announcementBarContent { [data-theme='dark'] .announcementBarContent {
color: #E5E7EB; color: #e5e7eb;
} }
[data-theme='dark'] .announcementBarContent a { [data-theme='dark'] .announcementBarContent a {
color: #80A3FF; color: #80a3ff;
} }
[data-theme='dark'] .announcementWrapper { [data-theme='dark'] .announcementWrapper {
background-color: #1c262f; background-color: #1c262f;

View File

@ -2,20 +2,19 @@ import React from 'react';
import DocSidebarItemCategory from '@theme/DocSidebarItem/Category'; import DocSidebarItemCategory from '@theme/DocSidebarItem/Category';
import DocSidebarItemLink from '@theme/DocSidebarItem/Link'; import DocSidebarItemLink from '@theme/DocSidebarItem/Link';
import DocSidebarItemHtml from '@theme/DocSidebarItem/Html'; import DocSidebarItemHtml from '@theme/DocSidebarItem/Html';
import useBaseUrl from '@docusaurus/useBaseUrl';
export default function DocSidebarItem({ item, ...props }) { export default function DocSidebarItem({ item, ...props }) {
switch (item.type) { switch (item.type) {
case 'category': case 'category':
if (item.customProps?.sidebar_pathname) { if (item.customProps?.sidebar_pathname) {
// if there is a custom sidebar_pathname, use it // if there is a custom sidebar_pathname, use it
item.href = `/docs/2.0/${item.customProps.sidebar_pathname}/overview/`; item.href = useBaseUrl(`/${item.customProps.sidebar_pathname}/overview/`);
} else if (item.href === undefined) { } else if (item.href === undefined) {
// if there is no custom sidebar_pathname, use the label with our regex // if there is no custom sidebar_pathname, use the label with our regex
// and apparently deal with the Wiki as a special case // and apparently deal with the Wiki as a special case
if (item.label != 'Docs Wiki') { if (item.label != 'Docs Wiki') {
item.href = `/docs/2.0/${item.label item.href = useBaseUrl(`/${item.label.toLowerCase().replace(/\s/g, '-')}/overview/`);
.toLowerCase()
.replace(/\s/g, '-')}/overview/`;
} }
} else { } else {
// if it already has a href (such as any category that has an index within the dir), use it // if it already has a href (such as any category that has an index within the dir), use it