Skip to content

A couple naming improvements and cleanups #27321

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

Merged
merged 2 commits into from
Mar 20, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ interface ILiveResultsHeadingProps {
onClickDone: (evt: React.MouseEvent<HTMLButtonElement>) => void;
onClickRunAgain: (evt: React.MouseEvent<HTMLButtonElement>) => void;
onClickStop: (evt: React.MouseEvent<HTMLButtonElement>) => void;
/** Whether this is a live run of a policy. If not, it is of a query. */
isPolicy?: boolean;
/** Whether this is a live run of a policy or a query */
resultsType?: "query" | "policy";
}

const LiveResultsHeading = ({
Expand All @@ -79,16 +79,16 @@ const LiveResultsHeading = ({
onClickDone,
onClickRunAgain,
onClickStop,
isPolicy = false,
resultsType = "query",
}: ILiveResultsHeadingProps) => {
const percentResponded =
numHostsTargeted > 0
? Math.round((numHostsResponded / numHostsTargeted) * 100)
: 0;

const PAGE_TITLES = {
RUNNING: `Running ${isPolicy ? "policy" : "query"}`,
FINISHED: `${isPolicy ? "Policy" : "Query"} finished`,
RUNNING: `Running ${resultsType}`,
FINISHED: `${resultsType[0].toUpperCase()}${resultsType.slice(1)} finished`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or use Lodash upperFirst()

};

const pageTitle = isFinished ? PAGE_TITLES.FINISHED : PAGE_TITLES.RUNNING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const PolicyResults = ({
onClickDone={onQueryDone}
onClickRunAgain={onRunQuery}
onClickStop={onStopQuery}
isPolicy
resultsType="policy"
/>
<TabNav>
<Tabs selectedIndex={navTabIndex} onSelect={(i) => setNavTabIndex(i)}>
Expand Down
2 changes: 2 additions & 0 deletions frontend/pages/policies/PolicyPage/screens/RunQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ const RunQuery = ({
websocket = new SockJS(`${BASE_URL}/v1/fleet/results`, undefined, {});
websocket.onopen = () => {
setupDistributedQuery(websocket);
// `prevCampaignState` at this point is the default state. Update that with what we get from
// the API response
setCampaignState((prevCampaignState) => ({
...prevCampaignState,
campaign: { ...prevCampaignState.campaign, returnedCampaign },
Expand Down
2 changes: 2 additions & 0 deletions frontend/pages/queries/live/screens/RunQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const RunQuery = ({
websocket = new SockJS(`${BASE_URL}/v1/fleet/results`, undefined, {});
websocket.onopen = () => {
setupDistributedQuery(websocket);
// `prevCampaignState` at this point is the default state. Update that with what we get from
// the API response
setCampaignState((prevCampaignState) => ({
...prevCampaignState,
campaign: { ...prevCampaignState.campaign, returnedCampaign },
Expand Down
Loading