feat(git): Hinweis im Account-Panel, Startlog, Fehlersuche und Betriebs-Compose (#30)
- Panel zeigt bei 503/G10 und 403/G07 einen Hinweis statt sich auszublenden; ohne Login unsichtbar - Startlog: Info-Zeile bei aktivem Backend (kid, Allowlist), ohne Secrets - docs/git: Abschnitt Fehlersuche / nachträglich aktivieren - docs/deploy: compose.yaml-Vorlage für das veröffentlichte Image, Verlinkung aus README/FORK/auth/storage - Dev-Compose reicht HB_ASSET_* durch Refs #30 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3b83125771
commit
f96dec267b
17 files changed
+439
-181
No files matched your search
@@ -1,13 +1,15 @@
|
||||
import './git.less';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { gitApi } from './gitApi.js';
|
||||
import { classifyListError } from './panelState.js';
|
||||
|
||||
// Verbindungen verwalten (ADR 0003 §7): anlegen, testen, löschen, Brews aus dem Repo importieren.
|
||||
// Das Token-Feld ist reines Eingabefeld und wird nie vorbefüllt; der Server gibt den Token nie zurück.
|
||||
const EMPTY = { label: '', repoUrl: '', authUsername: 'git', token: '' };
|
||||
|
||||
const GitConnectionsPanel = ()=>{
|
||||
const [state, setState] = useState('loading'); // loading | off | ready
|
||||
const [state, setState] = useState('loading'); // loading | hidden | notice | ready
|
||||
const [notice, setNotice] = useState('');
|
||||
const [conns, setConns] = useState([]);
|
||||
const [form, setForm] = useState(EMPTY);
|
||||
const [msg, setMsg] = useState({}); // pro Verbindung: { ok, text }
|
||||
@@ -15,10 +17,19 @@ const GitConnectionsPanel = ()=>{
|
||||
const [files, setFiles] = useState({}); // pro Verbindung: { branch, files }
|
||||
|
||||
const reload = ()=>gitApi.listConnections().then((list)=>{ setConns(list); setState('ready'); })
|
||||
.catch((err)=>{ if([403, 503].includes(err.status)) setState('off'); else { setFormError(err.message); setState('ready'); } });
|
||||
.catch((err)=>{
|
||||
const { state: next, notice: text } = classifyListError(err);
|
||||
if(next === 'error') { setFormError(err.message); setState('ready'); } else { setNotice(text ?? ''); setState(next); }
|
||||
});
|
||||
useEffect(()=>{ reload(); }, []);
|
||||
|
||||
if(state !== 'ready') return null; // Git-Backend deaktiviert oder kein OIDC-Konto
|
||||
if(state === 'notice') return (
|
||||
<div className='dataGroup gitConnections'>
|
||||
<h3>Git-Verbindungen <i className='fab fa-git-alt'></i></h3>
|
||||
<p className='notice'>{notice}</p>
|
||||
</div>
|
||||
);
|
||||
if(state !== 'ready') return null; // lädt oder nicht angemeldet
|
||||
|
||||
const set = (id, ok, text)=>setMsg((m)=>({ ...m, [id]: { ok, text } }));
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
}
|
||||
.error { color : @red; font-weight : 800; }
|
||||
.ok { color : @teal; font-weight : 800; }
|
||||
.notice { color : #555555; font-style : italic; }
|
||||
ul.files { list-style : none; padding : 0; li { margin : 2px 0; } }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Zustand des Git-Panels auf der Account-Seite (FLW-258): aus dem Fehler von GET /api/git/connections
|
||||
// wird entschieden, ob das Panel einen Hinweis zeigt, normal arbeitet oder unsichtbar bleibt.
|
||||
export const NOTICES = {
|
||||
disabled : 'Git-Backend auf diesem Server nicht aktiviert – siehe docs/git (Abschnitt „Fehlersuche / nachträglich aktivieren“).',
|
||||
noOidc : 'Nur mit OIDC-Anmeldung verfügbar.'
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {{ status?: number, HBErrorCode?: string }} err Fehler aus gitApi.listConnections()
|
||||
* @returns {{ state: 'notice'|'hidden'|'error', notice?: string }}
|
||||
* notice = Hinweis anzeigen, hidden = nichts anzeigen (nicht angemeldet), error = Panel mit Fehlermeldung
|
||||
*/
|
||||
export const classifyListError = (err)=>{
|
||||
if(err?.status === 503 && (!err.HBErrorCode || err.HBErrorCode === 'G10')) return { state: 'notice', notice: NOTICES.disabled };
|
||||
if(err?.status === 403 && (!err.HBErrorCode || err.HBErrorCode === 'G07')) return { state: 'notice', notice: NOTICES.noOidc };
|
||||
if(err?.status === 401) return { state: 'hidden' };
|
||||
return { state: 'error' };
|
||||
};
|
||||
@@ -69,7 +69,7 @@ const AccountPage = (props)=>{
|
||||
{renderSaveLocationButton('Homebrewery', 'HOMEBREWERY')}
|
||||
{renderSaveLocationButton('Google Drive', 'GOOGLE-DRIVE', accountDetails.googleId)}
|
||||
</div>
|
||||
<GitConnectionsPanel />
|
||||
{accountDetails.username && <GitConnectionsPanel />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user