-
Notifications
You must be signed in to change notification settings - Fork 226
Implement skipped repositories tabs #1549
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c442ff5
Implement skipped repositories tabs
robertbrignull 4272cee
Rename files to end .stories.tsx
robertbrignull 7ade7be
Use simple array type
robertbrignull 9629c99
Move alertTitle and alertMessage to props
robertbrignull baaa3d3
Update codicon styling
robertbrignull 529ceb1
Fix text when 1 repo is shown
robertbrignull 72253a1
Merge branch 'main' into robertbrignull/skipped-repos
robertbrignull 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
104 changes: 104 additions & 0 deletions
104
.../ql-vscode/src/stories/variant-analysis/VariantAnalysisSkippedRepositoriesTab.stories.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,104 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
|
|
||
| import { VariantAnalysisContainer } from '../../view/variant-analysis/VariantAnalysisContainer'; | ||
| import { VariantAnalysisSkippedRepositoriesTab } from '../../view/variant-analysis/VariantAnalysisSkippedRepositoriesTab'; | ||
|
|
||
| export default { | ||
| title: 'Variant Analysis/Variant Analysis Skipped Repositories Tab', | ||
| component: VariantAnalysisSkippedRepositoriesTab, | ||
| decorators: [ | ||
| (Story) => ( | ||
| <VariantAnalysisContainer> | ||
| <Story /> | ||
| </VariantAnalysisContainer> | ||
| ) | ||
| ], | ||
| } as ComponentMeta<typeof VariantAnalysisSkippedRepositoriesTab>; | ||
|
|
||
| const Template: ComponentStory<typeof VariantAnalysisSkippedRepositoriesTab> = (args) => ( | ||
| <VariantAnalysisSkippedRepositoriesTab {...args} /> | ||
| ); | ||
|
|
||
| export const NoAccessNoOmissions = Template.bind({}); | ||
| NoAccessNoOmissions.args = { | ||
| alertTitle: 'No access', | ||
| alertMessage: 'The following repositories could not be scanned because you do not have read access.', | ||
| skippedRepositoryGroup: { | ||
| repositoryCount: 2, | ||
| repositories: [ | ||
| { | ||
| fullName: 'octodemo/hello-globe', | ||
| }, | ||
| { | ||
| fullName: 'octodemo/hello-planet', | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| export const NoAccessWithOmissions = Template.bind({}); | ||
| NoAccessWithOmissions.args = { | ||
| ...NoAccessNoOmissions.args, | ||
| skippedRepositoryGroup: { | ||
| repositoryCount: 12345, | ||
| repositories: [ | ||
| { | ||
| fullName: 'octodemo/hello-globe', | ||
| }, | ||
| { | ||
| fullName: 'octodemo/hello-planet', | ||
| }, | ||
| { | ||
| fullName: 'octodemo/hello-universe', | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| export const NoDatabaseNoOmissions = Template.bind({}); | ||
| NoDatabaseNoOmissions.args = { | ||
| alertTitle: 'No database', | ||
| alertMessage: 'The following repositories could not be scanned because they do not have an available CodeQL database.', | ||
| skippedRepositoryGroup: { | ||
| repositoryCount: 2, | ||
| repositories: [ | ||
| { | ||
| id: 1, | ||
| fullName: 'octodemo/hello-globe', | ||
| private: false, | ||
| }, | ||
| { | ||
| id: 2, | ||
| fullName: 'octodemo/hello-planet', | ||
| private: true, | ||
| }, | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| export const NoDatabaseWithOmissions = Template.bind({}); | ||
| NoDatabaseWithOmissions.args = { | ||
| ...NoDatabaseNoOmissions.args, | ||
| skippedRepositoryGroup: { | ||
| repositoryCount: 12345, | ||
| repositories: [ | ||
| { | ||
| id: 1, | ||
| fullName: 'octodemo/hello-globe', | ||
| private: false, | ||
| }, | ||
| { | ||
| id: 2, | ||
| fullName: 'octodemo/hello-planet', | ||
| private: true, | ||
| }, | ||
| { | ||
| id: 3, | ||
| fullName: 'octodemo/hello-universe', | ||
| private: false, | ||
| }, | ||
| ], | ||
| }, | ||
| }; |
45 changes: 45 additions & 0 deletions
45
...ns/ql-vscode/src/stories/variant-analysis/VariantAnalysisSkippedRepositoryRow.stories.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,45 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
|
|
||
| import { VariantAnalysisContainer } from '../../view/variant-analysis/VariantAnalysisContainer'; | ||
| import { VariantAnalysisSkippedRepositoryRow } from '../../view/variant-analysis/VariantAnalysisSkippedRepositoryRow'; | ||
|
|
||
| export default { | ||
| title: 'Variant Analysis/Variant Analysis Skipped Repository', | ||
| component: VariantAnalysisSkippedRepositoryRow, | ||
| decorators: [ | ||
| (Story) => ( | ||
| <VariantAnalysisContainer> | ||
| <Story /> | ||
| </VariantAnalysisContainer> | ||
| ) | ||
| ], | ||
| } as ComponentMeta<typeof VariantAnalysisSkippedRepositoryRow>; | ||
|
|
||
| const Template: ComponentStory<typeof VariantAnalysisSkippedRepositoryRow> = (args) => ( | ||
| <VariantAnalysisSkippedRepositoryRow {...args} /> | ||
| ); | ||
|
|
||
| export const OnlyFullName = Template.bind({}); | ||
| OnlyFullName.args = { | ||
| repository: { | ||
| fullName: 'octodemo/hello-globe', | ||
| } | ||
| }; | ||
|
|
||
| export const Public = Template.bind({}); | ||
| Public.args = { | ||
| repository: { | ||
| fullName: 'octodemo/hello-globe', | ||
| private: false, | ||
| } | ||
| }; | ||
|
|
||
| export const Private = Template.bind({}); | ||
| Private.args = { | ||
| repository: { | ||
| fullName: 'octodemo/hello-globe', | ||
| private: true, | ||
| } | ||
| }; |
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
5 changes: 0 additions & 5 deletions
5
extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisNoCodeqlDbRepos.tsx
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisNotFoundRepos.tsx
This file was deleted.
Oops, something went wrong.
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
51 changes: 51 additions & 0 deletions
51
extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisSkippedRepositoriesTab.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,51 @@ | ||
| import * as React from 'react'; | ||
| import styled from 'styled-components'; | ||
| import { VariantAnalysisSkippedRepositoryGroup } from '../../remote-queries/shared/variant-analysis'; | ||
| import { Alert } from '../common'; | ||
| import { VariantAnalysisSkippedRepositoryRow } from './VariantAnalysisSkippedRepositoryRow'; | ||
|
|
||
| export type VariantAnalysisSkippedRepositoriesTabProps = { | ||
| alertTitle: string, | ||
| alertMessage: string, | ||
| skippedRepositoryGroup: VariantAnalysisSkippedRepositoryGroup, | ||
| }; | ||
|
|
||
| function getSkipReasonAlert( | ||
| title: string, | ||
| message: string, | ||
| repos: VariantAnalysisSkippedRepositoryGroup | ||
| ) { | ||
| const repositoriesOmittedText = repos.repositoryCount > repos.repositories.length | ||
| ? ` (Only the first ${repos.repositories.length > 1 ? `${repos.repositories.length} repositories are` : 'repository is'} shown.)` | ||
| : ''; | ||
| return ( | ||
| <Alert | ||
| key='alert' | ||
| type='warning' | ||
| title={title} | ||
| message={message + repositoriesOmittedText} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| const Container = styled.div` | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 0.5em; | ||
| width: 100%; | ||
| `; | ||
|
|
||
| export const VariantAnalysisSkippedRepositoriesTab = ({ | ||
| alertTitle, | ||
| alertMessage, | ||
| skippedRepositoryGroup, | ||
| }: VariantAnalysisSkippedRepositoriesTabProps) => { | ||
| return ( | ||
| <Container> | ||
| {getSkipReasonAlert(alertTitle, alertMessage, skippedRepositoryGroup)} | ||
| {skippedRepositoryGroup.repositories.map((repo) => | ||
| <VariantAnalysisSkippedRepositoryRow key={`repo/${repo.fullName}`} repository={repo} /> | ||
| )} | ||
| </Container> | ||
| ); | ||
| }; | ||
48 changes: 48 additions & 0 deletions
48
extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisSkippedRepositoryRow.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,48 @@ | ||
| import { VSCodeBadge, VSCodeCheckbox } from '@vscode/webview-ui-toolkit/react'; | ||
| import * as React from 'react'; | ||
| import styled from 'styled-components'; | ||
| import { Codicon, WarningIcon } from '../common'; | ||
| import { VariantAnalysisSkippedRepository as SkippedRepo } from '../../remote-queries/shared/variant-analysis'; | ||
|
|
||
| export type VariantAnalysisSkippedRepositoryRowProps = { | ||
| repository: SkippedRepo, | ||
| }; | ||
|
|
||
| const Row = styled.div` | ||
| display: flex; | ||
| flex-direction: row; | ||
| gap: 0.5em; | ||
| align-items: center; | ||
| `; | ||
|
|
||
| const ChevronIcon = styled(Codicon)` | ||
| color: var(--vscode-disabledForeground); | ||
| `; | ||
|
|
||
| const PrivacyText = styled.span` | ||
| font-size: small; | ||
| color: var(--vscode-descriptionForeground); | ||
| `; | ||
|
|
||
| function getPrivacyElement(isPrivate: boolean | undefined) { | ||
| if (isPrivate === undefined) { | ||
| return undefined; | ||
| } | ||
| const text = isPrivate ? 'private' : 'public'; | ||
| return <PrivacyText>{text}</PrivacyText>; | ||
| } | ||
|
|
||
| export const VariantAnalysisSkippedRepositoryRow = ({ | ||
| repository, | ||
| }: VariantAnalysisSkippedRepositoryRowProps) => { | ||
| return ( | ||
| <Row> | ||
| <VSCodeCheckbox /> | ||
| <ChevronIcon name='chevron-right' label='Expand' /> | ||
| <VSCodeBadge>-</VSCodeBadge> | ||
| <span>{repository.fullName}</span> | ||
| {getPrivacyElement(repository.private)} | ||
| <WarningIcon /> | ||
| </Row> | ||
| ); | ||
| }; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
keyonly needs to be unique within its parent, so just usingrepo.fullNamewould be enough:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My reasoning here was only to make super sure it doesn't conflict with the key for the alert, which is
alert. Should be fine since a repo name contains a slash, but I didn't want to rely on that or risk conflicts if another component is added to this container. So unless there's more of a benefit to simplifying it I'd prefer to keep it as it is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to leave it as-is, but I don't think you need the
keyon the alert at all since it's not part of the list. React only uses the keys for change detection in amapcall/list. Even when the component is a sibling of amapcall, it shouldn't be necessary to add thekey.