-
Notifications
You must be signed in to change notification settings - Fork 110
feat(lightspeed): add Sources chip + popover for notebook context #3672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
its-mitesh-kumar
merged 9 commits into
redhat-developer:main
from
its-mitesh-kumar:feat/lightspeed-notebook-sources-chip-popover
Jul 9, 2026
+471
−31
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9182c07
feat(lightspeed): add Sources chip + popover for notebook context
its-mitesh-kumar 9254817
handling pluralization
its-mitesh-kumar c087ef7
updating translations
its-mitesh-kumar 102d13e
removing lines between docs and changing icon color
its-mitesh-kumar 78b6164
removing the button to open links
its-mitesh-kumar 0f06489
using PF components
its-mitesh-kumar ddd4f25
updating patternfly version
its-mitesh-kumar fbd3a2c
truncating longer filename
its-mitesh-kumar 8e1a430
Merge remote-tracking branch 'upstream' into feat/lightspeed-notebook…
its-mitesh-kumar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| '@red-hat-developer-hub/backstage-plugin-lightspeed': minor | ||
| --- | ||
|
|
||
| Replace inline SourcesCard with a compact chip + popover for notebook sources display, using PatternFly's native Popover component with custom FileTypeIcon badges and i18n support for all languages. |
This file contains hidden or 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 hidden or 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 hidden or 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
165 changes: 165 additions & 0 deletions
165
workspaces/lightspeed/plugins/lightspeed/src/components/SourcesChipModal.tsx
This file contains hidden or 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,165 @@ | ||
| /* | ||
| * Copyright Red Hat, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { makeStyles } from '@material-ui/core'; | ||
| import { SourcesCardProps } from '@patternfly/chatbot'; | ||
| import { | ||
| Button, | ||
| HelperText, | ||
| HelperTextItem, | ||
| List, | ||
| ListItem, | ||
| Popover, | ||
| Tooltip, | ||
| } from '@patternfly/react-core'; | ||
| import { InfoCircleIcon, LinkIcon } from '@patternfly/react-icons'; | ||
|
|
||
| import { useTranslation } from '../hooks/useTranslation'; | ||
| import { FileTypeIcon } from './notebooks/FileTypeIcon'; | ||
|
|
||
| const POPOVER_WIDTH = '400px'; | ||
|
|
||
| const useStyles = makeStyles(theme => ({ | ||
| sourcesPopover: { | ||
| '& .pf-v6-c-popover__title': { | ||
| alignItems: 'flex-start', | ||
| }, | ||
| '& .pf-v6-c-popover__title-text': { | ||
| margin: 0, | ||
| }, | ||
| '& .pf-v6-c-popover__header': { | ||
| paddingBlockEnd: theme.spacing(2), | ||
| }, | ||
| '& .pf-v6-c-popover__body': { | ||
| paddingBlockStart: 0, | ||
| }, | ||
| }, | ||
| chipButton: { | ||
| padding: '4px 12px', | ||
| fontSize: '0.8125rem', | ||
| fontWeight: 500, | ||
| borderRadius: 16, | ||
| backgroundColor: 'transparent', | ||
| color: 'var(--pf-t--global--text--color--regular, #1b1d21)', | ||
| '&:hover': { | ||
| backgroundColor: | ||
| 'var(--pf-t--global--background--color--secondary--default, #e0e0e0)', | ||
| }, | ||
| '& .pf-v6-c-button__icon': { | ||
| color: 'inherit', | ||
| }, | ||
| }, | ||
| helperText: { | ||
| marginBottom: theme.spacing(1.5), | ||
| color: 'var(--pf-t--global--text--color--subtle, #c7c7c7)', | ||
| }, | ||
| sourcesList: { | ||
| maxHeight: 320, | ||
| overflowY: 'auto' as const, | ||
| }, | ||
| sourceItem: { | ||
| alignItems: 'center', | ||
| '& .pf-v6-c-list__item-text': { | ||
| minWidth: 0, | ||
| }, | ||
| }, | ||
| sourceContent: { | ||
| flex: 1, | ||
| minWidth: 0, | ||
| }, | ||
| sourceTitle: { | ||
| fontSize: '0.875rem', | ||
| fontWeight: 500, | ||
| overflow: 'hidden', | ||
| textOverflow: 'ellipsis', | ||
| whiteSpace: 'nowrap', | ||
| }, | ||
| sourceBody: { | ||
| fontSize: '0.8125rem', | ||
| color: 'var(--pf-t--global--text--color--subtle, #c7c7c7)', | ||
| marginTop: 2, | ||
| overflow: 'hidden', | ||
| textOverflow: 'ellipsis', | ||
| display: '-webkit-box', | ||
| WebkitLineClamp: 2, | ||
| WebkitBoxOrient: 'vertical', | ||
| }, | ||
| })); | ||
|
|
||
| type SourcesChipModalProps = { | ||
| sources: SourcesCardProps; | ||
| }; | ||
|
|
||
| export const SourcesChipModal = ({ sources }: SourcesChipModalProps) => { | ||
| const classes = useStyles(); | ||
| const { t } = useTranslation(); | ||
|
|
||
| const count = sources.sources?.length ?? 0; | ||
| if (count === 0) return null; | ||
|
|
||
| return ( | ||
| <Popover | ||
| className={classes.sourcesPopover} | ||
| position="top-start" | ||
| triggerAction="click" | ||
| aria-label={t('sources.modal.title')} | ||
| headerContent={t('sources.modal.title')} | ||
| headerIcon={<LinkIcon />} | ||
| closeBtnAriaLabel={t('sources.popover.closeAriaLabel')} | ||
| minWidth={POPOVER_WIDTH} | ||
| maxWidth={POPOVER_WIDTH} | ||
| appendTo={() => document.body} | ||
| bodyContent={ | ||
| <> | ||
| <HelperText className={classes.helperText}> | ||
| <HelperTextItem variant="indeterminate" icon={<InfoCircleIcon />}> | ||
| {t('sources.modal.description')} | ||
| </HelperTextItem> | ||
| </HelperText> | ||
| <List | ||
| isPlain | ||
| className={classes.sourcesList} | ||
| aria-label={t('sources.modal.title')} | ||
| > | ||
| {sources.sources.map((source, index) => { | ||
| const title = source.title ?? `Source ${index + 1}`; | ||
| return ( | ||
| <ListItem | ||
| key={`${source.title}-${index}`} | ||
| className={classes.sourceItem} | ||
| icon={<FileTypeIcon fileName={title} />} | ||
| > | ||
| <div className={classes.sourceContent}> | ||
| <Tooltip content={title}> | ||
| <div className={classes.sourceTitle}>{title}</div> | ||
| </Tooltip> | ||
| {source.body && ( | ||
| <div className={classes.sourceBody}>{source.body}</div> | ||
| )} | ||
| </div> | ||
| </ListItem> | ||
| ); | ||
| })} | ||
| </List> | ||
| </> | ||
| } | ||
| > | ||
| <Button variant="link" icon={<LinkIcon />} className={classes.chipButton}> | ||
| {(t as Function)('sources.chip.label', { count })} | ||
| </Button> | ||
| </Popover> | ||
| ); | ||
| }; | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.