Skip to content
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

ARC-916 - GHE UI: Connect GitHub Enterprise Server page #1252

Merged
merged 23 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
77d7de6
- New View for Connecting to GHE Server added
krazziekay Jun 9, 2022
91e983e
- Code cleanup
krazziekay Jun 9, 2022
789fed6
Merge branch 'main' of github.com:atlassian/github-for-jira into ARC-916
krazziekay Jun 9, 2022
5e68643
- Minor correction
krazziekay Jun 9, 2022
1c68dae
- Trailing slashes removed
krazziekay Jun 9, 2022
4abde4b
- Trailing slashes removed
krazziekay Jun 9, 2022
a1797f4
- some replaced by includes for protocal check
krazziekay Jun 9, 2022
21077b6
- Hostname check fixes
krazziekay Jun 9, 2022
0ebc93c
Review changes
krazziekay Jun 10, 2022
8593640
Merge branch 'main' into ARC-916
krazziekay Jun 10, 2022
e1bccdd
- Text changes
krazziekay Jun 10, 2022
d7bde2e
Merge branch 'ARC-916' of github.com:atlassian/github-for-jira into A…
krazziekay Jun 10, 2022
087eaa5
Merge branch 'main' into ARC-916
krazziekay Jun 10, 2022
fe795be
- Review changes
krazziekay Jun 10, 2022
af36155
Merge branch 'main' into ARC-916
krazziekay Jun 13, 2022
8fe5938
- Removed white spaces
krazziekay Jun 14, 2022
7cd4d80
- minor correction
krazziekay Jun 14, 2022
1c0ad71
Merge branch 'main' into ARC-916
krazziekay Jun 14, 2022
738b10d
- Minor increment in the font sizes and margins
krazziekay Jun 14, 2022
491cf4a
Merge remote-tracking branch 'origin/ARC-916' into ARC-916
krazziekay Jun 14, 2022
0c01ae7
- Minor increment in the font sizes and margins
krazziekay Jun 14, 2022
f87d564
Merge branch 'main' into ARC-916
krazziekay Jun 14, 2022
281c21b
Merge branch 'main' into ARC-916
krazziekay Jun 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions static/css/jira-connect-ghe.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.jiraConnectGHE__content {
margin: 4em auto 0;
max-width: 508px;
}
.jiraConnectGHE__content__title {
text-align: center;
margin-bottom: 2em;
}

.jiraConnectGHE__options__subTitle {
font-size: 1rem;
margin-bottom: 0.5em;
display: inline-flex;
}

.jiraConnectGHE__prompt {
color: #344563;
font-size: 0.9rem;
margin-bottom: 1em;
}

.jiraConnectGHE__error {
display: none;
color: #DE350B;
font-size: 0.8rem;
margin-top: 0.125em;
}

.jiraConnectGHE__label {
font-size: 0.8rem;
font-weight: 600;
color: #6B778C;
}

.jiraConnectGHE__input {
width: 100%;
border: 2px solid #DFE1E6;
border-radius: 3px;
background: #FAFBFC;
padding: 0.625em 0.5em;
}

.has-error {
border-color: #DE350B;
}

.jiraConnectGHE__actionBtn__container {
margin-top: 1.25em;
text-align: right;
}

#gheServerBtnSpinner {
display: none;
color: #fff;
}
65 changes: 65 additions & 0 deletions static/js/jira-connect-ghe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const ALLOWED_PROTOCOLS = ["http:", "https:"];
krazziekay marked this conversation as resolved.
Show resolved Hide resolved
const GITHUB_CLOUD = ["github.com", "www.github.com"];
krazziekay marked this conversation as resolved.
Show resolved Hide resolved

/**
* Method that checks the validity of the passed URL
*
* @param {string} inputURL
* @returns {boolean}
*/
const checkValidGHEUrl = inputURL => {
try {
krazziekay marked this conversation as resolved.
Show resolved Hide resolved
const { protocol, hostname } = new URL(inputURL);

if (!ALLOWED_PROTOCOLS.includes(protocol)) {
return false;
}
// This checks whether the hostname whether there is an extension like `.com`, `.net` etc.
if (hostname.split('.').length < 2) {
krazziekay marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
if (GITHUB_CLOUD.includes(hostname)) {
// TODO: Need to alert the users that this URL is GitHub cloud and not Enterprise
// Waiting for design: https://softwareteams.atlassian.net/browse/ARC-1418
return false;
krazziekay marked this conversation as resolved.
Show resolved Hide resolved
}

return true;
} catch (e) {
return false;
}
};

$("#gheServerURL").on("keyup", event => {
krazziekay marked this conversation as resolved.
Show resolved Hide resolved
const hasUrl = event.target.value.length > 0;
$("#gheServerBtn").attr({
"aria-disabled": !hasUrl,
"disabled": !hasUrl
});
$("#gheServerURLError").hide();
$("#gheServerURL").removeClass("has-error");
});

$("#gheServerBtn").on("click", event => {
const btn = event.target;
const typedURL = $("#gheServerURL").val().replace(/\/+$/, '');
const isValid = checkValidGHEUrl(typedURL);

$(btn).attr({
"aria-disabled": !isValid,
"disabled": !isValid
});

if (isValid) {
$("#gheServerURLError").hide();
$("#gheServerBtnText").hide();
$("#gheServerBtnSpinner").show();
$("#gheServerURL").removeClass("has-error");

// TODO: Need to add the action
console.log("Data for API: ", typedURL);
} else {
$("#gheServerURLError").show();
$("#gheServerURL").addClass("has-error");
}
});
103 changes: 103 additions & 0 deletions views/jira-connect-ghe.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="ap-local-base-url" content="{{localBaseUrl}}" />
<meta name="public-url" content="{{APP_URL}}" />
<title>{{title}}</title>
<link
href="/public/aui/aui-prototyping.css"
rel="stylesheet"
integrity="DTM1Q+8lU7SzJT+FWr0JFisCSZlwfM0GiAKYy7h1s9vIKa/CIh37s9NuOCqIOgK4tmqrjLK4NuWuIPUQNsikHA=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="/public/css-reset/bundle.css" media="all" />
<link
rel="stylesheet"
href="/public/atlassian-ui-kit/bundle.css"
media="all"
/>
<link rel="stylesheet" href="/public/css/global.css" media="all" />
<link
rel="stylesheet"
href="/public/css/jira-connect-ghe.css"
media="all"
/>
<script src="/public/js/jquery.min.js" nonce="{{nonce}}"></script>
</head>

<body class="aui-page-hybrid">
<div class="jiraConnectGHE">
<header class="jiraConnectGHE__header">
{{> navigation previousPageName="Select GitHub Version" }}
</header>

<section class="jiraConnectGHE__content">
<div class="headerImage">
<img
src="/public/assets/jira-and-github.png"
alt="Jira and GitHub logos"
/>
</div>
<h2 class="jiraConnectGHE__content__title">GitHub Enterprise Server</h2>

<div class="jiraConnectGHE__prompt">
Connecting GitHub Enterprise Server to Jira requires opening a hole in your firewall,
as Atlassian’s IP addresses must be able to call your GitHub Enterprise Server.
<!--TODO: Add a link here-->
<a href="" target="_blank">Learn more.</a>
</div>

<div>
<h3 class="jiraConnectGHE__options__subTitle">
GitHub Enterprise Server URL&nbsp;
<!--TODO: Add a tooltip for this icon-->
krazziekay marked this conversation as resolved.
Show resolved Hide resolved
<i class="aui-icon aui-iconfont-question-filled"></i>
</h3>
<div class="jiraConnectGHE__prompt">
Enter the URL for the server of the GitHub Enterprise organization that you want to connect. This is unique to your server.
</div>
<div>
<label class="jiraConnectGHE__label" for="gheServerURL">Server URL</label>
<input type="text" class="jiraConnectGHE__input" id="gheServerURL" placeholder="https://example.com" />
<div class="jiraConnectGHE__error" id="gheServerURLError">
<i class="aui-icon aui-iconfont-error"></i>
The entered URL is not valid.
<!--TODO: Add a link here-->
<a href="" target="_blank">Learn more.</a>
</div>
</div>

<div class="jiraConnectGHE__actionBtn__container">
<button
id="gheServerBtn"
class="aui-button aui-button-primary"
aria-disabled="true"
disabled
>
<span id="gheServerBtnText">Next</span>
<aui-spinner id="gheServerBtnSpinner" size="small"></aui-spinner>
</button>

</div>
</div>
</section>

</div>

<script src="/public/js/jira-connect-ghe.js" nonce="{{nonce}}"></script>
<!-- Per https://blog.developer.atlassian.com/announcement-reminder-about-deprecation-of-xdm_e-usage-and-needing-to-load-all-js-from-the-cdn/ we are required to load this from this specific CDN -->
<!-- DO NOT TOUCH!!! THIS IS NEEDED FOR CONNECT OR ELSE IT WILL CAUSE AN ERROR -->
<script
src="https://connect-cdn.atl-paas.net/all.js"
nonce="{{nonce}}"
></script>
<script
src="/public/aui/aui-prototyping.js"
crossorigin="anonymous"
referrerpolicy="no-referrer"
nonce="{{nonce}}"
></script>
</body>
</html>