feat(ui): wire JAR upload progress into the primary action button
This commit is contained in:
@@ -88,6 +88,7 @@ export default function AppDeploymentPage() {
|
|||||||
// Local UI state
|
// Local UI state
|
||||||
const [name, setName] = useState('');
|
const [name, setName] = useState('');
|
||||||
const [stagedJar, setStagedJar] = useState<File | null>(null);
|
const [stagedJar, setStagedJar] = useState<File | null>(null);
|
||||||
|
const [uploadPct, setUploadPct] = useState<number | null>(null);
|
||||||
const [tab, setTab] = useState<TabKey>('monitoring');
|
const [tab, setTab] = useState<TabKey>('monitoring');
|
||||||
const [deleteConfirm, setDeleteConfirm] = useState(false);
|
const [deleteConfirm, setDeleteConfirm] = useState(false);
|
||||||
const [stopTarget, setStopTarget] = useState<string | null>(null);
|
const [stopTarget, setStopTarget] = useState<string | null>(null);
|
||||||
@@ -125,8 +126,10 @@ export default function AppDeploymentPage() {
|
|||||||
// redeploy path).
|
// redeploy path).
|
||||||
const serverDirtyAgainstDeploy = app && dirtyLoading ? false : (dirtyState?.dirty ?? true);
|
const serverDirtyAgainstDeploy = app && dirtyLoading ? false : (dirtyState?.dirty ?? true);
|
||||||
const deploymentInProgress = !!activeDeployment;
|
const deploymentInProgress = !!activeDeployment;
|
||||||
|
const uploading = uploadPct !== null;
|
||||||
const primaryMode = computeMode({
|
const primaryMode = computeMode({
|
||||||
deploymentInProgress,
|
deploymentInProgress,
|
||||||
|
uploading,
|
||||||
hasLocalEdits: dirty.anyLocalEdit,
|
hasLocalEdits: dirty.anyLocalEdit,
|
||||||
serverDirtyAgainstDeploy,
|
serverDirtyAgainstDeploy,
|
||||||
});
|
});
|
||||||
@@ -177,7 +180,17 @@ export default function AppDeploymentPage() {
|
|||||||
|
|
||||||
// 2. Upload JAR if staged
|
// 2. Upload JAR if staged
|
||||||
if (stagedJar) {
|
if (stagedJar) {
|
||||||
await uploadJar.mutateAsync({ envSlug, appSlug: targetApp.slug, file: stagedJar });
|
setUploadPct(0);
|
||||||
|
try {
|
||||||
|
await uploadJar.mutateAsync({
|
||||||
|
envSlug,
|
||||||
|
appSlug: targetApp.slug,
|
||||||
|
file: stagedJar,
|
||||||
|
onProgress: setUploadPct,
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setUploadPct(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Save container config
|
// 3. Save container config
|
||||||
@@ -260,8 +273,18 @@ export default function AppDeploymentPage() {
|
|||||||
let versionId: string;
|
let versionId: string;
|
||||||
|
|
||||||
if (stagedJar) {
|
if (stagedJar) {
|
||||||
const newVersion = await uploadJar.mutateAsync({ envSlug, appSlug: app.slug, file: stagedJar });
|
setUploadPct(0);
|
||||||
|
try {
|
||||||
|
const newVersion = await uploadJar.mutateAsync({
|
||||||
|
envSlug,
|
||||||
|
appSlug: app.slug,
|
||||||
|
file: stagedJar,
|
||||||
|
onProgress: setUploadPct,
|
||||||
|
});
|
||||||
versionId = newVersion.id;
|
versionId = newVersion.id;
|
||||||
|
} finally {
|
||||||
|
setUploadPct(null);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!currentVersion) {
|
if (!currentVersion) {
|
||||||
toast({
|
toast({
|
||||||
@@ -346,6 +369,7 @@ export default function AppDeploymentPage() {
|
|||||||
// ── Primary button enabled logic ───────────────────────────────────
|
// ── Primary button enabled logic ───────────────────────────────────
|
||||||
const primaryEnabled = (() => {
|
const primaryEnabled = (() => {
|
||||||
if (primaryMode === 'deploying') return false;
|
if (primaryMode === 'deploying') return false;
|
||||||
|
if (primaryMode === 'uploading') return false;
|
||||||
if (primaryMode === 'save') return !!name.trim() && (isNetNew || dirty.anyLocalEdit);
|
if (primaryMode === 'save') return !!name.trim() && (isNetNew || dirty.anyLocalEdit);
|
||||||
return true; // redeploy always enabled
|
return true; // redeploy always enabled
|
||||||
})();
|
})();
|
||||||
@@ -389,6 +413,7 @@ export default function AppDeploymentPage() {
|
|||||||
<PrimaryActionButton
|
<PrimaryActionButton
|
||||||
mode={primaryMode}
|
mode={primaryMode}
|
||||||
enabled={primaryEnabled}
|
enabled={primaryEnabled}
|
||||||
|
progress={uploadPct ?? undefined}
|
||||||
onClick={primaryMode === 'redeploy' ? handleRedeploy : handleSave}
|
onClick={primaryMode === 'redeploy' ? handleRedeploy : handleSave}
|
||||||
/>
|
/>
|
||||||
{app && latestDeployment && (
|
{app && latestDeployment && (
|
||||||
|
|||||||
Reference in New Issue
Block a user