-
Notifications
You must be signed in to change notification settings - Fork 171
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
Github Search Module For Github Issues #1465
Open
alper98
wants to merge
12
commits into
backstage:main
Choose a base branch
from
alper98:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,833
−26
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6842223
feat: github search issue module
alper98 629ef5b
feat: yarn lock
alper98 bade9e0
feat: changesets
alper98 de69c24
feat: codeowners
alper98 8f7bc1d
feat: formatting codeowners
alper98 d812ea5
feat: adding it to the existing github-issues workspace
alper98 42024fd
feat: migrate rest
alper98 5136382
feat: readme
alper98 0821ace
feat: add tests
alper98 65444f1
feat: package json and changesets
alper98 bcd9139
feat: name of test
alper98 d6896b4
Merge branch 'main' into main
alper98 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
5 changes: 5 additions & 0 deletions
5
workspaces/github-issues/.changeset/friendly-panthers-worry.md
This file contains 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 @@ | ||
--- | ||
'@backstage-community/plugin-search-backend-module-github-issues': minor | ||
--- | ||
|
||
Added new search backend module for indexing github issues. |
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
110 changes: 110 additions & 0 deletions
110
...onents/GithubIssues/GithubIssuesSearchResultListItem/GithubIssuesSearchResultListItem.tsx
This file contains 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,110 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* 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 { Link } from '@backstage/core-components'; | ||
import { | ||
IndexableDocument, | ||
ResultHighlight, | ||
} from '@backstage/plugin-search-common'; | ||
import { HighlightedSearchResultText } from '@backstage/plugin-search-react'; | ||
import Box from '@material-ui/core/Box'; | ||
import Chip from '@material-ui/core/Chip'; | ||
import ListItemIcon from '@material-ui/core/ListItemIcon'; | ||
import ListItemText from '@material-ui/core/ListItemText'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import React, { ReactNode } from 'react'; | ||
|
||
const useStyles = makeStyles( | ||
{ | ||
flexContainer: { | ||
flexWrap: 'wrap', | ||
}, | ||
itemText: { | ||
width: '100%', | ||
wordBreak: 'break-all', | ||
marginBottom: '1rem', | ||
}, | ||
}, | ||
{ name: 'GithubIssuesSearchResultListItemItem' }, | ||
); | ||
|
||
/** | ||
* Props for {@link GithubIssuesSearchResultListItemItem}. | ||
* | ||
* @public | ||
*/ | ||
export interface GithubIssuesSearchResultListItemItemProps { | ||
icon?: ReactNode | ((result: IndexableDocument) => ReactNode); | ||
result?: IndexableDocument; | ||
highlight?: ResultHighlight; | ||
rank?: number; | ||
} | ||
|
||
/** @public */ | ||
export function GithubIssuesSearchResultListItemItem( | ||
props: GithubIssuesSearchResultListItemItemProps, | ||
) { | ||
const result = props.result as any; | ||
|
||
const classes = useStyles(); | ||
|
||
if (!result) return null; | ||
|
||
return ( | ||
<> | ||
{props.icon && ( | ||
<ListItemIcon> | ||
{typeof props.icon === 'function' ? props.icon(result) : props.icon} | ||
</ListItemIcon> | ||
)} | ||
<div className={classes.flexContainer}> | ||
<ListItemText | ||
className={classes.itemText} | ||
primaryTypographyProps={{ variant: 'h6' }} | ||
primary={ | ||
<Link noTrack to={result.location}> | ||
{props.highlight?.fields.title ? ( | ||
<HighlightedSearchResultText | ||
text={props.highlight.fields.title} | ||
preTag={props.highlight.preTag} | ||
postTag={props.highlight.postTag} | ||
/> | ||
) : ( | ||
result.title | ||
)} | ||
</Link> | ||
} | ||
secondary={ | ||
props.highlight?.fields.text ? ( | ||
<HighlightedSearchResultText | ||
text={props.highlight.fields.text} | ||
preTag={props.highlight.preTag} | ||
postTag={props.highlight.postTag} | ||
/> | ||
) : ( | ||
result.text | ||
) | ||
} | ||
/> | ||
<Box> | ||
{result.labels?.map((tag: string) => ( | ||
<Chip label={tag} size="small" /> | ||
))} | ||
</Box> | ||
</div> | ||
</> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
...ugins/github-issues/src/components/GithubIssues/GithubIssuesSearchResultListItem/index.ts
This file contains 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 @@ | ||
export * from './GithubIssuesSearchResultListItem'; |
This file contains 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
1 change: 1 addition & 0 deletions
1
workspaces/github-issues/plugins/search-backend-module-github-issues/.eslintrc.js
This file contains 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 @@ | ||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); |
55 changes: 55 additions & 0 deletions
55
workspaces/github-issues/plugins/search-backend-module-github-issues/README.md
This file contains 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,55 @@ | ||
# @backstage-community/plugin-search-backend-module-github-issues | ||
|
||
This search module for GitHub indexes GitHub issues and makes them searchable inside your Backstage instance. This allows for better transparency and exposes your issues to a wider audience, facilitating better communication of help wanted for open-source projects within your organization. | ||
|
||
## Installation | ||
|
||
To configure the plugin using the new backend system: | ||
|
||
1. In the `packages/backend/src/index.ts` file, add the following: | ||
|
||
```typescript | ||
import { createBackend } from '@backstage/backend-defaults'; | ||
|
||
const backend = createBackend(); | ||
|
||
backend.add( | ||
import('@backstage-community/plugin-search-backend-module-github-issues'), | ||
); | ||
|
||
backend.start(); | ||
``` | ||
|
||
## Configuration | ||
|
||
### Environment Variables | ||
|
||
To configure the module, you need to set the following environment variables: | ||
|
||
- **`search.collators.github.org`** The organztion to which we make the search. | ||
- **`search.collators.github.query`** The actual query string used to make a search at the github api. Example: is:issue is:open org:backstage | ||
|
||
### GitHub Credentials | ||
|
||
#### Token | ||
|
||
**Important:** The GitHub token, which is necessary for authentication, should be managed within your Backstage integrations configuration. The token must be added to your GitHub integration settings, and the plugin will retrieve it through the `GithubCredentialsProvider`. | ||
|
||
Ensure that your GitHub integration in the Backstage configuration includes the necessary token for the `GithubCredentialsProvider` to work correctly. | ||
|
||
#### App | ||
|
||
You can also authenticate using your github app. [Read more here.](https://backstage.io/docs/integrations/github/github-apps) | ||
|
||
**Note**: If you're using the app method, you'll have to ensure that the org is inside the allowedInstallationOwners. | ||
|
||
### YAML Configuration Example | ||
|
||
```yaml | ||
search: | ||
collators: | ||
github: | ||
org: backstage | ||
host: github.com | ||
query: is:issue is:open org:backstage | ||
``` |
55 changes: 55 additions & 0 deletions
55
workspaces/github-issues/plugins/search-backend-module-github-issues/config.d.ts
This file contains 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,55 @@ | ||
/* | ||
* Copyright 2023 The Backstage Authors | ||
* | ||
* 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 { SchedulerServiceTaskScheduleDefinitionConfig } from '@backstage/backend-plugin-api'; | ||
|
||
export interface Config { | ||
search?: { | ||
collators?: { | ||
/** | ||
* Configuration options for `@community-plugins/search-backend-module-github` collator. | ||
*/ | ||
github?: { | ||
/** | ||
* The target that this provider should consume. | ||
* | ||
* @example "https://github.com/backstage" | ||
*/ | ||
org: string; | ||
/** | ||
* The host configuration for the GitHub instance to search. | ||
* | ||
* @default 'github.com' | ||
*/ | ||
host?: string; | ||
/** | ||
* The schedule for how often to run the collation job. | ||
* | ||
* @default { frequency: { minutes: 10 }, timeout: { minutes: 15 }, initialDelay: { seconds: 3 } } | ||
*/ | ||
schedule?: SchedulerServiceTaskScheduleDefinitionConfig; | ||
/** | ||
* Query to search for issues. For more information on the query syntax, see the GitHub documentation. | ||
* @see https://docs.github.com/en/github/searching-for-information-on-github/searching-issues-and-pull-requests | ||
* | ||
* @example 'is:issue is:open org:backstage' | ||
* | ||
*/ | ||
query: string; | ||
}; | ||
}; | ||
}; | ||
} |
45 changes: 45 additions & 0 deletions
45
workspaces/github-issues/plugins/search-backend-module-github-issues/package.json
This file contains 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 @@ | ||
{ | ||
"name": "@backstage-community/plugin-search-backend-module-github-issues", | ||
"description": "The github-issues backend module for the search plugin.", | ||
"version": "0.1.0", | ||
"main": "src/index.ts", | ||
"types": "src/index.ts", | ||
"license": "Apache-2.0", | ||
"publishConfig": { | ||
"access": "public", | ||
"main": "dist/index.cjs.js", | ||
"types": "dist/index.d.ts" | ||
}, | ||
"backstage": { | ||
"role": "backend-plugin-module" | ||
}, | ||
"scripts": { | ||
"start": "backstage-cli package start", | ||
"build": "backstage-cli package build", | ||
"lint": "backstage-cli package lint", | ||
"test": "backstage-cli package test", | ||
"clean": "backstage-cli package clean", | ||
"prepack": "backstage-cli package prepack", | ||
"postpack": "backstage-cli package postpack" | ||
}, | ||
"dependencies": { | ||
"@backstage/backend-plugin-api": "^1.0.0", | ||
"@backstage/config": "^1.2.0", | ||
"@backstage/integration": "^1.15.0", | ||
"@backstage/plugin-search-backend-node": "^1.3.2", | ||
"@backstage/plugin-search-common": "^1.2.14", | ||
"@octokit/graphql": "^5.0.0", | ||
"fetch-mock": "^11.1.5" | ||
}, | ||
"devDependencies": { | ||
"@backstage/backend-test-utils": "^1.0.0", | ||
"@backstage/cli": "^0.27.1", | ||
"@octokit/graphql-schema": "^15.25.0", | ||
"msw": "^1.0.0" | ||
}, | ||
"files": [ | ||
"config.d.ts", | ||
"dist" | ||
], | ||
"configSchema": "config.d.ts" | ||
} |
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.
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.
self review: example should be
backstage