Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions WebUI/src/main/ts/i18n/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ export const MSG = {
PUBLISH_SECTION_DESIGN: "perc.ui.publish.modern@Design",
PUBLISH_SECTION_RUNTIME: "perc.ui.publish.modern@Runtime",
PUBLISH_FILTER_SITES: "perc.ui.publish.title@Filter Sites",
PUBLISH_FILTER_EDITIONS: "perc.ui.publish.modern@Filter editions",
PUBLISH_EMPTY_EDITION_FILTER:
"perc.ui.publish.modern@No jobs match this edition filter. Clear the filter to see the full list.",
PUBLISH_CARD: "perc.ui.publish.title@Card",
PUBLISH_LIST: "perc.ui.publish.title@List",
PUBLISH_FULL: "perc.ui.publish.title@Full",
Expand Down
27 changes: 24 additions & 3 deletions WebUI/src/main/ts/publishing/sections/StatusSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
thStyle,
toolbarStyle,
} from "../publishing.styles";
import { filterJobsByEdition } from "../statusEditionFilter";
import { filterJobsBySite } from "../statusSiteFilter";
import {
nextSortState,
Expand Down Expand Up @@ -84,6 +85,7 @@ export function StatusSection({
const [error, setError] = useState<string | null>(null);
const [loading, setLoading] = useState(true);
const [siteFilter, setSiteFilter] = useState("");
const [editionFilter, setEditionFilter] = useState("");
const [sort, setSort] = useState<StatusSortState>(DEFAULT_SORT);
const [selectedJobId, setSelectedJobId] = useState<string | null>(null);
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
Expand All @@ -109,9 +111,14 @@ export function StatusSection({
}, [load]);

const visibleJobs = useMemo(
() => sortJobs(filterJobsBySite(jobs, siteFilter), sort),
[jobs, siteFilter, sort],
() =>
sortJobs(
filterJobsByEdition(filterJobsBySite(jobs, siteFilter), editionFilter),
sort,
),
[jobs, siteFilter, editionFilter, sort],
);
const editionQuery = editionFilter.trim() !== "";
useEffect(() => {
const id = focusJob?.id?.trim() ?? "";
if (id !== "") {
Expand Down Expand Up @@ -222,6 +229,18 @@ export function StatusSection({
style={{ padding: "6px 10px", minWidth: 200 }}
/>
</label>
<label>
<span className="sr-only">{message(MSG.PUBLISH_FILTER_EDITIONS)}</span>
<input
type="search"
data-testid="publish-status-edition-filter"
value={editionFilter}
onChange={(e) => setEditionFilter(e.target.value)}
placeholder={message(MSG.PUBLISH_FILTER_EDITIONS)}
aria-label={message(MSG.PUBLISH_FILTER_EDITIONS)}
style={{ padding: "6px 10px", minWidth: 200 }}
/>
</label>
</div>
{loading && <p>{message(MSG.PUBLISH_LOADING)}</p>}
{error && (
Expand All @@ -234,7 +253,9 @@ export function StatusSection({
)}
{!loading && jobs.length > 0 && visibleJobs.length === 0 && (
<p style={emptyStyle} data-testid="publish-status-empty-filter">
No jobs match this site filter. Clear the filter to see the full list.
{editionQuery
? message(MSG.PUBLISH_EMPTY_EDITION_FILTER)
: "No jobs match this site filter. Clear the filter to see the full list."}
</p>
)}
{visibleJobs.length > 0 && (
Expand Down
42 changes: 42 additions & 0 deletions WebUI/src/main/ts/publishing/statusEditionFilter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2026 Intersoft Data Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { PublishingJob } from "./types";

function jobEditionHaystack(job: PublishingJob): string {
const name = job.editionName;
if (name == null || String(name).trim() === "") {
return "";
}
return String(name).toLowerCase();
}

/**
* Narrow already-loaded status jobs by edition name (case-insensitive
* substring). Blank query returns the original list. Jobs with no edition
* name do not match a non-blank query.
*/
export function filterJobsByEdition(
jobs: PublishingJob[],
query: string,
): PublishingJob[] {
const q = query.trim().toLowerCase();
if (!q) {
return jobs;
}
return jobs.filter((job) => jobEditionHaystack(job).includes(q));
}
128 changes: 128 additions & 0 deletions WebUI/src/test/ts/publishing/statusEditionFilter.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Copyright (c) 2026 Intersoft Data Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { filterJobsByEdition } from "@/publishing/statusEditionFilter";
import { StatusSection } from "@/publishing/sections/StatusSection";
import { fetchCurrentJobs } from "@/api/publishing/statusApi";

describe("filterJobsByEdition", () => {
const jobs = [
{ jobId: 1, siteName: "FastForward", editionName: "Nightly Full", status: "Running" },
{ jobId: 2, siteName: "DoneSite", editionName: "Hourly Incremental", status: "Completed" },
{ jobId: 3, siteName: "Bare", status: "Running" },
];

it("returns every job when the query is blank", () => {
expect(filterJobsByEdition(jobs, "")).toEqual(jobs);
expect(filterJobsByEdition(jobs, " ")).toEqual(jobs);
});

it("matches edition name case-insensitively and skips jobs with no name", () => {
expect(filterJobsByEdition(jobs, "nightly").map((j) => j.jobId)).toEqual([1]);
expect(filterJobsByEdition(jobs, "INCREMENTAL").map((j) => j.jobId)).toEqual([2]);
expect(filterJobsByEdition(jobs, "nope")).toEqual([]);
});
});

const LOADED = [
{
jobId: 1,
siteName: "FastForward",
siteId: 10,
editionName: "Nightly Full",
status: "Running",
completedItems: 1,
totalItems: 4,
},
{
jobId: 2,
siteName: "DoneSite",
siteId: 22,
editionName: "Hourly Incremental",
status: "Completed",
completedItems: 3,
totalItems: 3,
},
];

vi.mock("@/api/publishing/statusApi", () => ({
fetchCurrentJobs: vi.fn(),
}));

vi.mock("@/api/publishing/serversApi", () => ({
stopPublishing: vi.fn().mockResolvedValue({}),
}));

vi.mock("@/api/publishing/itemHistoryApi", () => ({
fetchItemPublishingHistory: vi.fn().mockResolvedValue([]),
}));

describe("StatusSection edition filter (#4914)", () => {
beforeEach(() => {
vi.mocked(fetchCurrentJobs).mockReset();
vi.mocked(fetchCurrentJobs).mockResolvedValue(LOADED);
});

it("narrows by edition, shows an empty match, and restores the site-scoped list", async () => {
render(<StatusSection />);
await waitFor(() => {
expect(screen.getByTestId("publish-stop-job-1")).toBeTruthy();
});

const site = screen.getByTestId("publish-status-site-filter");
fireEvent.change(site, { target: { value: "site" } });
expect(screen.queryByTestId("publish-stop-job-1")).toBeNull();
expect(screen.getByText("DoneSite")).toBeTruthy();

const edition = screen.getByTestId("publish-status-edition-filter");
fireEvent.change(edition, { target: { value: "HOURLY" } });
expect(screen.getByText("DoneSite")).toBeTruthy();
expect(screen.queryByText("FastForward")).toBeNull();

fireEvent.change(edition, { target: { value: "missing-edition" } });
const empty = screen.getByTestId("publish-status-empty-filter");
expect(empty.textContent).toMatch(/edition filter/i);
expect(screen.queryByRole("alert")).toBeNull();

fireEvent.change(edition, { target: { value: "" } });
expect(screen.getByText("DoneSite")).toBeTruthy();
expect(screen.queryByTestId("publish-stop-job-1")).toBeNull();
});

it("keeps the status panel when a later reload is forbidden", async () => {
vi.mocked(fetchCurrentJobs)
.mockResolvedValueOnce(LOADED)
.mockRejectedValueOnce({ status: 403, message: "Forbidden" });

render(<StatusSection />);
await waitFor(() => {
expect(screen.getByTestId("publish-section-status")).toBeTruthy();
expect(screen.getByTestId("publish-stop-job-1")).toBeTruthy();
});

await waitFor(
() => {
expect(screen.getByRole("alert")).toBeTruthy();
},
{ timeout: 7000 },
);
expect(screen.getByTestId("publish-section-status")).toBeTruthy();
expect(screen.getByTestId("publish-stop-job-1")).toBeTruthy();
});
});
25 changes: 25 additions & 0 deletions docs/ai-generated/code-reviews/issue-4914-erlang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Summary

Machine analysis found **0** finding(s), **0** bug(s).

## Scope

- Base: origin/main
- Head: HEAD
- Files: 6 analyzed
- Persona: erlang 0.1.1
- Persona source: /home/nate/.local/share/mkd/agents/erlang

## Recommendation

approve

## Gate

- Blocking bugs: 0
- May commit/push: yes

## Issues

_No issues._

44 changes: 44 additions & 0 deletions docs/ai-generated/code-reviews/pr-4933-erlang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!--
Copyright (c) 2026 Intersoft Data Labs, Inc.
Licensed under the Apache License, Version 2.0.
-->

# Erlang review — PR #4933

## Scope

- Persona: erlang 0.1.1
- Persona source: /home/nate/.local/share/mkd/agents/erlang
- Status: mkd-code-review 0.1.18, pack percussion, --gate advisory, --git-base origin/main
- PR: https://github.com/intersoftdatalabs-in/percussioncms/pull/4933
- Base: origin/main
- Head: 1cc63ec05c4a02ec8fed969a3e585970c4a1ff3c
- Files analyzed: 7
- Independent read: no bugs, missing tests, path issues, or change-class gaps. Recommendation: approve.

## CLI stdout (`mkd-code-review analyze --format markdown`)

## Summary

Machine analysis found **0** finding(s), **0** bug(s).

## Scope

- Base: origin/main
- Head: HEAD
- Files: 7 analyzed
- Persona: erlang 0.1.1
- Persona source: /home/nate/.local/share/mkd/agents/erlang

## Recommendation

approve

## Gate

- Blocking bugs: 0
- May commit/push: yes

## Issues

_No issues._
Loading
Loading