Skip to content

Commit

Permalink
Update mac settings components to os settings components (#14570)
Browse files Browse the repository at this point in the history
update the mac settings components naming to be less specific to mac os

- [x] Manual QA for all new/changed functionality
  • Loading branch information
ghernandez345 authored Nov 7, 2023
1 parent 3bfafcd commit eacf9cb
Show file tree
Hide file tree
Showing 22 changed files with 60 additions and 63 deletions.
18 changes: 9 additions & 9 deletions frontend/pages/hosts/details/DeviceUserPage/DeviceUserPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import FleetIcon from "../../../../../assets/images/fleet-avatar-24x24@2x.png";
import PolicyDetailsModal from "../cards/Policies/HostPoliciesTable/PolicyDetailsModal";
import AutoEnrollMdmModal from "./AutoEnrollMdmModal";
import ManualEnrollMdmModal from "./ManualEnrollMdmModal";
import MacSettingsModal from "../MacSettingsModal";
import OSSettingsModal from "../OSSettingsModal";
import ResetKeyModal from "./ResetKeyModal";
import BootstrapPackageModal from "../HostDetailsPage/modals/BootstrapPackageModal";

Expand Down Expand Up @@ -78,7 +78,7 @@ const DeviceUserPage = ({
null
);
const [showPolicyDetailsModal, setShowPolicyDetailsModal] = useState(false);
const [showMacSettingsModal, setShowMacSettingsModal] = useState(false);
const [showOSSettingsModal, setShowOSSettingsModal] = useState(false);
const [showBootstrapPackageModal, setShowBootstrapPackageModal] = useState(
false
);
Expand Down Expand Up @@ -264,9 +264,9 @@ const DeviceUserPage = ({
name: host?.mdm.macos_setup?.bootstrap_package_name,
};

const toggleMacSettingsModal = useCallback(() => {
setShowMacSettingsModal(!showMacSettingsModal);
}, [showMacSettingsModal, setShowMacSettingsModal]);
const toggleOSSettingsModal = useCallback(() => {
setShowOSSettingsModal(!showOSSettingsModal);
}, [showOSSettingsModal, setShowOSSettingsModal]);

const onCancelPolicyDetailsModal = useCallback(() => {
setShowPolicyDetailsModal(!showPolicyDetailsModal);
Expand Down Expand Up @@ -411,7 +411,7 @@ const DeviceUserPage = ({
diskEncryptionEnabled={host?.disk_encryption_enabled}
bootstrapPackageData={bootstrapPackageData}
isPremiumTier={isPremiumTier}
toggleMacSettingsModal={toggleMacSettingsModal}
toggleOSSettingsModal={toggleOSSettingsModal}
hostMdmProfiles={host?.mdm.profiles ?? []}
mdmName={deviceMacAdminsData?.mobile_device_management?.name}
showRefetchSpinner={showRefetchSpinner}
Expand Down Expand Up @@ -488,11 +488,11 @@ const DeviceUserPage = ({
policy={selectedPolicy}
/>
)}
{showMacSettingsModal && (
<MacSettingsModal
{showOSSettingsModal && (
<OSSettingsModal
platform={host?.platform}
hostMDMData={host?.mdm}
onClose={toggleMacSettingsModal}
onClose={toggleOSSettingsModal}
/>
)}
{showBootstrapPackageModal &&
Expand Down
19 changes: 9 additions & 10 deletions frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import DeleteHostModal from "../../components/DeleteHostModal";

import DiskEncryptionKeyModal from "./modals/DiskEncryptionKeyModal";
import HostActionDropdown from "./HostActionsDropdown/HostActionsDropdown";
import MacSettingsModal from "../MacSettingsModal";
import OSSettingsModal from "../OSSettingsModal";
import BootstrapPackageModal from "./modals/BootstrapPackageModal";
import SelectQueryModal from "./modals/SelectQueryModal";
import { isSupportedPlatform } from "./modals/DiskEncryptionKeyModal/DiskEncryptionKeyModal";
Expand Down Expand Up @@ -141,7 +141,7 @@ const HostDetailsPage = ({
const [showTransferHostModal, setShowTransferHostModal] = useState(false);
const [showSelectQueryModal, setShowSelectQueryModal] = useState(false);
const [showPolicyDetailsModal, setPolicyDetailsModal] = useState(false);
const [showMacSettingsModal, setShowMacSettingsModal] = useState(false);
const [showOSSettingsModal, setShowOSSettingsModal] = useState(false);
const [showUnenrollMdmModal, setShowUnenrollMdmModal] = useState(false);
const [showDiskEncryptionModal, setShowDiskEncryptionModal] = useState(false);
const [showBootstrapPackageModal, setShowBootstrapPackageModal] = useState(
Expand Down Expand Up @@ -420,9 +420,9 @@ const HostDetailsPage = ({
[showPolicyDetailsModal, setPolicyDetailsModal, setSelectedPolicy]
);

const toggleMacSettingsModal = useCallback(() => {
setShowMacSettingsModal(!showMacSettingsModal);
}, [showMacSettingsModal, setShowMacSettingsModal]);
const toggleOSSettingsModal = useCallback(() => {
setShowOSSettingsModal(!showOSSettingsModal);
}, [showOSSettingsModal, setShowOSSettingsModal]);

const toggleBootstrapPackageModal = useCallback(() => {
setShowBootstrapPackageModal(!showBootstrapPackageModal);
Expand Down Expand Up @@ -691,8 +691,7 @@ const HostDetailsPage = ({
bootstrapPackageData={bootstrapPackageData}
isPremiumTier={isPremiumTier}
isSandboxMode={isSandboxMode}
isOnlyObserver={isOnlyObserver}
toggleMacSettingsModal={toggleMacSettingsModal}
toggleOSSettingsModal={toggleOSSettingsModal}
toggleBootstrapPackageModal={toggleBootstrapPackageModal}
hostMdmProfiles={host?.mdm.profiles ?? []}
mdmName={mdm?.name}
Expand Down Expand Up @@ -824,11 +823,11 @@ const HostDetailsPage = ({
policy={selectedPolicy}
/>
)}
{showMacSettingsModal && (
<MacSettingsModal
{showOSSettingsModal && (
<OSSettingsModal
platform={host?.platform}
hostMDMData={host?.mdm}
onClose={toggleMacSettingsModal}
onClose={toggleOSSettingsModal}
/>
)}
{showUnenrollMdmModal && !!host && (
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion frontend/pages/hosts/details/MacSettingsModal/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import Button from "components/buttons/Button";
import Modal from "components/Modal";
import { IHostMdmData } from "interfaces/host";

import MacSettingsTable from "./MacSettingsTable";
import { generateTableData } from "./MacSettingsTable/MacSettingsTableConfig";
import OSSettingsTable from "./OSSettingsTable";
import { generateTableData } from "./OSSettingsTable/OSSettingsTableConfig";

interface IMacSettingsModalProps {
interface IOSSettingsModalProps {
platform?: string;
hostMDMData?: IHostMdmData;
onClose: () => void;
}

const baseClass = "mac-settings-modal";
const baseClass = "os-settings-modal";

const MacSettingsModal = ({
const OSSettingsModal = ({
platform,
hostMDMData,
onClose,
}: IMacSettingsModalProps) => {
}: IOSSettingsModalProps) => {
// the caller should ensure that hostMDMData is not undefined and that platform is "windows" or
// "darwin", otherwise we will allow an empty modal will be rendered.
// https://fleetdm.com/handbook/company/why-this-way#why-make-it-obvious-when-stuff-breaks
Expand All @@ -36,7 +36,7 @@ const MacSettingsModal = ({
width="large"
>
<>
<MacSettingsTable tableData={memoizedTableData || []} />
<OSSettingsTable tableData={memoizedTableData || []} />
<div className="modal-cta-wrap">
<Button variant="brand" onClick={onClose}>
Done
Expand All @@ -47,4 +47,4 @@ const MacSettingsModal = ({
);
};

export default MacSettingsModal;
export default OSSettingsModal;
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from "react";
import { render, screen } from "@testing-library/react";
import { createCustomRenderer } from "test/test-utils";
import { MacMdmProfileOperationType } from "interfaces/mdm";
import MacSettingStatusCell from "./MacSettingStatusCell";
import OSSettingStatusCell from "./OSSettingStatusCell";

describe("Mac setting status cell", () => {
describe("OS setting status cell", () => {
it("Correctly displays the status text of a profile", () => {
const status = "verifying";
const operationType: MacMdmProfileOperationType = "install";

render(
<MacSettingStatusCell
<OSSettingStatusCell
profileName="Test Profile"
status={status}
operationType={operationType}
Expand All @@ -27,7 +27,7 @@ describe("Mac setting status cell", () => {
const customRender = createCustomRenderer();

const { user } = customRender(
<MacSettingStatusCell
<OSSettingStatusCell
profileName="Test Profile"
status={status}
operationType={operationType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import {
import {
isMdmProfileStatus,
OsSettingsTableStatusValue,
} from "../MacSettingsTableConfig";
} from "../OSSettingsTableConfig";
import TooltipContent, {
TooltipInnerContentFunc,
TooltipInnerContentOption,
} from "./components/Tooltip/TooltipContent";
import TooltipInnerContentActionRequired from "./components/Tooltip/ActionRequired";

const baseClass = "mac-setting-status-cell";
const baseClass = "os-setting-status-cell";

type ProfileDisplayOption = {
statusText: string;
Expand Down Expand Up @@ -134,17 +134,17 @@ const WINDOWS_DISK_ENCRYPTION_DISPLAY_CONFIG: WindowsDiskEncryptionDisplayConfig
},
};

interface IMacSettingStatusCellProps {
interface IOSSettingStatusCellProps {
status: OsSettingsTableStatusValue;
operationType: MacMdmProfileOperationType | null;
profileName: string;
}

const MacSettingStatusCell = ({
const OSSettingStatusCell = ({
status,
operationType,
profileName = "",
}: IMacSettingStatusCellProps) => {
}: IOSSettingStatusCellProps) => {
let displayOption: ProfileDisplayOption = null;

// windows hosts do not have an operation type at the moment and their display options are
Expand Down Expand Up @@ -213,4 +213,4 @@ const MacSettingStatusCell = ({
// graceful error - this state should not be reached based on the API spec
return <TextCell value="Unrecognized" />;
};
export default MacSettingStatusCell;
export default OSSettingStatusCell;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.mac-settings-indicator {
.os-setting-status-cell {
display: flex;
gap: 4px;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./OSSettingStatusCell";
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from "react";
import TableContainer from "components/TableContainer";

import tableHeaders, { ITableRowOsSettings } from "./MacSettingsTableConfig";
import tableHeaders, { ITableRowOsSettings } from "./OSSettingsTableConfig";

const baseClass = "macsettings-table";
const baseClass = "os-settings-table";

interface IMacSettingsTableProps {
interface IOSSettingsTableProps {
tableData?: ITableRowOsSettings[];
}

const MacSettingsTable = ({ tableData }: IMacSettingsTableProps) => {
const OSSettingsTable = ({ tableData }: IOSSettingsTableProps) => {
return (
<div className={baseClass}>
<TableContainer
Expand All @@ -27,4 +27,4 @@ const MacSettingsTable = ({ tableData }: IMacSettingsTableProps) => {
);
};

export default MacSettingsTable;
export default OSSettingsTable;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "interfaces/mdm";
import { DEFAULT_EMPTY_CELL_VALUE } from "utilities/constants";
import TruncatedTextCell from "components/TableContainer/DataTable/TruncatedTextCell";
import MacSettingStatusCell from "./MacSettingStatusCell";
import OSSettingStatusCell from "./OSSettingStatusCell";
import { generateWinDiskEncryptionProfile } from "../../helpers";

export interface ITableRowOsSettings extends Omit<IHostMdmProfile, "status"> {
Expand Down Expand Up @@ -70,7 +70,7 @@ const tableHeaders: IDataColumn[] = [
accessor: "statusText",
Cell: (cellProps: ICellProps) => {
return (
<MacSettingStatusCell
<OSSettingStatusCell
status={cellProps.row.original.status}
operationType={cellProps.row.original.operation_type}
profileName={cellProps.row.original.name}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.macsettings-table {
.os-settings-table {
.statusText {
&__cell {
white-space: nowrap;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./OSSettingsTable";
1 change: 1 addition & 0 deletions frontend/pages/hosts/details/OSSettingsModal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./OSSettingsModal";
12 changes: 5 additions & 7 deletions frontend/pages/hosts/details/cards/HostSummary/HostSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import { DEFAULT_EMPTY_CELL_VALUE } from "utilities/constants";
import StatusIndicator from "components/StatusIndicator";

import MacSettingsIndicator from "./MacSettingsIndicator";
import OSSettingsIndicator from "./OSSettingsIndicator";
import HostSummaryIndicator from "./HostSummaryIndicator";
import BootstrapPackageIndicator from "./BootstrapPackageIndicator/BootstrapPackageIndicator";
import { generateWinDiskEncryptionProfile } from "../../helpers";
Expand All @@ -41,8 +41,7 @@ interface IHostSummaryProps {
diskEncryptionEnabled?: boolean;
isPremiumTier?: boolean;
isSandboxMode?: boolean;
isOnlyObserver?: boolean;
toggleMacSettingsModal?: () => void;
toggleOSSettingsModal?: () => void;
toggleBootstrapPackageModal?: () => void;
hostMdmProfiles?: IHostMdmProfile[];
mdmName?: string;
Expand All @@ -61,8 +60,7 @@ const HostSummary = ({
diskEncryptionEnabled,
isPremiumTier,
isSandboxMode = false,
isOnlyObserver,
toggleMacSettingsModal,
toggleOSSettingsModal,
toggleBootstrapPackageModal,
hostMdmProfiles,
mdmName,
Expand Down Expand Up @@ -231,9 +229,9 @@ const HostSummary = ({
hostMdmProfiles &&
hostMdmProfiles.length > 0 && ( // 2 - host has at least one setting (profile) enforced
<HostSummaryIndicator title="OS settings">
<MacSettingsIndicator
<OSSettingsIndicator
profiles={hostMdmProfiles}
onClick={toggleMacSettingsModal}
onClick={toggleOSSettingsModal}
/>
</HostSummaryIndicator>
)}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Icon from "components/Icon";
import Button from "components/buttons/Button";
import { IconNames } from "components/icons";

const baseClass = "mac-settings-indicator";
const baseClass = "os-settings-indicator";

type MdmProfileStatusForDisplay =
| "Failed"
Expand Down Expand Up @@ -106,14 +106,14 @@ const getHostProfilesStatusForDisplay = (
}
};

interface IMacSettingsIndicatorProps {
interface IOSSettingsIndicatorProps {
profiles: IHostMdmProfile[];
onClick?: () => void;
}
const MacSettingsIndicator = ({
const OSSettingsIndicator = ({
profiles,
onClick,
}: IMacSettingsIndicatorProps): JSX.Element => {
}: IOSSettingsIndicatorProps): JSX.Element => {
if (!profiles.length) {
// the caller should ensure that this never happens, but just in case we return a default
// to make it more obvious that something is wrong.
Expand Down Expand Up @@ -157,4 +157,4 @@ const MacSettingsIndicator = ({
);
};

export default MacSettingsIndicator;
export default OSSettingsIndicator;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.mac-setting-status-cell {
.os-settings-indicator {
display: flex;
gap: 4px;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./OSSettingsIndicator";

0 comments on commit eacf9cb

Please sign in to comment.