Skip to content

Commit

Permalink
chore: Import changes from the examples package (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgylobko authored Jan 22, 2025
1 parent 621d33f commit 8a1cae1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
13 changes: 10 additions & 3 deletions src/pages/chat/common-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ export function ChatBubbleAvatar({ type, name, initials, loading }: AuthorAvatar
return <Avatar initials={initials} tooltipText={name} ariaLabel={name} />;
}

export function CodeViewActions() {
export function CodeViewActions({ content }: { content: string }) {
return (
<ButtonGroup
variant="icon"
onItemClick={() => void 0}
onItemClick={({ detail }) => {
if (detail.id !== 'copy' || !navigator.clipboard) {
return;
}

// eslint-disable-next-line no-console
navigator.clipboard.writeText(content).catch(error => console.log('Failed to copy', error.message));
}}
items={[
{
type: 'group',
Expand Down Expand Up @@ -84,7 +91,7 @@ export const ScrollableContainer = forwardRef(function ScrollableContainer(
) {
return (
<div style={{ position: 'relative', blockSize: '100%' }}>
<div style={{ position: 'absolute', inset: 0, overflowY: 'auto' }} ref={ref}>
<div style={{ position: 'absolute', inset: 0, overflowY: 'auto' }} ref={ref} data-testid="chat-scroll-container">
{children}
</div>
</div>
Expand Down
12 changes: 11 additions & 1 deletion src/pages/chat/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,17 @@ main();`}
highlight={typescriptHighlight}
/>
),
actions: <CodeViewActions />,
actions: (
<CodeViewActions
content={`// This is the main function that will be executed when the script runs
function main(): void {
// Use console.log to print "Hello, World!" to the console
console.log("Hello, World!");
}
// Call the main function to execute the program
main();`}
/>
),
timestamp: getTimestampMinutesAgo(4),
hideAvatar: true,
},
Expand Down
7 changes: 6 additions & 1 deletion src/pages/table-property-filter/property-filter-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ export function PropertyFilterTable({
* https://owasp.org/www-community/vulnerabilities/Information_exposure_through_query_strings_in_url
* For further guidance, reach out to your organization’s security team.
*/
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, JSON.stringify(event.detail));
const query = event.detail;
if (!query.tokens?.length && !query?.tokenGroups?.length) {
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, null);
} else {
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, JSON.stringify(query));
}

propertyFilterProps.onChange(event);
}}
Expand Down
8 changes: 7 additions & 1 deletion src/pages/table-saved-filters/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,13 @@ export function App() {
* https://owasp.org/www-community/vulnerabilities/Information_exposure_through_query_strings_in_url
* For further guidance, reach out to your organization’s security team.
*/
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, JSON.stringify(event.detail));
const query = event.detail;
if (!query.tokens?.length && !query?.tokenGroups?.length) {
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, null);
setQueryParam(SELECTED_FILTER_SET_QUERY_PARAM_KEY, null);
} else {
setQueryParam(PROPERTY_FILTERS_QUERY_PARAM_KEY, JSON.stringify(query));
}

propertyFilterProps.onChange(event);
}}
Expand Down
4 changes: 2 additions & 2 deletions src/styles/chat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
}

&.classic {
position: absolute;
inset-block-end: 0;
inline-size: 100%;
block-size: 1100px;
}
}

Expand Down

0 comments on commit 8a1cae1

Please sign in to comment.