Skip to content

Commit 635ba3f

Browse files
committed
🔧 chore: pr feedback
1 parent 9ffdf0c commit 635ba3f

File tree

2 files changed

+50
-37
lines changed

2 files changed

+50
-37
lines changed

docs/organization/integrations/source-code-mgmt/github/index.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ There are two types of GitHub integrations, so make sure you're choosing the cor
1414
For these accounts, follow the '[Installing GitHub Enterprise](#installing-github-enterprise)' instructions.
1515

1616

17-
### To determine which integration to use, enter your GitHub domain below:
17+
### Check Your Domain
18+
19+
To determine which integration to use, enter your GitHub domain below:
1820

1921
<GitHubDomainChecker />
2022

src/components/githubDomainChecker.tsx

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@
22

33
import {useState} from 'react';
44

5-
const MAX_COMPONENTS_ON_PAGE = 100;
5+
interface GitHubDomainCheckerProps {
6+
id?: string;
7+
}
68

7-
export function GitHubDomainChecker() {
9+
export function GitHubDomainChecker({id}: GitHubDomainCheckerProps = {}) {
810
const [domain, setDomain] = useState('');
911
const [isValidDomain, setIsValidDomain] = useState(false);
10-
11-
const isGitHubCom =
12-
domain.toLowerCase().trim() === 'github.com' ||
13-
domain.toLowerCase().trim() === 'https://github.com';
12+
13+
// Updated to handle github.com URLs with paths (e.g., github.com/user)
14+
const isGitHubCom = (() => {
15+
const trimmedDomain = domain.toLowerCase().trim();
16+
if (!trimmedDomain) return false;
17+
18+
// Remove protocol if present
19+
const domainWithoutProtocol = trimmedDomain.replace(/^https?:\/\//, '');
20+
21+
// Check if it starts with github.com (with or without path)
22+
return domainWithoutProtocol.startsWith('github.com');
23+
})();
24+
1425
const hasInput = domain.trim().length > 0;
1526

1627
// Validate domain format
@@ -20,12 +31,9 @@ export function GitHubDomainChecker() {
2031
setIsValidDomain(false);
2132
return;
2233
}
23-
24-
// Check if it's github.com (valid)
25-
if (
26-
trimmedDomain.toLowerCase() === 'github.com' ||
27-
trimmedDomain.toLowerCase() === 'https://github.com'
28-
) {
34+
35+
// Check if it contains github.com (valid)
36+
if (trimmedDomain.toLowerCase().includes('github.com')) {
2937
setIsValidDomain(true);
3038
return;
3139
}
@@ -41,23 +49,24 @@ export function GitHubDomainChecker() {
4149
setDomain(newDomain);
4250
validateDomain(newDomain);
4351
};
44-
52+
53+
// Improved input styling with dark mode support
4554
const inputClassName =
46-
'form-input w-full rounded-md border-[1.5px] focus:ring-2 focus:ring-accent-purple/20 border-gray-200';
47-
48-
// This is to avoid in case multiple instances of this component are used on the page
49-
const randomCounter = Math.round(Math.random() * MAX_COMPONENTS_ON_PAGE);
55+
'form-input w-full rounded-md border-[1.5px] focus:ring-2 focus:ring-accent-purple/20 border-gray-200 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400';
56+
57+
// Use provided id or generate a fallback
58+
const inputId = id || `gh-domain-${Date.now()}`;
5059

5160
return (
52-
<div className="space-y-4 p-6 border border-gray-100 rounded">
61+
<div className="space-y-4 p-6 border border-gray-100 dark:border-gray-700 rounded">
5362
<div className="flex w-full">
5463
<div className="flex items-center min-w-[16ch] px-4">
55-
<label htmlFor={`gh-domain-${randomCounter}`} className="text-nowrap">
64+
<label htmlFor={inputId} className="text-nowrap">
5665
GitHub Domain
5766
</label>
5867
</div>
5968
<input
60-
id={`gh-domain-${randomCounter}`}
69+
id={inputId}
6170
value={domain}
6271
placeholder="https://github.com or https://ghe.example.com"
6372
className={inputClassName}
@@ -66,26 +75,28 @@ export function GitHubDomainChecker() {
6675
</div>
6776

6877
{hasInput && (
69-
<div className="mt-4 p-4 rounded-md border">
70-
<div className="text-sm font-medium mb-2">Recommended Installation:</div>
78+
<div className="mt-4 p-4 rounded-md border dark:border-gray-600">
7179
{isValidDomain ? (
72-
isGitHubCom ? (
73-
<div className="text-green-700 bg-green-50 p-3 rounded-md">
74-
<div className="mb-2">
75-
<strong>GitHub</strong> - Use the standard GitHub integration for
76-
github.com
77-
</div>
80+
<div>
81+
<div className="text-sm font-medium mb-2">
82+
Recommended Installation:
7883
</div>
79-
) : (
80-
<div className="text-blue-700 bg-blue-50 p-3 rounded-md">
81-
<div className="mb-2">
82-
<strong>GitHub Enterprise</strong> - Use GitHub Enterprise integration
83-
for your domain
84+
{isGitHubCom ? (
85+
<div className="text-green-700 bg-green-50 dark:text-green-300 dark:bg-green-900/30 p-3 rounded-md">
86+
<div className="mb-2">
87+
<strong>GitHub</strong> - Use the standard GitHub integration for github.com
88+
</div>
8489
</div>
85-
</div>
86-
)
90+
) : (
91+
<div className="text-blue-700 bg-blue-50 dark:text-blue-300 dark:bg-blue-900/30 p-3 rounded-md">
92+
<div className="mb-2">
93+
<strong>GitHub Enterprise</strong> - Use GitHub Enterprise integration for your domain
94+
</div>
95+
</div>
96+
)}
97+
</div>
8798
) : (
88-
<div className="text-red-700 bg-red-50 p-3 rounded-md">
99+
<div className="text-red-700 bg-red-50 dark:text-red-300 dark:bg-red-900/30 p-3 rounded-md">
89100
<strong>Invalid Domain</strong> - Please enter a valid GitHub domain or URL
90101
</div>
91102
)}

0 commit comments

Comments
 (0)