-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jira-admin-check-ff-remove
- Loading branch information
Showing
45 changed files
with
1,740 additions
and
1,222 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1 @@ | ||
14.21.1 | ||
18.18.1 |
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
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
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
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
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 |
---|---|---|
|
@@ -4,6 +4,6 @@ | |
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
"setupFilesAfterEnv": [ | ||
"@testing-library/jest-dom/extend-expect" | ||
"./setup.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
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 @@ | ||
import "@testing-library/jest-dom"; |
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
47 changes: 47 additions & 0 deletions
47
spa/src/pages/DeferredInstallation/DefaultState/forbidden.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,47 @@ | ||
/** @jsxImportSource @emotion/react */ | ||
import Step from "../../../components/Step"; | ||
import { css } from "@emotion/react"; | ||
import { token } from "@atlaskit/tokens"; | ||
import { popup } from "../../../utils"; | ||
import analyticsClient from "../../../analytics"; | ||
|
||
const paragraphStyle = css` | ||
color: ${token("color.text.subtle")}; | ||
margin: ${token("space.0")}; | ||
`; | ||
const noAdminDivStyle = css` | ||
margin-top: ${token("space.200")}; | ||
`; | ||
const linkStyle = css` | ||
cursor: pointer; | ||
padding-left: 0; | ||
padding-right: 0; | ||
`; | ||
|
||
const ForbiddenState = ({ orgName, requestId } : { orgName: string; requestId: string; }) => { | ||
const getOrgOwnerUrl = async () => { | ||
// TODO: Need to get this URL for Enterprise users too, this is only for Cloud users | ||
popup(`https://github.com/orgs/${orgName}/people?query=role%3Aowner`); | ||
analyticsClient.sendUIEvent({ actionSubject: "checkOrgAdmin", action: "clicked"}, { type: "cloud", from: "DeferredInstallationFailedScreen" }, requestId); | ||
}; | ||
|
||
return ( | ||
<Step title="Can’t connect this organization because you don’t have owner permissions"> | ||
<div css={noAdminDivStyle}> | ||
<p css={paragraphStyle}> | ||
The GitHub account you’ve used doesn’t have owner permissions | ||
for organization {orgName}. | ||
</p> | ||
<br/> | ||
<p css={paragraphStyle}> | ||
Let the person who sent you the request know to{" "} | ||
<a css={linkStyle} onClick={getOrgOwnerUrl}> | ||
find an owner for that organization. | ||
</a> | ||
</p> | ||
</div> | ||
</Step> | ||
); | ||
}; | ||
|
||
export default ForbiddenState; |
135 changes: 135 additions & 0 deletions
135
spa/src/pages/DeferredInstallation/DefaultState/index.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,135 @@ | ||
/** @jsxImportSource @emotion/react */ | ||
import { Box, xcss } from "@atlaskit/primitives"; | ||
import InfoIcon from "@atlaskit/icon/glyph/info"; | ||
import Button from "@atlaskit/button"; | ||
import { css } from "@emotion/react"; | ||
import { token } from "@atlaskit/tokens"; | ||
import Step from "../../../components/Step"; | ||
import { useEffect, useState } from "react"; | ||
import { AxiosError } from "axios"; | ||
import OAuthManager from "../../../services/oauth-manager"; | ||
import DeferralManager from "../../../services/deferral-manager"; | ||
import analyticsClient from "../../../analytics"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { StateCallbacksForDefaultDeferredState } from "rest-interfaces"; | ||
|
||
const boxStyles = xcss({ | ||
borderBlockWidth: token("space.500"), | ||
borderStyle: "solid", | ||
borderColor: "color.border", | ||
borderRadius: "border.radius.050", | ||
borderWidth: "border.width", | ||
marginTop: token("space.200"), | ||
marginBottom: token("space.200"), | ||
display: "flex", | ||
alignItems: "center", | ||
}); | ||
const paragraphStyle = css` | ||
color: ${token("color.text.subtle")}; | ||
margin: ${token("space.0")}; | ||
`; | ||
const infoParaStyle = css` | ||
padding-left: 16px; | ||
`; | ||
|
||
const DefaultState = ({ | ||
orgName, | ||
jiraHost, | ||
requestId, | ||
callbacks, | ||
}: { | ||
orgName: string; | ||
jiraHost: string; | ||
requestId: string; | ||
callbacks: StateCallbacksForDefaultDeferredState; | ||
}) => { | ||
const navigate = useNavigate(); | ||
const { setIsLoading, setForbidden, onPopupBlocked } = callbacks; | ||
const [isLoggedIn, setIsLoggedIn] = useState(false); | ||
|
||
// Finish the OAuth dance if authenticated | ||
useEffect(() => { | ||
const handler = async (event: MessageEvent) => { | ||
if (event.data?.type === "oauth-callback" && event.data?.code) { | ||
const response: boolean | AxiosError = await OAuthManager.finishOAuthFlow(event.data?.code, event.data?.state); | ||
setIsLoading(false); | ||
if (response instanceof AxiosError) { | ||
return; | ||
} | ||
setIsLoggedIn(true); | ||
} | ||
}; | ||
window.addEventListener("message", handler); | ||
return () => { | ||
window.removeEventListener("message", handler); | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
// Start the deferral connection if authenticated | ||
useEffect(() => { | ||
const connectDeferredOrgOrg = async () => { | ||
if (requestId) { | ||
setIsLoading(true); | ||
const status: boolean | AxiosError = await DeferralManager.connectOrgByDeferral(requestId); | ||
if (status instanceof AxiosError) { | ||
setForbidden(true); | ||
analyticsClient.sendScreenEvent({ name: "DeferredInstallationFailedScreen" }, { type: "cloud" }, requestId); | ||
} | ||
else if (status) { | ||
setForbidden(false); | ||
navigate("/spa/connected", { state: { orgLogin: orgName, requestId } }); | ||
} else { | ||
setForbidden(true); | ||
} | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
isLoggedIn && connectDeferredOrgOrg(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [ isLoggedIn ]); | ||
|
||
// Authenticate if no token/username is set | ||
const authenticate = async () => { | ||
setIsLoading(true); | ||
try { | ||
analyticsClient.sendUIEvent({ actionSubject: "signInAndConnectThroughDeferredInstallationStartScreen", action: "clicked"}, { type: "cloud" }, requestId); | ||
await OAuthManager.authenticateInGitHub({ | ||
onWinClosed: () => { | ||
setIsLoading(false); | ||
}, onPopupBlocked | ||
}); | ||
} catch (e) { | ||
// TODO: print alert error | ||
console.error("check error", e); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<Step | ||
title={`Connect GitHub organization ${orgName} to Jira Software`} | ||
> | ||
<> | ||
<p css={paragraphStyle}> | ||
A Jira administrator has asked for approval to connect the | ||
GitHub organization {orgName} to the Jira site {jiraHost}. | ||
</p> | ||
<Box padding="space.200" xcss={boxStyles}> | ||
<InfoIcon label="differed-installation-info" size="small"/> | ||
<p css={[paragraphStyle, infoParaStyle]}> | ||
This will make all repositories in {orgName} available to all projects in {jiraHost}. Import work from those | ||
GitHub repositories into Jira. | ||
</p> | ||
</Box> | ||
<Button appearance="primary" onClick={authenticate}> | ||
Sign in & connect | ||
</Button> | ||
</> | ||
</Step> | ||
); | ||
}; | ||
|
||
export default DefaultState; |
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,15 @@ | ||
import { ErrorObjType } from "../../../utils/modifyError"; | ||
import ErrorUI from "../../../components/Error"; | ||
import Step from "../../../components/Step"; | ||
|
||
const ErrorState = ({ error }: { error: ErrorObjType}) => <> | ||
<ErrorUI type={error.type} message={error.message} /> | ||
<Step title="Connect a GitHub organization to Jira software"> | ||
<div> | ||
Please inform the person who sent you the link that the link <br/> | ||
has expired and send a new link. | ||
</div> | ||
</Step> | ||
</>; | ||
|
||
export default ErrorState; |
Oops, something went wrong.