2025-08-25 14:15:12 +00:00
|
|
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
import { useQuery } from "react-query";
|
2025-08-14 15:10:45 +00:00
|
|
|
import { Tab, TabList, TabPanel, Tabs } from "react-tabs";
|
|
|
|
|
|
|
|
|
|
import PATHS from "router/paths";
|
|
|
|
|
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
import scriptsAPI, {
|
|
|
|
|
IScriptBatchSummaryV2,
|
|
|
|
|
IScriptBatchSummariesResponse,
|
|
|
|
|
} from "services/entities/scripts";
|
2025-08-14 15:10:45 +00:00
|
|
|
|
|
|
|
|
import { isValidScriptBatchStatus, ScriptBatchStatus } from "interfaces/script";
|
|
|
|
|
|
|
|
|
|
import { COLORS } from "styles/var/colors";
|
|
|
|
|
|
2025-08-15 13:24:55 +00:00
|
|
|
import Spinner from "components/Spinner";
|
2025-08-14 15:10:45 +00:00
|
|
|
import ProgressBar from "components/ProgressBar";
|
|
|
|
|
import SectionHeader from "components/SectionHeader";
|
|
|
|
|
import TabNav from "components/TabNav";
|
|
|
|
|
import TabText from "components/TabText";
|
2025-08-25 14:15:12 +00:00
|
|
|
import PaginatedList, { IPaginatedListHandle } from "components/PaginatedList";
|
2025-10-08 17:31:57 +00:00
|
|
|
import ListItem from "components/ListItem";
|
2025-08-14 15:10:45 +00:00
|
|
|
import Icon from "components/Icon/Icon";
|
2026-04-27 22:54:34 +00:00
|
|
|
import EmptyState from "components/EmptyState";
|
2025-08-14 15:10:45 +00:00
|
|
|
|
|
|
|
|
import { IScriptsCommonProps } from "../../ScriptsNavItems";
|
UI: Batch script run detail page (#32333)
## For #31226
New features:
- Dynamic header for each possible state of a batch script run: Started,
Scheduled, and Finished (corresponds to tabs at
`/controls/scripts/progress`
- Unique tabs for each possible status of hosts targeted by a batch
script run: Ran, Errored, Pending, Incompatible, Canceled.
- Within each tab, sortable, paginated host results with output preview
and execution time.
- View script/run details, cancel a batch, view manage hosts page
filtered for the script batch run and a status.
- Global script batch runs activities and and Scripts progress rows now
navigate to this details page.
Cleanups and improvements:
- Expand tab count badge options using “alert”/“pending” variants across
hosts, policies, and query results.
- Misc cleanups and improvements

- [x] Changes file added for user-visible changes in `changes/`,
- [x] Updated automated tests - new tests tracked for follow-up work
- [x] QA'd all new/changed functionality manually
---------
Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2025-08-29 15:37:05 +00:00
|
|
|
import getWhen from "../../helpers";
|
2025-08-14 15:10:45 +00:00
|
|
|
|
|
|
|
|
const baseClass = "script-batch-progress";
|
|
|
|
|
|
|
|
|
|
const STATUS_BY_INDEX: ScriptBatchStatus[] = [
|
|
|
|
|
"started",
|
|
|
|
|
"scheduled",
|
|
|
|
|
"finished",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const EMPTY_STATE_DETAILS: Record<ScriptBatchStatus, string> = {
|
|
|
|
|
started: "When a script is run on multiple hosts, progress will appear here.",
|
|
|
|
|
scheduled:
|
|
|
|
|
"When a script is scheduled to run in the future, it will appear here.",
|
|
|
|
|
finished:
|
|
|
|
|
"When a batch script is completed or canceled, historical results will appear here.",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getEmptyState = (status: ScriptBatchStatus) => {
|
|
|
|
|
return (
|
2026-04-27 22:54:34 +00:00
|
|
|
<EmptyState
|
|
|
|
|
variant="list"
|
|
|
|
|
header={`No batch scripts ${status} for this fleet`}
|
|
|
|
|
info={EMPTY_STATE_DETAILS[status]}
|
|
|
|
|
/>
|
2025-08-14 15:10:45 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-25 17:49:04 +00:00
|
|
|
export type IScriptBatchProgressProps = IScriptsCommonProps;
|
2025-08-14 15:10:45 +00:00
|
|
|
|
|
|
|
|
const ScriptBatchProgress = ({
|
|
|
|
|
location,
|
|
|
|
|
router,
|
|
|
|
|
teamId,
|
|
|
|
|
}: IScriptBatchProgressProps) => {
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
const [pageNumber, setPageNumber] = useState(0);
|
2025-08-14 15:10:45 +00:00
|
|
|
|
2025-08-25 14:15:12 +00:00
|
|
|
const paginatedListRef = useRef<IPaginatedListHandle<IScriptBatchSummaryV2>>(
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
|
2025-08-14 15:10:45 +00:00
|
|
|
const statusParam = location?.query.status;
|
|
|
|
|
|
|
|
|
|
const selectedStatus = statusParam as ScriptBatchStatus;
|
|
|
|
|
|
|
|
|
|
const DEFAULT_PAGE_SIZE = 10;
|
|
|
|
|
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
const queryKey = {
|
Update API calls in front-end to use new, non-deprecated URLs and params (#41515)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #41391
# Details
This PR updates front-end API calls to use new URLs and API params, so
that the front end doesn't cause deprecation warnings to appear on the
server.
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.
n/a, should not be user-visible
## Testing
- [X] Added/updated automated tests
- [ ] QA'd all new/changed functionality manually
The biggest risk here is not that we missed a spot that still causes a
deprecation warning, but that we might inadvertently make a change that
breaks the front end, for instance by sending `fleet_id` to a function
that drops it silently and thus sends no ID to the server. Fortunately
we use TypeScript in virtually every place affected by these changes, so
the code would not compile if there were mismatches between the API
expectation and what we're sending. Still, spot checking as many places
as possible both for deprecation-warning leaks and loss of functionality
is important.
## Summary by CodeRabbit
* **Refactor**
* Updated API nomenclature across the application to use "fleets"
instead of "teams" and "reports" instead of "queries" in endpoint paths
and request/response payloads.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-03-13 03:26:48 +00:00
|
|
|
fleet_id: teamId,
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
status: selectedStatus,
|
|
|
|
|
page: pageNumber,
|
|
|
|
|
per_page: DEFAULT_PAGE_SIZE,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const { data, isFetching: updating } = useQuery<
|
|
|
|
|
IScriptBatchSummariesResponse,
|
|
|
|
|
Error,
|
|
|
|
|
IScriptBatchSummariesResponse
|
|
|
|
|
>([queryKey], () => scriptsAPI.getRunScriptBatchSummaries(queryKey), {
|
|
|
|
|
keepPreviousData: true,
|
|
|
|
|
});
|
2025-08-14 15:10:45 +00:00
|
|
|
|
2025-08-15 13:24:55 +00:00
|
|
|
const handleTabChange = useCallback(
|
|
|
|
|
(index: number) => {
|
|
|
|
|
const newStatus = STATUS_BY_INDEX[index];
|
|
|
|
|
|
|
|
|
|
const newParams = new URLSearchParams(location?.search);
|
|
|
|
|
newParams.set("status", newStatus);
|
|
|
|
|
const newQuery = newParams.toString();
|
|
|
|
|
|
|
|
|
|
router.push(
|
|
|
|
|
PATHS.CONTROLS_SCRIPTS_BATCH_PROGRESS.concat(
|
|
|
|
|
newQuery ? `?${newQuery}` : ""
|
|
|
|
|
)
|
|
|
|
|
);
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
setPageNumber(0);
|
2025-08-15 13:24:55 +00:00
|
|
|
},
|
|
|
|
|
[location?.search, router]
|
|
|
|
|
);
|
|
|
|
|
|
2025-08-14 15:10:45 +00:00
|
|
|
const onClickRow = (r: IScriptBatchSummaryV2) => {
|
2025-09-22 23:09:35 +00:00
|
|
|
// explicitly including the status param here avoids triggering the script details page's effect
|
|
|
|
|
// which would add it automatically, muddying browser history and preventing smooth forward/back navigation
|
|
|
|
|
router.push(
|
|
|
|
|
PATHS.CONTROLS_SCRIPTS_BATCH_DETAILS(r.batch_execution_id).concat(
|
|
|
|
|
"?status=ran"
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-08-14 15:10:45 +00:00
|
|
|
return r;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const renderRow = (summary: IScriptBatchSummaryV2) => {
|
|
|
|
|
const {
|
|
|
|
|
script_name,
|
|
|
|
|
targeted_host_count,
|
|
|
|
|
ran_host_count,
|
|
|
|
|
errored_host_count,
|
|
|
|
|
} = summary;
|
|
|
|
|
const when = getWhen(summary);
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2025-10-08 17:31:57 +00:00
|
|
|
<ListItem title={script_name} details={when} />
|
2025-08-14 15:10:45 +00:00
|
|
|
{summary.status !== "scheduled" && (
|
|
|
|
|
<div className={`${baseClass}__row-right`}>
|
2025-10-08 17:31:57 +00:00
|
|
|
<div className={`${baseClass}__status-count`}>
|
2025-08-14 15:10:45 +00:00
|
|
|
{ran_host_count + errored_host_count} / {targeted_host_count}{" "}
|
|
|
|
|
hosts
|
|
|
|
|
</div>
|
|
|
|
|
<ProgressBar
|
|
|
|
|
sections={[
|
|
|
|
|
{
|
|
|
|
|
// results
|
|
|
|
|
color: COLORS["status-success"],
|
|
|
|
|
portion: ran_host_count / targeted_host_count,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// errors
|
|
|
|
|
color: COLORS["status-error"],
|
|
|
|
|
portion: errored_host_count / targeted_host_count,
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
<div className={`${baseClass}__row-errors`}>
|
|
|
|
|
<Icon
|
|
|
|
|
name="error-outline"
|
|
|
|
|
color="ui-fleet-black-50"
|
|
|
|
|
size="small"
|
|
|
|
|
/>{" "}
|
|
|
|
|
<div>{errored_host_count}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-15 13:24:55 +00:00
|
|
|
// Reset to first tab if status is invalid.
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!isValidScriptBatchStatus(statusParam)) {
|
|
|
|
|
handleTabChange(0);
|
|
|
|
|
}
|
|
|
|
|
}, [statusParam, handleTabChange]);
|
|
|
|
|
|
2025-08-14 15:10:45 +00:00
|
|
|
const renderTabContent = (status: ScriptBatchStatus) => {
|
2025-08-15 13:24:55 +00:00
|
|
|
// If we're switching to a new tab, show the loading spinner
|
|
|
|
|
// while we get the first page and # of results.
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
if (updating) {
|
2025-08-15 13:24:55 +00:00
|
|
|
return (
|
|
|
|
|
<div className={`${baseClass}__loading`}>
|
|
|
|
|
<Spinner />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
const count = data?.count || 0;
|
|
|
|
|
const rows = data?.batch_executions || [];
|
|
|
|
|
|
|
|
|
|
if (count === 0) {
|
2025-08-14 15:10:45 +00:00
|
|
|
return getEmptyState(status);
|
|
|
|
|
}
|
2025-08-15 13:24:55 +00:00
|
|
|
|
2025-08-14 15:10:45 +00:00
|
|
|
return (
|
|
|
|
|
<div className={`${baseClass}__tab-content`}>
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
{!updating && count && (
|
2025-08-14 15:10:45 +00:00
|
|
|
<div className={`${baseClass}__status-count`}>
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
{count} batch script{count > 1 ? "s" : ""}
|
2025-08-14 15:10:45 +00:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<PaginatedList<IScriptBatchSummaryV2>
|
2025-08-25 14:15:12 +00:00
|
|
|
ref={paginatedListRef}
|
Refactor paginated list to use UseQuery (#33669)
# Details
As mentioned in a previous front-end sync, I realized after having to
add a `reload()` method to the `PaginatedList` imperative handle that I
had strayed too far from the path. The original concept for this
component was for it to be fully self-contained, so the parent didn't
have to concern itself with pagination at all other than being told what
page to load. But the addition of an `onChangePage` property isn't a
tragedy and is totally worth the reduction in code, consistency with use
of `useQuery` elsewhere and React best practice of passing data from
parent to child.
This refactor still retains the use of the imperative handle for
querying the "dirty state" of the list, so parents don't have to manage
that state themselves.
## Testing
- [X] Added/updated automated tests
Updated PaginatedList tests as needed. Also confirmed that tests for the
upstream components (PoliciesPaginatedList, Secrets, RunBatchScriptModal
and ScriptBatchProgress) all passed without any modification.
- [X] QA'd all new/changed functionality manually
Added enough data to paginate each of the components that uses
PaginatedList, confirmed pagination still works and dirty state
functionality (in PoliciesPaginatedList) still works. Also confirmed
add/delete functionality works as expected in Secrets.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- New Features
- Consistent, responsive pagination across Scripts, Secrets, Hosts, and
Policies pages with clearer loading and empty states.
- Bug Fixes
- Delete Secret modal now reliably displays errors and refreshes the
list after deletion.
- Refactor
- Unified data-driven pagination flow for improved performance and
smoother navigation.
- Simplified list interactions by removing manual reloads.
- Tests
- Updated tests to align with the new pagination behavior and data flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-10-28 16:27:05 +00:00
|
|
|
count={count}
|
|
|
|
|
data={rows}
|
|
|
|
|
pageSize={DEFAULT_PAGE_SIZE}
|
|
|
|
|
currentPage={pageNumber}
|
|
|
|
|
onChangePage={setPageNumber}
|
|
|
|
|
isLoading={updating}
|
2025-08-14 15:10:45 +00:00
|
|
|
onClickRow={onClickRow}
|
|
|
|
|
renderItemRow={renderRow}
|
|
|
|
|
useCheckBoxes={false}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div className={baseClass}>
|
|
|
|
|
<SectionHeader title="Batch progress" alignLeftHeaderVertically />
|
2025-09-29 17:10:41 +00:00
|
|
|
<TabNav secondary>
|
2025-08-14 15:10:45 +00:00
|
|
|
<Tabs
|
|
|
|
|
selectedIndex={STATUS_BY_INDEX.indexOf(selectedStatus)}
|
|
|
|
|
onSelect={handleTabChange}
|
|
|
|
|
>
|
|
|
|
|
<TabList>
|
|
|
|
|
<Tab>
|
|
|
|
|
<TabText>Started</TabText>
|
|
|
|
|
</Tab>
|
|
|
|
|
<Tab>
|
|
|
|
|
<TabText>Scheduled</TabText>
|
|
|
|
|
</Tab>
|
|
|
|
|
<Tab>
|
|
|
|
|
<TabText>Finished</TabText>
|
|
|
|
|
</Tab>
|
|
|
|
|
</TabList>
|
|
|
|
|
<TabPanel>{renderTabContent(STATUS_BY_INDEX[0])}</TabPanel>
|
|
|
|
|
<TabPanel>{renderTabContent(STATUS_BY_INDEX[1])}</TabPanel>
|
|
|
|
|
<TabPanel>{renderTabContent(STATUS_BY_INDEX[2])}</TabPanel>
|
|
|
|
|
</Tabs>
|
|
|
|
|
</TabNav>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ScriptBatchProgress;
|