Skip to content

Commit 16b9381

Browse files
@inkeep/widgets -> @inkeep/cxkit-react (#151)
* Initial draft for inkeep migration * Bump to latest * Tweak transform source logic * Remove excessive breadcrumb check * Test against goteleport.dev * Add inkeep package to the list of allowlisted dependencies * update inkeep to 0.5.32 * update to 0.5.33 * Revert "Test against goteleport.dev" This reverts commit cdb89c4. * bump @inkeep/cxkit-react to 0.5.36 * Add `LicenseRef-scancode-public-domain AND Unlicense` license --------- Co-authored-by: sarah_inkeep <sarah.niemiec@inkeep.com>
1 parent eafc8b8 commit 16b9381

File tree

7 files changed

+2359
-4551
lines changed

7 files changed

+2359
-4551
lines changed

.github/workflows/dependency-review.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,13 @@ jobs:
99
permissions:
1010
contents: read
1111
with:
12-
allow-dependencies-licenses: 'pkg:npm/%40inkeep/widgets, pkg:npm/domain-browser'
12+
allow-additional-licenses: >
13+
LicenseRef-scancode-public-domain AND Unlicense
14+
allow-dependencies-licenses: >
15+
pkg:npm/%40inkeep/cxkit-color-mode,
16+
pkg:npm/%40inkeep/cxkit-primitives,
17+
pkg:npm/%40inkeep/cxkit-react,
18+
pkg:npm/%40inkeep/cxkit-styled,
19+
pkg:npm/%40inkeep/cxkit-theme,
20+
pkg:npm/%40inkeep/cxkit-types,
21+
pkg:npm/domain-browser

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Settings for AWS Amplify are following:
3535
1. `nodejs` 20 and `yarn` v1.22.22.
3636
2. Build command `yarn build`
3737
4. Build results folder `build`
38-
5. Following env variables should be set: `INKEEP_API_KEY`, `INKEEP_INTEGRATION_ID`, `INKEEP_ORGANIZATION_ID`, `YOUTUBE_API_KEY`, `SANITY_PROJECT_ID`, `SANITY_DATASET`.
38+
5. Following env variables should be set: `INKEEP_API_KEY`, `YOUTUBE_API_KEY`, `SANITY_PROJECT_ID`, `SANITY_DATASET`.
3939
6. This variable should be set increase nodejs memory `NODE_OPTIONS=--max-old-space-size=8192`
4040
7. Add the following redirect to make 404 work:
4141
- Source address: `/<*>`

content/18.x

Submodule 18.x updated 4770 files

docusaurus.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ const config: Config = {
4141
customFields: {
4242
inkeepConfig: {
4343
apiKey: getFromSecretOrEnv("INKEEP_API_KEY"),
44-
integrationId: getFromSecretOrEnv("INKEEP_INTEGRATION_ID"),
45-
organizationId: getFromSecretOrEnv("INKEEP_ORGANIZATION_ID"),
4644
},
4745
},
4846
clientModules: [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@docusaurus/plugin-svgr": "^3.7.0",
5555
"@docusaurus/theme-classic": "^3.7.0",
5656
"@docusaurus/tsconfig": "^3.7.0",
57-
"@inkeep/widgets": "^0.2.292",
57+
"@inkeep/cxkit-react": "^0.5.36",
5858
"@mdx-js/react": "^3.0.0",
5959
"classnames": "^2.3.1",
6060
"clsx": "^2.1.1",
Lines changed: 57 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,69 @@
11
import React, { useState, useRef, useCallback, useEffect } from "react";
22
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
33
import BrowserOnly from "@docusaurus/BrowserOnly";
4-
import { useDocsVersion } from "@docusaurus/plugin-content-docs/client";
5-
import {
6-
type InkeepAIChatSettings,
7-
type InkeepSearchSettings,
8-
type InkeepCustomTriggerProps,
9-
type InkeepWidgetBaseSettings,
10-
type AIChatFunctions,
11-
type SearchFunctions,
12-
} from "@inkeep/widgets";
4+
import type {
5+
InkeepAIChatSettings,
6+
InkeepSearchSettings,
7+
InkeepModalSearchAndChatProps,
8+
InkeepBaseSettings,
9+
AIChatFunctions,
10+
SearchFunctions,
11+
} from "@inkeep/cxkit-react";
1312

1413
import styles from "./InkeepSearch.module.css";
1514
import InkeepSearchIconSvg from "./inkeepIcon.svg";
1615

17-
const cssOverrides = `
18-
.ikp-modal-widget-content {
19-
border: 2px solid #512FC9;
20-
border-radius: 12px;
21-
top: 88px;
22-
left: 12px;
23-
}
24-
`;
25-
26-
const stylesheets = [<style key="inkeep-overrides">{cssOverrides}</style>];
2716

2817
export function InkeepSearch() {
29-
const versionMetadata = useDocsVersion();
30-
const { version } = versionMetadata;
3118
const [isOpen, setIsOpen] = useState(false);
3219
const [message, setMessage] = useState("");
3320
const [CustomTrigger, setCustomTrigger] = useState(null);
3421

3522
useEffect(() => {
3623
(async () => {
37-
const { InkeepCustomTrigger } = await import("@inkeep/widgets");
38-
setCustomTrigger(() => InkeepCustomTrigger);
24+
const { InkeepModalSearchAndChat } = await import("@inkeep/cxkit-react");
25+
setCustomTrigger(() => InkeepModalSearchAndChat);
3926
})();
4027
}, []);
4128

4229
const { siteConfig } = useDocusaurusContext();
4330

4431
const inkeepConfig = siteConfig.customFields.inkeepConfig as {
4532
apiKey: string;
46-
integrationId: string;
47-
organizationId: string;
4833
};
4934

50-
const inkeepBaseSettings: InkeepWidgetBaseSettings = {
51-
apiKey: inkeepConfig.apiKey,
52-
integrationId: inkeepConfig.integrationId,
53-
organizationId: inkeepConfig.organizationId,
35+
const inkeepBaseSettings: InkeepBaseSettings = {
36+
apiKey: inkeepConfig.apiKey || '',
5437
organizationDisplayName: "Teleport",
5538
primaryBrandColor: "#512FC9",
56-
chatApiProxyDomain: "goteleport.com/inkeep-proxy",
57-
remoteErrorLogsLevel: 1,
58-
optOutAllAnalytics: false,
59-
consoleDebugLevel: 0,
60-
customCardSettings: [
61-
{
62-
filters: {
63-
ContentType: "docs",
64-
},
65-
searchTabLabel: "Docs",
66-
icon: { builtIn: "IoDocumentTextOutline" },
67-
},
68-
],
39+
aiApiBaseUrl: "https://goteleport.com/inkeep-proxy",
40+
privacyPreferences: {
41+
optOutAllAnalytics: true,
42+
},
43+
transformSource: (source) => {
44+
const isDocs =
45+
source.contentType === 'docs' ||
46+
source.type === 'documentation'
47+
if (!isDocs) {
48+
return source
49+
}
50+
return {
51+
...source,
52+
tabs: ['Docs', ...(source.tabs ?? [])],
53+
icon: { builtIn: 'IoDocumentTextOutline' },
54+
}
55+
},
56+
colorMode: {
57+
forcedColorMode: "light",
58+
},
6959
theme: {
70-
colorMode: {
71-
forcedColorMode: "light",
72-
},
73-
tokens: {
74-
zIndex: {
75-
overlay: "2100",
76-
modal: "2200",
77-
popover: "2300",
78-
skipLink: "2400",
79-
toast: "2500",
80-
tooltip: "2600",
81-
},
60+
zIndex: {
61+
overlay: "2100",
62+
modal: "2200",
63+
popover: "2300",
64+
skipLink: "2400",
65+
toast: "2500",
66+
tooltip: "2600",
8267
},
8368
},
8469
};
@@ -89,39 +74,33 @@ export function InkeepSearch() {
8974
const handleChange = useCallback(
9075
(str: string) => {
9176
chatCallableFunctionsRef.current?.updateInputMessage(str);
92-
searchCallableFunctionsRef.current?.updateSearchQuery(str);
77+
searchCallableFunctionsRef.current?.updateQuery(str);
9378
setMessage(str);
94-
setIsOpen(true);
79+
if (str) {
80+
setIsOpen(true);
81+
}
9582
},
96-
[setMessage, chatCallableFunctionsRef, searchCallableFunctionsRef]
83+
[]
9784
);
9885

99-
const handleClose = useCallback(() => {
100-
setIsOpen(false);
101-
}, []);
10286

103-
const inkeepCustomTriggerProps: InkeepCustomTriggerProps = {
104-
isOpen,
105-
onClose: handleClose,
106-
stylesheets,
87+
const inkeepCustomTriggerProps: InkeepModalSearchAndChatProps = {
10788
baseSettings: {
10889
...inkeepBaseSettings,
10990
},
11091
aiChatSettings: {
11192
...inkeepAIChatSettings,
11293
chatFunctionsRef: chatCallableFunctionsRef,
113-
handleMessageChange: handleChange,
114-
messageAttributes: {
115-
productVersion: version,
116-
},
94+
onInputMessageChange: handleChange,
11795
},
11896
searchSettings: {
11997
...inkeepSearchSettings,
12098
searchFunctionsRef: searchCallableFunctionsRef,
121-
handleSearchQueryChange: handleChange,
99+
onQueryChange: handleChange,
122100
},
123101
modalSettings: {
124-
closeOnBlur: true,
102+
onOpenChange: setIsOpen,
103+
isOpen: isOpen,
125104
},
126105
};
127106

@@ -150,21 +129,16 @@ export function InkeepSearch() {
150129
}
151130

152131
const inkeepAIChatSettings: InkeepAIChatSettings = {
153-
botName: "Teleport",
154-
botAvatarSrcUrl: "https://goteleport.com/static/pam-standing.svg",
155-
isControlledMessage: true,
156-
defaultChatMode: "AUTO",
132+
aiAssistantName: 'Teleport',
133+
aiAssistantAvatar: 'https://goteleport.com/static/pam-standing.svg',
157134
};
158135

159136
const inkeepSearchSettings: InkeepSearchSettings = {
160-
placeholder: "Search Docs",
161-
tabSettings: {
162-
isAllTabEnabled: false,
163-
rootBreadcrumbsToUseAsTabs: ["Docs", "GitHub"],
164-
tabOrderByLabel: ["Docs", "GitHub"],
165-
alwaysDisplayedTabs: ["Docs", "GitHub"],
166-
disabledDefaultTabs: undefined,
167-
},
168-
isControlledSearchQuery: true,
137+
placeholder: 'Search Docs',
138+
tabs: [
139+
['Docs', { isAlwaysVisible: true }],
140+
['GitHub', { isAlwaysVisible: true }],
141+
],
169142
shouldOpenLinksInNewTab: true,
143+
view: 'dual-pane',
170144
};

0 commit comments

Comments
 (0)