Branches fix (#13)

This commit is contained in:
2025-09-16 22:19:31 +02:00
committed by GitHub
parent 3332d16b84
commit 1e93bf21d5
5 changed files with 56 additions and 20 deletions
+1 -1
View File
@@ -174,7 +174,7 @@ if __name__ == '__main__':
try:
if not isinstance(step, GitClone):
continue
branches[env.id] = {**branches[env.id], **step.get_branches()}
branches[env.id] = {**step.get_branches()}
except BaseException as e:
socketio.emit('error', {'message': e}, namespace='/ws/errors')
logger.info(f"Fetched {env.id}: {len (branches[env.id])} branches")
+11 -4
View File
@@ -136,7 +136,7 @@ class DockerSwarmDeploy(AbstractStep[str]):
self.stackChecker = stackChecker
def progress(self) -> str:
def progress(self) -> Any:
"""
Deploys to Docker Swarm using the specified docker-compose.yaml.
"""
@@ -181,7 +181,12 @@ class DockerSwarmDeploy(AbstractStep[str]):
for svc_name, svc in expected_services.items():
expected_image = svc.get("image")
running_image = current_services.get(svc_name).image if svc_name in current_services else None
l = f"Service '{svc_name}' (expected image: '{expected_image}', actual image: '{running_image}')"
l = {
"service": svc_name,
"expected_image": expected_image,
"actual_image": running_image,
"stack": self.stack_name,
}
logger.info(l)
if running_image and expected_image and running_image == expected_image:
ok.append(l)
@@ -190,11 +195,13 @@ class DockerSwarmDeploy(AbstractStep[str]):
if len(diffs) == 0:
logger.info(f"No diff found, stack is already up-to-date.")
return '\\n'.join(ok)
return ok
logger.info(f"Diff {diffs}")
if self.env.dry:
logger.info(f"Stack is not active, skipping deploy.")
return "\\n".join(diffs) + "\\nStack is not active, skipping deploy."
return {
"diffs": diffs,
}
tmp_compose_path = docker_compose_absolute_path + ".tmp"
with open(tmp_compose_path, 'w') as f:
+21 -13
View File
@@ -20,6 +20,9 @@ const branchFilter = document.getElementById('branch-filter');
let branches = [];
let filteredBranches = [];
// Toggle state: show all branches or filtered
let showAllBranches = false;
// Environment runtime state storage:
// environmentsRaw: array as received from backend: [ [envObj, jobsArr], ... ]
let environmentsRaw = [];
@@ -71,7 +74,7 @@ function filterBranches() {
(c.message && c.message.toLowerCase().includes(filterText)) ||
(c.author && c.author.toLowerCase().includes(filterText));
});
return isSelected || isDeployed || isFiltered || isFilteredByCommit;
return showAllBranches || isSelected || isDeployed || isFiltered || isFilteredByCommit;
});
renderBranches();
}
@@ -234,20 +237,14 @@ function renderJobs() {
<h4>Environment: ${envObj.name || envObj.id || ''}</h4>
${Array.isArray(jobsArr) && jobsArr.length > 0
? jobsArr.map(job => {
let statusDisplay = '';
let tooltip = '';
if (Array.isArray(job.status) && job.status.length > 0) {
statusDisplay = typeof job.status[0] === 'string' ? job.status[0] : JSON.stringify(job.status[0]);
if (job.status.length > 1) {
tooltip = job.status.slice(1).flatMap(s => typeof s === 'string' ? [s] : s).join('<br/>');
}
} else {
statusDisplay = typeof job.status === 'string' ? job.status : JSON.stringify(job.status);
}
let statusDisplay = `<pre>` + JSON.stringify(job.status, null, 2) + `</pre>`;
statusDisplay = statusDisplay.replace(
/(https?:\/\/[^\s"']+)/g,
url => `<a href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`
);
return `
<div class="job-item">
<strong>${job.env} - ${job.name}</strong> - ${statusDisplay}
${tooltip ? `<span class="tooltip-icon" title="${tooltip.replace(/"/g, '&quot;')}">&#x1F6C8;</span>` : ''}
<strong>${job.env} - ${job.name}</strong><br />${statusDisplay}
</div>`;
}).join('')
: '<div class="job-item">No jobs found.</div>'}
@@ -266,6 +263,16 @@ branchFilter.oninput = () => {
filterBranches();
};
// Toggle show all button handler
const toggleShowAllBtn = document.getElementById('toggle-show-all');
if (toggleShowAllBtn) {
toggleShowAllBtn.onclick = () => {
showAllBranches = !showAllBranches;
toggleShowAllBtn.textContent = showAllBranches ? 'Show Filtered' : 'Show All';
filterBranches();
};
}
// Apply changes button handler
applyChangesBtn.onclick = () => {
updateEnvironment();
@@ -349,6 +356,7 @@ function updateEnvironment() {
wsEnv.emit('update', { id: envId, branches: selectedBranchesByEnv[envId] });
// Optimistically sync server state
serverSelectedBranchesByEnv[envId] = [...selectedBranchesByEnv[envId]];
branchFilter.value = '';
}
});
checkForPendingChanges();
+5 -2
View File
@@ -22,12 +22,15 @@
<div class="filter-section" style="float: left;">
<input type="text" id="branch-filter" placeholder="Filter branches by name, commit ID, or commit message..." class="filter-input">
</div>
<div class="apply-section" style="float: right;">
<button id="apply-changes" class="apply-button hidden">Apply Changes</button>
<div class="control-bar" style="float: left;">
<button id="toggle-show-all" class="toggle-button">Show All</button>
</div>
<div class="control-bar" style="float: right;">
<button id="refresh-branches" class="refresh-button">Refresh Branches</button>
</div>
<div class="apply-section" style="float: right;">
<button id="apply-changes" class="apply-button hidden">Apply Changes</button>
</div>
<div style="clear: both;" />
<div class="branches-list" id="branches-list">
<p class="loading">Loading branches...</p>
+18
View File
@@ -34,6 +34,7 @@ body {
cursor: pointer;
font-size: 1rem;
margin-bottom: 16px;
margin-left: 8px;
}
.refresh-button:hover {
background: #218838;
@@ -48,10 +49,27 @@ body {
cursor: pointer;
font-size: 1rem;
margin-bottom: 16px;
margin-left: 8px;
}
.apply-button:hover {
background: #218838;
}
.toggle-button {
background: #28a745;
color: #fff;
border: none;
border-radius: 4px;
padding: 10px 20px;
cursor: pointer;
font-size: 1rem;
margin-bottom: 16px;
margin-left: 8px;
}
.toggle-button:hover {
background: #218838;
}
.apply-section {
text-align: center;
margin: 16px 0;