feat(versionManagment): fork vs official upstream rows and layout refresh

- views: remote_display, branch_ref, fork_remote_commit, upstream_commit,
  short SHAs, GitHub commit URLs, notecheck_compare_remote, local_behind_official
- template: installation grid, full-width meta rows, i18n upgrade note,
  info notice when local differs from official upstream on dev
This commit is contained in:
master3395
2026-03-27 22:08:45 +01:00
parent 227608aaa3
commit c950fbc4ab
2 changed files with 183 additions and 13 deletions

View File

@@ -165,6 +165,72 @@
font-weight: 600;
}
.alert-info {
background: var(--bg-hover, #eef0ff);
border: 1px solid var(--border-color, #c7c9f0);
color: var(--text-primary, #2f3640);
}
.alert-info a {
color: var(--accent-color, #5b5fcf);
font-weight: 600;
}
.version-section {
margin-top: 20px;
margin-bottom: 10px;
font-size: 14px;
font-weight: 700;
color: var(--text-primary, #2f3640);
}
.version-section:first-of-type {
margin-top: 0;
}
.version-meta-row {
display: flex;
flex-direction: column;
gap: 8px;
width: 100%;
margin-bottom: 14px;
padding: 12px 14px;
border-radius: 8px;
border: 1px solid var(--border-color, #e8e9ff);
background: var(--bg-hover, #f8f9ff);
}
.version-meta-row-label {
font-size: 12px;
font-weight: 600;
color: var(--text-secondary, #8893a7);
text-transform: uppercase;
letter-spacing: 0.5px;
}
.version-meta-row-value {
font-size: 14px;
color: var(--text-primary, #2f3640);
word-break: break-word;
line-height: 1.5;
}
.version-meta-row-value code,
.version-sha {
font-family: 'SF Mono', Monaco, monospace;
font-size: 13px;
background: var(--bg-secondary, white);
padding: 2px 8px;
border-radius: 4px;
border: 1px solid var(--border-color, #e8e9ff);
}
.version-meta-row-value a {
font-weight: 600;
color: var(--accent-color, #5b5fcf);
margin-left: 4px;
}
/* Info grid */
.info-grid {
display: grid;
@@ -269,7 +335,16 @@
{% if Notecheck %}
<div class="alert alert-warning">
<i class="fas fa-exclamation-triangle"></i>
<span>{% trans "Note: Latest commit does not match, please upgrade CyberPanel." %} <a href="https://cyberpanel.net/KnowledgeBase/home/upgrading-cyberpanel/">Learn how to upgrade CyberPanel.</a></span>
<span>
{% blocktrans with cmp=notecheck_compare_remote %}Note: The current commit does not match the latest commit on {{ cmp }}. Please upgrade CyberPanel.{% endblocktrans %}
<a href="https://cyberpanel.net/KnowledgeBase/home/upgrading-cyberpanel/" target="_blank" rel="noopener noreferrer">{% trans "Learn how to upgrade CyberPanel." %}</a>
</span>
</div>
{% endif %}
{% if local_behind_official and not Notecheck %}
<div class="alert alert-info">
<i class="fas fa-info-circle"></i>
<span>{% trans "Your commit differs from the latest on the official CyberPanel repository (usmannasir/cyberpanel). This is informational if you intentionally track a fork." %}</span>
</div>
{% endif %}
@@ -294,8 +369,9 @@
</div>
<div class="content-card">
<h2 class="card-title">Version Information</h2>
<h2 class="card-title">{% trans "Version Information" %}</h2>
<p class="version-section">{% trans "This installation" %}</p>
<div class="info-grid">
<div class="info-item">
<span class="info-label">{% trans "Current Version" %}</span>
@@ -306,22 +382,65 @@
<span class="info-value">{{ build }}</span>
</div>
<div class="info-item">
<span class="info-label">{% trans "Current Commit" %}</span>
<span class="info-value">{{ Currentcomt }}</span>
<span class="info-label">{% trans "Current commit" %}</span>
<span class="info-value" title="{{ Currentcomt }}">
{% if Currentcomt_short %}<code class="version-sha">{{ Currentcomt_short }}</code>{% else %}—{% endif %}
</span>
</div>
<div class="info-item">
<span class="info-label">{% trans "Latest Version" %}</span>
<span class="info-label">{% trans "Published latest version" %}</span>
<span class="info-value">{{ latestVersion }}</span>
</div>
<div class="info-item">
<span class="info-label">{% trans "Latest Build" %}</span>
<span class="info-label">{% trans "Published latest build" %}</span>
<span class="info-value">{{ latestBuild }}</span>
</div>
<div class="info-item">
<span class="info-label">{% trans "Latest Commit" %}</span>
<span class="info-value">{{ latestcomit }}</span>
</div>
</div>
<p class="version-section">{% trans "Git remotes and branch tips" %}</p>
<div class="version-meta-row">
<span class="version-meta-row-label">{% trans "Origin (git remote)" %}</span>
<span class="version-meta-row-value">{{ remote_display|default:"—" }}</span>
</div>
<div class="version-meta-row">
<span class="version-meta-row-label">{% trans "Tracking branch" %}</span>
<span class="version-meta-row-value"><code class="version-sha">{{ branch_ref }}</code></span>
</div>
{% if fork_remote_commit %}
<div class="version-meta-row">
<span class="version-meta-row-label">{% trans "Your fork — latest on GitHub" %}</span>
<span class="version-meta-row-value">
<code class="version-sha" title="{{ fork_remote_commit }}">{{ fork_remote_commit_short }}</code>
{% if fork_commit_url %}
<a href="{{ fork_commit_url }}" target="_blank" rel="noopener noreferrer">{% trans "View commit" %}</a>
{% endif %}
</span>
</div>
{% endif %}
{% if on_dev_branch %}
<div class="version-meta-row">
<span class="version-meta-row-label">{% trans "Official upstream (usmannasir/cyberpanel) — latest on GitHub" %}</span>
<span class="version-meta-row-value">
{% if upstream_commit %}
<code class="version-sha" title="{{ upstream_commit }}">{{ upstream_commit_short }}</code>
{% if upstream_commit_url %}
<a href="{{ upstream_commit_url }}" target="_blank" rel="noopener noreferrer">{% trans "View commit" %}</a>
{% endif %}
{% else %}
{% trans "Unavailable" %} (API)
{% endif %}
</span>
</div>
{% elif latestcomit and not fork_remote_commit and not on_dev_branch %}
<div class="version-meta-row">
<span class="version-meta-row-label">{% trans "Latest commit on origin (comparison)" %}</span>
<span class="version-meta-row-value">
<code class="version-sha" title="{{ latestcomit }}">{{ latestcomit_short }}</code>
</span>
</div>
{% endif %}
</div>
<div class="content-card" ng-hide="upgradelogBox">

View File

@@ -325,6 +325,14 @@ def versionManagment(request):
remote_cmd = 'git -C /usr/local/CyberCP remote get-url origin 2>/dev/null || true'
remote_out = ProcessUtilities.outputExecutioner(remote_cmd)
is_usmannasir = 'usmannasir/cyberpanel' in (remote_out or '')
github_owner, github_repo = None, None
m_remote = re.search(r'github\.com[:/]([^/]+)/([^/]+?)(?:\.git)?$', (remote_out or '').strip())
if m_remote:
github_owner = m_remote.group(1)
github_repo = m_remote.group(2).rstrip('.git')
remote_display = '%s/%s' % (github_owner, github_repo)
else:
remote_display = ((remote_out or '').strip() or '')
# Stable: newer than cyberpanel.net = up to date; dev: compare commits
if not on_dev_branch and notechk and _version_compare(currentVersion, latestVersion) > 0:
@@ -365,10 +373,53 @@ def versionManagment(request):
except (requests.RequestException, IndexError, KeyError):
pass
# Fork remote tip for UI (empty when origin is official).
fork_remote_commit = latestcomit if (latestcomit and not is_usmannasir) else ''
upstream_commit = ''
if on_dev_branch:
up_url = "https://api.github.com/repos/usmannasir/cyberpanel/commits?sha=%s" % branch_ref
logging.CyberCPLogFileWriter.writeToFile(up_url)
try:
up_r = requests.get(up_url, timeout=10)
up_r.raise_for_status()
upstream_commit = up_r.json()[0]['sha']
except (requests.RequestException, IndexError, KeyError) as e:
logging.CyberCPLogFileWriter.writeToFile('[versionManagment] upstream GitHub API failed: %s' % str(e))
def _short_sha(commit_hash):
if not commit_hash or len(commit_hash) < 7:
return commit_hash or ''
return commit_hash[:7]
fork_commit_url = ''
if github_owner and github_repo and fork_remote_commit:
fork_commit_url = 'https://github.com/%s/%s/commit/%s' % (
github_owner, github_repo, fork_remote_commit)
upstream_commit_url = ''
if upstream_commit:
upstream_commit_url = 'https://github.com/usmannasir/cyberpanel/commit/%s' % upstream_commit
local_behind_official = bool(
on_dev_branch and Currentcomt and upstream_commit and Currentcomt != upstream_commit)
notecheck_compare_remote = 'usmannasir/cyberpanel' if is_usmannasir else remote_display
template = 'baseTemplate/versionManagment.html'
finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
'latestBuild': latestBuild, 'latestcomit': latestcomit, "Currentcomt": Currentcomt,
"Notecheck": notechk}
finalData = {
'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
'latestBuild': latestBuild, 'latestcomit': latestcomit, 'Currentcomt': Currentcomt,
'Notecheck': notechk, 'branch_ref': branch_ref, 'remote_display': remote_display,
'is_usmannasir': is_usmannasir, 'fork_remote_commit': fork_remote_commit,
'upstream_commit': upstream_commit, 'fork_commit_url': fork_commit_url,
'upstream_commit_url': upstream_commit_url,
'Currentcomt_short': _short_sha(Currentcomt),
'latestcomit_short': _short_sha(latestcomit),
'fork_remote_commit_short': _short_sha(fork_remote_commit),
'upstream_commit_short': _short_sha(upstream_commit),
'local_behind_official': local_behind_official,
'notecheck_compare_remote': notecheck_compare_remote,
'on_dev_branch': on_dev_branch,
}
proc = httpProc(request, template, finalData, 'versionManagement')
return proc.render()