Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

www-react: Add builder workers in /builder/{id} view #2

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions www/react-base/src/views/BuilderView/BuilderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,28 @@

import {observer} from "mobx-react";
import {useState} from "react";
import {Card} from "react-bootstrap";
import {buildbotSetupPlugin} from "buildbot-plugin-support";
import {
Build,
Builder,
Buildrequest,
DataCollection, DataMultiCollection,
DataCollection,
Forcescheduler,
Project,
useDataAccessor,
useDataApiQuery,
useDataApiSingleElementQuery
} from "buildbot-data-js";
import {TopbarAction, useTopbarItems, useTopbarActions, TopbarItem} from "buildbot-ui";
import {TopbarAction, useTopbarItems, useTopbarActions, WorkerBadge} from "buildbot-ui";
import {BuildsTable} from "../../components/BuildsTable/BuildsTable";
import {BuildRequestsTable} from "../../components/BuildrequestsTable/BuildrequestsTable";
import {LoadingSpan} from "../../components/LoadingSpan/LoadingSpan";
import {useNavigate, useParams} from "react-router-dom";
import {AlertNotification} from "../../components/AlertNotification/AlertNotification";
import {ForceBuildModal} from "../../components/ForceBuildModal/ForceBuildModal";
import {TableHeading} from "../../components/TableHeading/TableHeading";
import {FaStop, FaSpinner} from "react-icons/fa";
import {buildTopbarItemsForBuilder} from "../../util/TopbarUtils";
import {PendingBuildRequestsTable} from "../../components/PendingBuildRequestsTable/PendingBuildRequestsTable";

const anyCancellableBuilds = (builds: DataCollection<Build>,
buildrequests: DataCollection<Buildrequest>) => {
Expand Down Expand Up @@ -123,11 +124,18 @@ export const BuilderView = observer(() => {
: Project.getAll(accessor, {id: builder.projectid.toString()})
}));

const workersQuery = useDataApiQuery(() =>
buildersQuery.getRelated(builder => builder.getWorkers({query: {
order: 'name'
}
})));

const builder = buildersQuery.getNthOrNull(0);
const builds = buildsQuery.getParentCollectionOrEmpty(builderid.toString());
const buildrequests = buildrequestsQuery.getParentCollectionOrEmpty(builderid.toString());
const forceschedulers = forceSchedulersQuery.getParentCollectionOrEmpty(builderid.toString());
const project = projectsQuery.getNthOrNull(0);
const workers = workersQuery.getParentCollectionOrEmpty(builderid.toString());

const [isCancelling, setIsCancelling] = useState(false);
const [errorMsg, setErrorMsg] = useState<string | null>(null);
Expand Down Expand Up @@ -198,7 +206,25 @@ export const BuilderView = observer(() => {
? renderDescription(builder)
: <></>
}
<BuildRequestsTable buildrequests={buildrequests}/>
<Card>
<Card.Body>
<Card.Title>Pending Build Requests</Card.Title>
<PendingBuildRequestsTable buildRequestsQuery={buildrequests}/>
</Card.Body>
</Card>
<Card>
<Card.Body>
<Card.Title>Workers</Card.Title>
<div className="bb-builder-workers-container">
{
!workers.isResolved() ? <LoadingSpan/> :
workers.array.map(worker => (
<WorkerBadge key={worker.name} worker={worker} showWorkerName={true}/>
))
}
</div>
</Card.Body>
</Card>
<BuildsTable builds={builds} builders={null}/>
{shownForceScheduler !== null
? <ForceBuildModal scheduler={shownForceScheduler} builderid={builderid}
Expand Down
Loading