Add Rebuild button to Updates tab — triggers rebuild without git pull
This commit is contained in:
parent
3562c178d7
commit
03b241ec74
1 changed files with 30 additions and 1 deletions
|
|
@ -92,6 +92,7 @@ export function AdminMonitor({ user }: { user: User }) {
|
||||||
const [health, setHealth] = useState<HealthStatus[]>([])
|
const [health, setHealth] = useState<HealthStatus[]>([])
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [deploying, setDeploying] = useState<Set<string>>(new Set())
|
const [deploying, setDeploying] = useState<Set<string>>(new Set())
|
||||||
|
const [rebuilding, setRebuilding] = useState<Set<string>>(new Set())
|
||||||
const [shellContainer, setShellContainer] = useState('')
|
const [shellContainer, setShellContainer] = useState('')
|
||||||
const [shellCmd, setShellCmd] = useState('')
|
const [shellCmd, setShellCmd] = useState('')
|
||||||
const [shellOutput, setShellOutput] = useState('')
|
const [shellOutput, setShellOutput] = useState('')
|
||||||
|
|
@ -196,6 +197,19 @@ export function AdminMonitor({ user }: { user: User }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function triggerRebuild(repo: string) {
|
||||||
|
setRebuilding(prev => new Set(prev).add(repo))
|
||||||
|
try {
|
||||||
|
await fetch(`/deploy/rebuild/${repo}`, { method: 'POST', credentials: 'include' })
|
||||||
|
setTimeout(() => {
|
||||||
|
fetchStatus(true)
|
||||||
|
setRebuilding(prev => { const s = new Set(prev); s.delete(repo); return s })
|
||||||
|
}, 3000)
|
||||||
|
} catch {
|
||||||
|
setRebuilding(prev => { const s = new Set(prev); s.delete(repo); return s })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (tab === 'updates') fetchStatus()
|
if (tab === 'updates') fetchStatus()
|
||||||
if (tab === 'deploys') fetchDeploys()
|
if (tab === 'deploys') fetchDeploys()
|
||||||
|
|
@ -312,7 +326,7 @@ export function AdminMonitor({ user }: { user: User }) {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ flexShrink: 0 }}>
|
<div style={{ flexShrink: 0, display: 'flex', gap: '0.5rem', alignItems: 'center' }}>
|
||||||
{s.updateAvailable ? (
|
{s.updateAvailable ? (
|
||||||
<button
|
<button
|
||||||
onClick={() => triggerDeploy(s.repo)}
|
onClick={() => triggerDeploy(s.repo)}
|
||||||
|
|
@ -329,6 +343,21 @@ export function AdminMonitor({ user }: { user: User }) {
|
||||||
) : s.deployed ? (
|
) : s.deployed ? (
|
||||||
<span style={{ fontSize: '0.75rem', color: '#16a34a', fontWeight: 500 }}>✓ Up to date</span>
|
<span style={{ fontSize: '0.75rem', color: '#16a34a', fontWeight: 500 }}>✓ Up to date</span>
|
||||||
) : null}
|
) : null}
|
||||||
|
{s.deployed && (
|
||||||
|
<button
|
||||||
|
onClick={() => triggerRebuild(s.repo)}
|
||||||
|
disabled={rebuilding.has(s.repo) || deploying.has(s.repo)}
|
||||||
|
style={{
|
||||||
|
background: 'transparent', color: 'var(--text-mid)',
|
||||||
|
border: '1px solid var(--card-border)', borderRadius: '6px',
|
||||||
|
padding: '0.4rem 0.75rem', fontSize: '0.8rem', fontWeight: 500,
|
||||||
|
opacity: (rebuilding.has(s.repo) || deploying.has(s.repo)) ? 0.5 : 1,
|
||||||
|
cursor: 'pointer',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{rebuilding.has(s.repo) ? 'Rebuilding…' : 'Rebuild'}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue