-
Notifications
You must be signed in to change notification settings - Fork 843
UI: Add macOS settings (profiles) indicator and modal with data table #9809
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
jacobshandling
merged 26 commits into
fleetdm:main
from
jacobshandling:add-macOS-settings-items
Feb 22, 2023
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f9f219b
Create Pending icon; initial scaffold for macOS settings indicator in…
jacobshandling 7226518
work on mac settings indicator and modal
jacobshandling c282edf
build until mac settings table scaffold works in modal
jacobshandling 23ddc9f
Conditionally determine icon and tooltip text
jacobshandling 90cf2c9
Create settings indicator
jacobshandling 7b7cdb0
mock mac setting data - will change to fit API
jacobshandling 1d6fc3d
adjust style of mac settings indicator in host summary
jacobshandling 16c5411
make indicator styling more specific; integrate Sarah's feedback
jacobshandling 822b1c1
wire up with planned API structure
jacobshandling b539bd9
small style and copy changes
jacobshandling afece10
logic for macsettings status
jacobshandling f266128
correctly tie tooltips to unique ids
jacobshandling 561b4d4
style adjustments
jacobshandling b561375
style adjustments; error tooltip
jacobshandling 6980103
change file
jacobshandling de675a5
Add conditions for displaying macOS settings indicator; misc cleanup
jacobshandling 2696572
update MacSettingsTable to use DEFAULT_EMPTY_CELL_VALUE
jacobshandling 5ca43c3
Retool for new API; gracefully handle unexpected profiles
jacobshandling 270d269
tests
jacobshandling c6eb53c
remove faulty test
jacobshandling 3a07b59
Merge branch 'main' into add-macOS-settings-items
jacobshandling e5e8092
specify type name
jacobshandling 06277bf
remove mock host profiles data
jacobshandling d03de47
remove unnecessary isLoading props and EmptyTable todo
jacobshandling b4d5f64
remove empty table todo
jacobshandling 878bad5
Adjust modals width
jacobshandling File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Create a macOS settings indicator and modal on the host details and device user pages. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
frontend/components/TableContainer/DataTable/TruncatedTextCell/_styles.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import React from "react"; | ||
| import { COLORS, Colors } from "styles/var/colors"; | ||
| import { ICON_SIZES, IconSizes } from "styles/var/icon_sizes"; | ||
|
|
||
| interface IPendingProps { | ||
| size?: IconSizes; | ||
| color?: Colors; | ||
| } | ||
|
|
||
| const Pending = ({ | ||
| size = "medium", | ||
| color = "ui-fleet-black-50", | ||
| }: IPendingProps) => { | ||
| return ( | ||
| <svg | ||
| width={ICON_SIZES[size]} | ||
| height={ICON_SIZES[size]} | ||
| viewBox="0 0 16 17" | ||
| fill="none" | ||
| > | ||
| <path | ||
| fillRule="evenodd" | ||
| clipRule="evenodd" | ||
| d="M8 16.5C12.4183 16.5 16 12.9183 16 8.5C16 4.08172 12.4183 0.5 8 0.5C3.58172 0.5 0 4.08172 0 8.5C0 12.9183 3.58172 16.5 8 16.5ZM4.6665 9.5C5.21879 9.5 5.6665 9.05229 5.6665 8.5C5.6665 7.94772 5.21879 7.5 4.6665 7.5C4.11422 7.5 3.6665 7.94772 3.6665 8.5C3.6665 9.05229 4.11422 9.5 4.6665 9.5ZM8.6665 8.5C8.6665 9.05229 8.21879 9.5 7.6665 9.5C7.11422 9.5 6.6665 9.05229 6.6665 8.5C6.6665 7.94772 7.11422 7.5 7.6665 7.5C8.21879 7.5 8.6665 7.94772 8.6665 8.5ZM10.6665 9.5C11.2188 9.5 11.6665 9.05229 11.6665 8.5C11.6665 7.94772 11.2188 7.5 10.6665 7.5C10.1142 7.5 9.6665 7.94772 9.6665 8.5C9.6665 9.05229 10.1142 9.5 10.6665 9.5Z" | ||
| fill={COLORS[color]} | ||
| /> | ||
| </svg> | ||
| ); | ||
| }; | ||
|
|
||
| export default Pending; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ import parseOsVersion from "./modals/OSPolicyModal/helpers"; | |
|
|
||
| import DiskEncryptionKeyModal from "./modals/DiskEncryptionKeyModal"; | ||
| import HostActionDropdown from "./HostActionsDropdown/HostActionsDropdown"; | ||
| import MacSettingsModal from "../MacSettingsModal"; | ||
|
|
||
| const baseClass = "host-details"; | ||
|
|
||
|
|
@@ -127,6 +128,7 @@ const HostDetailsPage = ({ | |
| const [showQueryHostModal, setShowQueryHostModal] = useState(false); | ||
| const [showPolicyDetailsModal, setPolicyDetailsModal] = useState(false); | ||
| const [showOSPolicyModal, setShowOSPolicyModal] = useState(false); | ||
| const [showMacSettingsModal, setShowMacSettingsModal] = useState(false); | ||
| const [showUnenrollMdmModal, setShowUnenrollMdmModal] = useState(false); | ||
| const [showDiskEncryptionModal, setShowDiskEncryptionModal] = useState(false); | ||
| const [selectedPolicy, setSelectedPolicy] = useState<IHostPolicy | null>( | ||
|
|
@@ -145,7 +147,6 @@ const HostDetailsPage = ({ | |
| ] = useState<IHostDiskEncryptionProps>({}); | ||
| const [usersState, setUsersState] = useState<{ username: string }[]>([]); | ||
| const [usersSearchString, setUsersSearchString] = useState(""); | ||
| const [hideEditMdm, setHideEditMdm] = useState<boolean>(false); | ||
|
|
||
| const { data: fleetQueries, error: fleetQueriesError } = useQuery< | ||
| IFleetQueriesResponse, | ||
|
|
@@ -388,6 +389,10 @@ const HostDetailsPage = ({ | |
| setShowOSPolicyModal(!showOSPolicyModal); | ||
| }, [showOSPolicyModal, setShowOSPolicyModal]); | ||
|
|
||
| const toggleMacSettingsModal = useCallback(() => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See related comment to DeviceUserPage |
||
| setShowMacSettingsModal(!showMacSettingsModal); | ||
| }, [showMacSettingsModal, setShowMacSettingsModal]); | ||
|
|
||
| const onCancelPolicyDetailsModal = useCallback(() => { | ||
| setPolicyDetailsModal(!showPolicyDetailsModal); | ||
| setSelectedPolicy(null); | ||
|
|
@@ -620,6 +625,9 @@ const HostDetailsPage = ({ | |
| isPremiumTier={isPremiumTier} | ||
| isOnlyObserver={isOnlyObserver} | ||
| toggleOSPolicyModal={toggleOSPolicyModal} | ||
| toggleMacSettingsModal={toggleMacSettingsModal} | ||
| hostMacSettings={host?.mdm.profiles} | ||
| mdmName={mdm?.name} | ||
| showRefetchSpinner={showRefetchSpinner} | ||
| onRefetchHost={onRefetchHost} | ||
| renderActionButtons={renderActionButtons} | ||
|
|
@@ -737,15 +745,15 @@ const HostDetailsPage = ({ | |
| osPolicyLabel={osPolicyLabel} | ||
| /> | ||
| )} | ||
| {showUnenrollMdmModal && !!host && ( | ||
| <UnenrollMdmModal | ||
| hostId={host.id} | ||
| onClose={toggleUnenrollMdmModal} | ||
| onSuccess={() => { | ||
| setHideEditMdm(true); | ||
| }} | ||
| {showMacSettingsModal && ( | ||
| <MacSettingsModal | ||
| hostMacSettings={host?.mdm.profiles} | ||
| onClose={toggleMacSettingsModal} | ||
| /> | ||
| )} | ||
| {showUnenrollMdmModal && !!host && ( | ||
| <UnenrollMdmModal hostId={host.id} onClose={toggleUnenrollMdmModal} /> | ||
| )} | ||
| {showDiskEncryptionModal && host && ( | ||
| <DiskEncryptionKeyModal | ||
| hostId={host.id} | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to use a callback here? Maybe try this instead:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was just a pattern I saw elsewhere and followed in lieu of any other input. I'll do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gillespi314 I'm actually now remembering, @ghernandez345 doesn't like directly passing
set{State}s to other components and prefers a handler of some sort, so this is in line with that. I am curious as to why he prefers that though?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I've seen both approaches and defer to Gabe if his preference is to always define handlers.
In that case you can still avoid the
useCallback, I think.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useStateguarantees that the setter is referentially stable.But the
toggleMacSettingsModalhandler function will get recreated each render. And I see that it get passed as a prop to child components. This type of set up can result in performance problems when the child component needs intensive calculations to render. https://beta.reactjs.org/reference/react/useCallback#skipping-re-rendering-of-components. So you can adduseCallbackhere to cache this particular handler prop although it might be overkill. Also note that other prop changes can still trigger the child to re-render so this alone isn't a silver bullet for performance problems if the other props aren't being tightly controlled as well. If you do go withuseCallbackon the handler here, you can use[]for the dependencies if you use theprevStateupdater function that I suggested.