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
2 changes: 2 additions & 0 deletions changes/40177-config-profile-name-status
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Added logging of profile names alongside MDM commands installing or removing them
* Added indication in the UI when a profile command was deferred ("NotNow" status)
2 changes: 2 additions & 0 deletions frontend/__mocks__/commandMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const DEFAULT_COMMAND_MOCK: ICommand = {
updated_at: "2024-01-01T00:00:00Z",
request_type: "InstallProfile",
hostname: "default-hostname",
name: null,
};

export const createMockCommand = (overrides?: Partial<ICommand>): ICommand => ({
Expand Down Expand Up @@ -47,6 +48,7 @@ const DEFAULT_COMMAND_RESULT_MOCK: ICommandResult = {
<Status>Acknowledged</Status>
<Message>Installation complete</Message>
</Result>`),
name: null,
};

/**
Expand Down
4 changes: 2 additions & 2 deletions frontend/interfaces/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface ICommand {
updated_at: string;
request_type: string;
hostname: string;
name: string | null; // Profile name when command is for installing/removing a macOS profile
}

/**
Expand All @@ -30,10 +31,9 @@ export interface ICommandResult {
payload: string;
/** Base64-encoded string containing the MDM command response */
result: string;
name: string | null; // Profile name when command is for installing/removing a macOS profile
/** ResultsMetadata contains command-specific metadata.
* VPP install commands include a "software_installed" boolean and
* "vpp_verify_timeout_seconds" integer. */
results_metadata?: Record<string, unknown>;
}

export type IMDMCommandResult = ICommandResult;
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import commandApi, {
IGetHostCommandResultsQueryKey,
} from "services/entities/command";

// @ts-ignore
import InputField from "components/forms/fields/InputField";
import Modal from "components/Modal";
import Spinner from "components/Spinner";
import DataError from "components/DataError";
import IconStatusMessage from "components/IconStatusMessage";
import { IconNames } from "components/icons";
import Textarea from "components/Textarea";
import ModalFooter from "components/ModalFooter";
import Button from "components/buttons/Button";

Expand Down Expand Up @@ -50,12 +51,19 @@ const getStatusMessage = (result: ICommandResult): React.ReactNode => {
})})`
: null;

const namePart = result.name ? (
<>
{" "}
for <b>{result.name}</b>
</>
) : null;

switch (result.status) {
case "CommandFormatError":
case "Error":
return (
<span>
The <b>{result.request_type}</b> command failed on{" "}
The <b>{result.request_type}</b> command{namePart} failed on{" "}
<b>{result.hostname}</b>
{displayTime}.
</span>
Expand All @@ -64,7 +72,7 @@ const getStatusMessage = (result: ICommandResult): React.ReactNode => {
case "Acknowledged":
return (
<span>
The <b>{result.request_type}</b> command ran on{" "}
The <b>{result.request_type}</b> command{namePart} was acknowledged by{" "}
<b>{result.hostname}</b>
{displayTime}.
</span>
Expand All @@ -73,15 +81,15 @@ const getStatusMessage = (result: ICommandResult): React.ReactNode => {
case "Pending":
return (
<span>
The <b>{result.request_type}</b> command is running or will run on{" "}
<b>{result.hostname}</b> when it comes online.
The <b>{result.request_type}</b> command{namePart} is pending on{" "}
<b>{result.hostname}</b>.
</span>
);

case "NotNow":
return (
<span>
The <b>{result.request_type}</b> command didn&apos;t run on{" "}
The <b>{result.request_type}</b> command{namePart} is deferred on{" "}
<b>{result.hostname}</b> because the host was locked or was running on
battery power while in Power Nap. Fleet will try again.
</span>
Expand Down Expand Up @@ -135,21 +143,26 @@ const ModalContent = ({
message={getStatusMessage(result)}
/>
{!!result.payload && (
<Textarea label="Request payload:" variant="code">
{result.payload}
</Textarea>
<InputField
type="textarea"
label="Request payload:"
value={result.payload}
readOnly
enableCopy
/>
)}
{!!result.result && (
<Textarea
<InputField
type="textarea"
label={
<>
Response from <b>{result.hostname}</b>:
</>
}
variant="code"
>
{result.result}
</Textarea>
value={result.result}
readOnly
enableCopy
/>
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
flex-direction: column;
gap: $pad-large;
padding-bottom: $pad-small;

.textarea-wrapper {
gap: $pad-small;
}
}

// shortening the hight of the textarea
// so the modal height stays within the viewport
.textarea--code {
.input-field__textarea {
// shortening the height of the textarea
// so the modal height stays within the viewport
max-height: 200px;
height: auto;
field-sizing: content;
overflow-y: auto;
background-color: $ui-off-white;
font-family: "SourceCodePro", $monospace;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,45 @@ interface ICommandItemProps {
onShowDetails: ShowCommandDetailsHandler;
}

const CommandItem = ({ command, onShowDetails }: ICommandItemProps) => {
const { command_status, request_type, updated_at } = command;
const getStatusText = (command: ICommand): string => {
const { command_status, status } = command;

// Differentiate NotNow from regular Pending
if (status === "NotNow") {
return "is deferred";
}

let statusVerb = "";
switch (command_status) {
case "pending":
statusVerb = "will run";
break;
case "ran":
return "is pending";
case "failed":
statusVerb = command_status;
break;
return "failed";
case "ran":
default:
statusVerb = "ran";
return "was acknowledged";
}
};

const CommandItem = ({ command, onShowDetails }: ICommandItemProps) => {
const { request_type, updated_at, name } = command;

const statusText = getStatusText(command);

const onShowCommandDetails = (e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation();
onShowDetails(command);
};

const activityText = name ? (
<>
The <b>{request_type}</b> command for <b>{name}</b> {statusText}.
</>
) : (
<>
The <b>{request_type}</b> command {statusText}.
</>
);

return (
<FeedListItem
className={baseClass}
Expand All @@ -47,7 +65,7 @@ const CommandItem = ({ command, onShowDetails }: ICommandItemProps) => {
createdAt={new Date(updated_at)}
onClickFeedItem={onShowCommandDetails}
>
The <b>{request_type}</b> command {statusVerb}.
{activityText}
</FeedListItem>
);
};
Expand Down
9 changes: 6 additions & 3 deletions server/datastore/mysql/apple_mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,8 @@ SELECT
ncr.result,
ncr.updated_at,
nc.request_type,
nc.command as payload
nc.command as payload,
nc.name
FROM
nano_command_results ncr
INNER JOIN
Expand Down Expand Up @@ -1085,7 +1086,8 @@ SELECT
COALESCE(ncr.status, 'Pending') AS status,
request_type,
nc.command AS payload,
COALESCE(ncr.result, '') AS result
COALESCE(ncr.result, '') AS result,
nc.name
FROM
nano_enrollment_queue nq
JOIN nano_commands nc ON nq.command_uuid = nc.command_uuid
Expand Down Expand Up @@ -1130,7 +1132,8 @@ SELECT
COALESCE(nvq.result_updated_at, nvq.created_at) as updated_at,
nvq.request_type,
h.hostname,
h.team_id
h.team_id,
nvq.name
FROM
nano_view_queue nvq
INNER JOIN
Expand Down
15 changes: 10 additions & 5 deletions server/datastore/mysql/mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ SELECT
COALESCE(nvq.result_updated_at, nvq.created_at) as updated_at,
nvq.request_type as request_type,
h.hostname,
h.team_id
h.team_id,
nvq.name
FROM
nano_view_queue nvq
INNER JOIN
Expand All @@ -67,7 +68,8 @@ SELECT
COALESCE(wmc.updated_at, wmc.created_at) as updated_at,
wmc.target_loc_uri as request_type,
h.hostname,
h.team_id
h.team_id,
NULL as name
FROM windows_mdm_commands wmc
LEFT JOIN windows_mdm_command_queue wmcq ON wmcq.command_uuid = wmc.command_uuid
LEFT JOIN windows_mdm_command_results wmcr ON wmc.command_uuid = wmcr.command_uuid
Expand Down Expand Up @@ -225,7 +227,8 @@ SELECT
WHEN COALESCE(NULLIF(ncr.status, ''), 'Pending') = 'Error' THEN 'failed'
ELSE 'pending'
END AS command_status,
request_type
request_type,
nc.name
FROM
nano_enrollment_queue nq
JOIN nano_commands nc ON nq.command_uuid = nc.command_uuid
Expand All @@ -251,7 +254,8 @@ WHERE
wc.created_at AS updated_at,
'101' AS status,
'pending' AS command_status,
wc.target_loc_uri AS request_type
wc.target_loc_uri AS request_type,
NULL AS name
FROM
windows_mdm_command_queue wq
JOIN mdm_windows_enrollments mwe ON mwe.id = wq.enrollment_id
Expand Down Expand Up @@ -287,7 +291,8 @@ WHERE
) AS UNSIGNED
) >= 400 THEN 'failed'
END AS command_status,
wc.target_loc_uri AS request_type
wc.target_loc_uri AS request_type,
NULL AS name
FROM
windows_mdm_command_results wcr
JOIN mdm_windows_enrollments mwe ON mwe.id = wcr.enrollment_id
Expand Down
Loading
Loading