Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

feat(git): make the provider chips real, selectable buttons

Juan Denis3f50db7a3494
diff --git a/frontend/src/components/git/GitProviders.jsx b/frontend/src/components/git/GitProviders.jsx
index cd329786..ff87805f 100644
--- a/frontend/src/components/git/GitProviders.jsx
+++ b/frontend/src/components/git/GitProviders.jsx
@@ -13,12 +13,14 @@ import { GitBranch } from 'lucide-react';
// Ordered list rendered in the provider strip. `match` recognizes a clone URL's
// host; the trailing "other" entry is the catch-all (self-hosted, SSH, anything
// unrecognized).
+// `oauth` marks hosts that support a one-click connection (a backend OAuth app);
+// `placeholder` is the URL hint shown when that provider is chosen.
export const GIT_PROVIDERS = [
- { key: 'github', label: 'GitHub', Icon: SiGithub, hint: 'HTTPS or SSH', match: /github\.com/i },
- { key: 'gitlab', label: 'GitLab', Icon: SiGitlab, hint: 'Cloud or self-managed', match: /gitlab\./i },
- { key: 'bitbucket', label: 'Bitbucket', Icon: SiBitbucket, hint: 'bitbucket.org', match: /bitbucket\.org/i },
- { key: 'gitea', label: 'Gitea', Icon: SiGitea, hint: 'Self-hosted', match: /gitea/i },
- { key: 'other', label: 'SSH / Other', Icon: GitBranch, hint: 'Any Git remote', match: null },
+ { key: 'github', label: 'GitHub', Icon: SiGithub, hint: 'One-click or URL', match: /github\.com/i, oauth: true, placeholder: 'https://github.com/user/repo.git' },
+ { key: 'gitlab', label: 'GitLab', Icon: SiGitlab, hint: 'Cloud or self-managed', match: /gitlab\./i, oauth: true, placeholder: 'https://gitlab.com/group/project.git' },
+ { key: 'bitbucket', label: 'Bitbucket', Icon: SiBitbucket, hint: 'Paste a URL', match: /bitbucket\.org/i, placeholder: 'https://bitbucket.org/user/repo.git' },
+ { key: 'gitea', label: 'Gitea', Icon: SiGitea, hint: 'Self-hosted', match: /gitea/i, placeholder: 'https://gitea.example.com/user/repo.git' },
+ { key: 'other', label: 'SSH / Other', Icon: GitBranch, hint: 'Any Git remote', match: null, placeholder: 'git@host:user/repo.git' },
];
const OTHER_PROVIDER = GIT_PROVIDERS[GIT_PROVIDERS.length - 1];
@@ -32,24 +34,47 @@ export function detectProvider(url) {
return GIT_PROVIDERS.find((p) => p.match && p.match.test(trimmed)) || OTHER_PROVIDER;
}
-// The "explains the others" strip: every supported host as a chip with its brand
-// mark, label, and a one-liner. The detected provider gets the accent highlight.
-export function RepoProviderStrip({ detected }) {
+// The provider strip: every supported host as a chip with its brand mark, label,
+// and one-liner. Static by default (just "explains the others"); pass `onSelect`
+// to make the chips REAL radio buttons that pick the connection method.
+export function RepoProviderStrip({ detected, selected, onSelect }) {
+ const interactive = typeof onSelect === 'function';
+ const activeKey = selected ?? detected;
return (
- <div className="git-connect__providers" role="list" aria-label="Supported Git providers">
- {GIT_PROVIDERS.map(({ key, label, Icon, hint }) => (
- <div
- key={key}
- role="listitem"
- className={`git-connect__provider${detected === key ? ' git-connect__provider--active' : ''}`}
- >
- <span className="git-connect__provider-icon">
- <Icon size={18} aria-hidden="true" />
- </span>
- <span className="git-connect__provider-label">{label}</span>
- <span className="git-connect__provider-hint">{hint}</span>
- </div>
- ))}
+ <div
+ className="git-connect__providers"
+ role={interactive ? 'radiogroup' : 'list'}
+ aria-label="Git providers"
+ >
+ {GIT_PROVIDERS.map(({ key, label, Icon, hint }) => {
+ const active = activeKey === key;
+ const className = `git-connect__provider${active ? ' git-connect__provider--active' : ''}${interactive ? ' git-connect__provider--btn' : ''}`;
+ const inner = (
+ <>
+ <span className="git-connect__provider-icon">
+ <Icon size={18} aria-hidden="true" />
+ </span>
+ <span className="git-connect__provider-label">{label}</span>
+ <span className="git-connect__provider-hint">{hint}</span>
+ </>
+ );
+ return interactive ? (
+ <button
+ type="button"
+ key={key}
+ className={className}
+ role="radio"
+ aria-checked={active}
+ onClick={() => onSelect(key)}
+ >
+ {inner}
+ </button>
+ ) : (
+ <div key={key} role="listitem" className={className}>
+ {inner}
+ </div>
+ );
+ })}
</div>
);
}
diff --git a/frontend/src/components/git/RepoConnectForm.jsx b/frontend/src/components/git/RepoConnectForm.jsx
index 74e5b4b1..3c654590 100644
--- a/frontend/src/components/git/RepoConnectForm.jsx
+++ b/frontend/src/components/git/RepoConnectForm.jsx
@@ -1,11 +1,11 @@
-import { useState } from 'react';
+import { useState, useEffect } from 'react';
import { GitBranch, Unlink } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Textarea } from '@/components/ui/textarea';
import { Switch } from '@/components/ui/switch';
-import { RepoProviderStrip, ProviderBadge, detectProvider } from './GitProviders';
+import { RepoProviderStrip, ProviderBadge, detectProvider, GIT_PROVIDERS } from './GitProviders';
import GithubRepoPicker from './GithubRepoPicker';
// Canonical "connect a repository" form, shared across ServerKit's surfaces
@@ -54,6 +54,15 @@ const RepoConnectForm = ({
const isConnected = gitStatus?.connected;
const provider = detectProvider(formData.repoUrl);
+ // Which provider chip is chosen — drives the connect method (GitHub shows the
+ // one-click picker; everyone else gets a paste-a-URL field). A recognized URL
+ // wins over a manual click.
+ const [selectedKey, setSelectedKey] = useState(enableGithub ? 'github' : 'other');
+ useEffect(() => {
+ if (provider?.key) setSelectedKey(provider.key);
+ }, [provider?.key]);
+ const selectedProvider = GIT_PROVIDERS.find((p) => p.key === selectedKey) || GIT_PROVIDERS[0];
+
function handleChange(e) {
const { name, value } = e.target;
setFormData((prev) => ({ ...prev, [name]: value }));
@@ -159,16 +168,16 @@ const RepoConnectForm = ({
</div>
</div>
- <RepoProviderStrip detected={provider?.key} />
+ <RepoProviderStrip detected={provider?.key} selected={selectedKey} onSelect={setSelectedKey} />
- {enableGithub && (
+ {enableGithub && selectedKey === 'github' && (
<>
<GithubRepoPicker
onPick={({ repoUrl, branch }) =>
setFormData((p) => ({ ...p, repoUrl, branch: branch || p.branch }))
}
/>
- <div className="git-connect__or"><span>or connect by URL</span></div>
+ <div className="git-connect__or"><span>or paste a URL</span></div>
</>
)}
@@ -182,7 +191,7 @@ const RepoConnectForm = ({
name="repoUrl"
value={formData.repoUrl}
onChange={handleChange}
- placeholder={urlPlaceholder}
+ placeholder={selectedProvider.placeholder || urlPlaceholder}
required
/>
{provider && <ProviderBadge provider={provider} />}
diff --git a/frontend/src/styles/components/_git-connect.scss b/frontend/src/styles/components/_git-connect.scss
index 94a3c5f4..bdfbcea4 100644
--- a/frontend/src/styles/components/_git-connect.scss
+++ b/frontend/src/styles/components/_git-connect.scss
@@ -76,6 +76,18 @@
border-color: var(--accent-dim);
background: var(--accent-bg);
}
+
+ // When `onSelect` is passed the chips render as <button>s — make them
+ // read and behave like real, clickable options.
+ &--btn {
+ font: inherit;
+ text-align: left;
+ cursor: pointer;
+ width: 100%;
+
+ &:hover { border-color: var(--border-strong); }
+ &:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 1px; }
+ }
}
&__provider-icon {