-
Notifications
You must be signed in to change notification settings - Fork 71
feat: github app can be created on organization and can be made public #677
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,17 @@ | ||
|
|
||
| import { useContext } from "preact/hooks"; | ||
| import * as stores from "../stores"; | ||
| import { NavLink } from "react-router-dom"; | ||
|
|
||
| interface IntegrationStarterProps { | ||
| connectButtonUrl: string; | ||
| } | ||
| export const IntegrationStarter = (props: IntegrationStarterProps) => { | ||
| const config = useContext(stores.Config.Context); | ||
| const submitManifest = (e: Event) => { | ||
| e.preventDefault(); | ||
|
|
||
| const urlWithToken = new URL(props.connectButtonUrl); | ||
| urlWithToken.searchParams.append(`org_id`, config.orgId); | ||
|
|
||
| window.location.href = urlWithToken.toString(); | ||
| }; | ||
|
|
||
| export const IntegrationStarter = (_props: IntegrationStarterProps) => { | ||
| return ( | ||
| <form | ||
| className="d-flex flex-items-center" | ||
| onSubmit={submitManifest} | ||
| method="post" | ||
| <NavLink | ||
| className="btn btn-primary btn-small" | ||
| to="/github_app/setup" | ||
| > | ||
| <button | ||
| className="btn btn-primary btn-small" | ||
| > | ||
| Connect | ||
| </button> | ||
| </form> | ||
| Connect | ||
| </NavLink> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| import { useContext, useState } from "preact/hooks"; | ||
| import { NavLink } from "react-router-dom"; | ||
| import * as stores from "../stores"; | ||
|
|
||
| export const GithubAppSetup = () => { | ||
| const config = useContext(stores.Config.Context); | ||
| const [accountType, setAccountType] = useState<"personal" | "organization">("personal"); | ||
| const [isPublic, setIsPublic] = useState(false); | ||
| const [organizationName, setOrganizationName] = useState(""); | ||
|
|
||
| const githubAppIntegration = config.newIntegrations?.find( | ||
| (integration) => integration.type === "github_app" | ||
| ); | ||
|
|
||
| if (!githubAppIntegration) { | ||
| return ( | ||
| <div> | ||
| <NavLink className="gray link f6 mb2 dib" to="/"> | ||
| ← Back to Integrations | ||
| </NavLink> | ||
| <p>GitHub App integration not available</p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| const submitManifest = (e: Event) => { | ||
| e.preventDefault(); | ||
|
|
||
| const urlWithToken = new URL(githubAppIntegration.connectUrl); | ||
| urlWithToken.searchParams.append(`org_id`, config.orgId); | ||
| urlWithToken.searchParams.append(`is_public`, isPublic ? "true" : "false"); | ||
|
|
||
| if (accountType === "organization" && organizationName.trim()) { | ||
| urlWithToken.searchParams.append(`organization`, organizationName.trim()); | ||
| } | ||
|
Comment on lines
+33
to
+35
|
||
|
|
||
| window.location.href = urlWithToken.toString(); | ||
| }; | ||
|
|
||
| return ( | ||
| <div> | ||
| <NavLink className="gray link f6 mb2 dib" to="/"> | ||
| ← Back to Integrations | ||
| </NavLink> | ||
| <h2 className="f3 f2-m mb0">GitHub App</h2> | ||
| <p className="measure"> | ||
| GitHub Cloud integration through installed GitHub App. | ||
| </p> | ||
|
|
||
| <div className="pv3 bt b--lighter-gray"> | ||
| <div className="mb1"> | ||
| <label className="b mr1">Setup Configuration</label> | ||
| </div> | ||
| <p className="mb3"> | ||
| Choose where to create the GitHub App and configure its visibility settings. | ||
| </p> | ||
|
|
||
| <form onSubmit={submitManifest}> | ||
| <div className="mv3 br3 shadow-3 bg-white pa3 bb b--black-075"> | ||
| <div className="flex items-center mb2 pb3 bb bw1 b--black-075"> | ||
| <span className="material-symbols-outlined mr2">settings</span> | ||
| <span className="b f5">GitHub App Configuration</span> | ||
| </div> | ||
|
|
||
| <div className="mb3"> | ||
| <label className="b db mb2">Account Type</label> | ||
| <div className="mb2"> | ||
| <label className="flex items-center pointer"> | ||
| <input | ||
| type="radio" | ||
| name="accountType" | ||
| value="personal" | ||
| checked={accountType === "personal"} | ||
| onChange={() => setAccountType("personal")} | ||
| className="mr2" | ||
| /> | ||
| <span>Personal Account</span> | ||
| </label> | ||
| </div> | ||
| <div className="mb2"> | ||
| <label className="flex items-center pointer"> | ||
| <input | ||
| type="radio" | ||
| name="accountType" | ||
| value="organization" | ||
| checked={accountType === "organization"} | ||
| onChange={() => setAccountType("organization")} | ||
| className="mr2" | ||
| /> | ||
| <span>Organization Account</span> | ||
| </label> | ||
| </div> | ||
|
|
||
| {accountType === "organization" && ( | ||
| <div className="mt3"> | ||
| <label className="db mb2" htmlFor="organizationName"> | ||
| Organization Name | ||
| </label> | ||
| <input | ||
| id="organizationName" | ||
| type="text" | ||
| value={organizationName} | ||
| onChange={(e) => setOrganizationName((e.target as HTMLInputElement).value)} | ||
| placeholder="e.g., my-company" | ||
| className="form-control w-100" | ||
| required | ||
| /> | ||
| <p className="f6 gray mt2 mb0"> | ||
| The exact name of your GitHub organization | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please extend this line with info that you need to be an admin on this organization. |
||
| </p> | ||
| </div> | ||
| )} | ||
| </div> | ||
|
|
||
| <div className="mb3 pt3 bt b--black-075"> | ||
| <label className="b db mb2">App Visibility</label> | ||
| <label className="flex items-start pointer"> | ||
| <input | ||
| type="checkbox" | ||
| checked={isPublic} | ||
| onChange={(e) => setIsPublic((e.target as HTMLInputElement).checked)} | ||
| className="mr2 mt1" | ||
| /> | ||
| <div> | ||
| <span className="db mb1">Make app public</span> | ||
| <span className="f6 gray db"> | ||
| {isPublic | ||
| ? "Public apps can be installed by anyone and may appear in GitHub's marketplace." | ||
| : `Private apps only work with ${ | ||
| accountType === "organization" ? "the specified organization" : "your personal account" | ||
| }. They cannot be installed elsewhere.`} | ||
| </span> | ||
| </div> | ||
| </label> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="mt3"> | ||
| <button type="submit" className="btn btn-primary"> | ||
| Continue to GitHub | ||
| </button> | ||
| <NavLink to="/" className="ml3 link gray"> | ||
| Cancel | ||
| </NavLink> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import { IntegrationPage } from './integration_page'; | ||
| import { HomePage } from './home_page'; | ||
| import { GithubAppSetup } from './github_app_setup'; | ||
|
|
||
| export { | ||
| HomePage, | ||
| IntegrationPage | ||
| IntegrationPage, | ||
| GithubAppSetup | ||
| }; |
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
connectButtonUrlprop is no longer used but remains in the interface. Consider removing it fromIntegrationStarterPropssince the component now navigates to a hardcoded route instead of using the provided URL.