Skip to content

Commit 8a1cae1

Browse files
authored
chore: Import changes from the examples package (#182)
1 parent 621d33f commit 8a1cae1

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

src/pages/chat/common-components.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ export function ChatBubbleAvatar({ type, name, initials, loading }: AuthorAvatar
1616
return <Avatar initials={initials} tooltipText={name} ariaLabel={name} />;
1717
}
1818

19-
export function CodeViewActions() {
19+
export function CodeViewActions({ content }: { content: string }) {
2020
return (
2121
<ButtonGroup
2222
variant="icon"
23-
onItemClick={() => void 0}
23+
onItemClick={({ detail }) => {
24+
if (detail.id !== 'copy' || !navigator.clipboard) {
25+
return;
26+
}
27+
28+
// eslint-disable-next-line no-console
29+
navigator.clipboard.writeText(content).catch(error => console.log('Failed to copy', error.message));
30+
}}
2431
items={[
2532
{
2633
type: 'group',
@@ -84,7 +91,7 @@ export const ScrollableContainer = forwardRef(function ScrollableContainer(
8491
) {
8592
return (
8693
<div style={{ position: 'relative', blockSize: '100%' }}>
87-
<div style={{ position: 'absolute', inset: 0, overflowY: 'auto' }} ref={ref}>
94+
<div style={{ position: 'absolute', inset: 0, overflowY: 'auto' }} ref={ref} data-testid="chat-scroll-container">
8895
{children}
8996
</div>
9097
</div>

src/pages/chat/config.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,17 @@ main();`}
260260
highlight={typescriptHighlight}
261261
/>
262262
),
263-
actions: <CodeViewActions />,
263+
actions: (
264+
<CodeViewActions
265+
content={`// This is the main function that will be executed when the script runs
266+
function main(): void {
267+
// Use console.log to print "Hello, World!" to the console
268+
console.log("Hello, World!");
269+
}
270+
// Call the main function to execute the program
271+
main();`}
272+
/>
273+
),
264274
timestamp: getTimestampMinutesAgo(4),
265275
hideAvatar: true,
266276
},

src/pages/table-property-filter/property-filter-table.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ export function PropertyFilterTable({
124124
* https://owasp.org/www-community/vulnerabilities/Information_exposure_through_query_strings_in_url
125125
* For further guidance, reach out to your organization’s security team.
126126
*/
127-
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, JSON.stringify(event.detail));
127+
const query = event.detail;
128+
if (!query.tokens?.length && !query?.tokenGroups?.length) {
129+
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, null);
130+
} else {
131+
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, JSON.stringify(query));
132+
}
128133

129134
propertyFilterProps.onChange(event);
130135
}}

src/pages/table-saved-filters/root.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,13 @@ export function App() {
239239
* https://owasp.org/www-community/vulnerabilities/Information_exposure_through_query_strings_in_url
240240
* For further guidance, reach out to your organization’s security team.
241241
*/
242-
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, JSON.stringify(event.detail));
242+
const query = event.detail;
243+
if (!query.tokens?.length && !query?.tokenGroups?.length) {
244+
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, null);
245+
setQueryParam(SELECTED_FILTER_SET_QUERY_PARAM_KEY, null);
246+
} else {
247+
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, JSON.stringify(query));
248+
}
243249

244250
propertyFilterProps.onChange(event);
245251
}}

src/styles/chat.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
}
1818

1919
&.classic {
20-
position: absolute;
21-
inset-block-end: 0;
20+
inline-size: 100%;
21+
block-size: 1100px;
2222
}
2323
}
2424

0 commit comments

Comments
 (0)