-
Notifications
You must be signed in to change notification settings - Fork 3
DEVELOP-780 Add dashboard panel contribution #16
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
2 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
| @@ -1,16 +1,17 @@ | ||
| import { AuthProvider } from "@aha-app/aha-develop-react"; | ||
| import React from "react"; | ||
| import Styles from "./components/Styles"; | ||
| import { Page } from "./components/page/Page"; | ||
| import { Styles } from "./Styles"; | ||
|
|
||
| aha.on("prs", (_, { settings }) => { | ||
| const repos = settings.repos || []; | ||
| /** | ||
| * Set up the styles and auth provider | ||
| */ | ||
| export const ExtensionRoot = ({ children }) => { | ||
| return ( | ||
| <> | ||
| <Styles /> | ||
| <AuthProvider serviceName="github" serviceParameters={{ scope: "repo" }}> | ||
| <Page repos={repos} /> | ||
| {children} | ||
| </AuthProvider> | ||
| </> | ||
| ); | ||
| }); | ||
| }; | ||
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,70 @@ | ||
| import React from "react"; | ||
| import { PrTable } from "../components/page/PrTable"; | ||
| import { searchForPr } from "../lib/github"; | ||
| import GithubQuery from "../lib/query"; | ||
| import { useGithubApi } from "../lib/useGithubApi"; | ||
|
|
||
| export const PrPanel: React.FC<{ | ||
| filter: string; | ||
| repos: string[]; | ||
| }> = ({ filter, repos }) => { | ||
| const query = [ | ||
| new GithubQuery() | ||
| .repo(...repos, { quote: true }) | ||
| .is("pr") | ||
| .toQuery(), | ||
| filter, | ||
| ] | ||
| .filter(Boolean) | ||
| .join(" "); | ||
|
|
||
| const { authed, error, loading, data, fetchData } = useGithubApi( | ||
| async (api) => { | ||
| const { edges } = await searchForPr(api, { | ||
| query, | ||
| includeStatus: true, | ||
| includeReviews: true, | ||
| count: 10, | ||
| }); | ||
| return edges.map((e) => e.node); | ||
| }, | ||
| {}, | ||
| [query] | ||
| ); | ||
|
|
||
| if (!authed || error) { | ||
| return ( | ||
| <div className="page-content empty-state"> | ||
| <div | ||
| className="empty-state__content" | ||
| style={{ textAlign: "center", paddingTop: 50 }} | ||
| > | ||
| <p>Authenticate with GitHub to get started.</p> | ||
| <aha-button type="primary" onClick={() => fetchData()}> | ||
| Authenticate with GitHub | ||
| </aha-button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| if (loading || !data) { | ||
| return ( | ||
| <div className="page-content empty-state"> | ||
| <div className="empty-state__content"> | ||
| <div | ||
| style={{ | ||
| fontSize: 36, | ||
| justifyContent: "center", | ||
| alignItems: "center", | ||
| }} | ||
| > | ||
| <aha-spinner /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return <PrTable prs={data} />; | ||
| }; |
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
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 @@ | ||
| export const IDENTIFIER = "aha-develop.github"; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| const refNumMatcher = /([A-Z][A-Z0-9]*-(([E]|[0-9]+)-)?[0-9]+)/; | ||
|
|
||
| /** | ||
| * Given a list of PRs, load the corresponding features if they exist | ||
| * | ||
| * @param {import('./github').PrForLink[]} prs | ||
| */ | ||
| export async function loadRelatedFeatures(prs) { | ||
| const refNums = []; | ||
| const prsByRefNum = {}; | ||
|
|
||
| for (let pr of prs) { | ||
| [pr.headRef?.name.toUpperCase(), pr.title] | ||
| .map(String) | ||
| .map((s) => refNumMatcher.exec(s)) | ||
| .forEach((match) => { | ||
| if (match) { | ||
| refNums.push(match[0]); | ||
| prsByRefNum[match[0]] = pr; | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| if (refNums.length === 0) { | ||
| // No records to find | ||
| return {}; | ||
| } | ||
|
|
||
| const features = await aha.models.Feature.select( | ||
| "id", | ||
| "referenceNum", | ||
| "name", | ||
| "path" | ||
| ) | ||
| .where({ | ||
| id: refNums, | ||
| }) | ||
| .all(); | ||
|
|
||
| /** @type {{[index:string]: Aha.Feature}} */ | ||
| const prRecords = {}; | ||
|
|
||
| for (let feature of features) { | ||
| const pr = prsByRefNum[feature.referenceNum]; | ||
| if (!pr) continue; | ||
| prRecords[pr.number] = feature; | ||
| } | ||
|
|
||
| return prRecords; | ||
| } |
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.
git has picked this up as a file rename, but actually this file moved to src/views/prsPage.js and the ExtensionRoot is an extraction from all the react entry points.