-
Notifications
You must be signed in to change notification settings - Fork 848
Technician role FE changes #39494
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
Technician role FE changes #39494
Changes from all commits
ee5a684
416aaf3
937bbe5
2373975
73f4f9c
4a4d3bd
7971759
b48ec0a
fd1b66f
0f16f6f
a63df17
41b3c5f
5af7b1a
e8b2c2d
70c18d5
7dc0596
a8e260d
cb08dbf
0e74a1e
642b8f0
3226996
ce0e978
8ac7713
0f902b0
fe1111c
3b7e646
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import React, { useContext } from "react"; | ||
| import React, { useContext, useMemo } from "react"; | ||
| import { InjectedRouter, Params } from "react-router/lib/Router"; | ||
| import { useQuery } from "react-query"; | ||
|
|
||
|
|
@@ -28,7 +28,9 @@ const OSSettings = ({ | |
| params, | ||
| }: IOSSettingsProps) => { | ||
| const { section } = params; | ||
| const { currentTeam } = useContext(AppContext); | ||
| const { currentTeam, isTeamTechnician, isGlobalTechnician } = useContext( | ||
| AppContext | ||
| ); | ||
|
|
||
| // TODO: consider using useTeamIdParam hook here instead in the future | ||
| const teamId = | ||
|
|
@@ -50,12 +52,31 @@ const OSSettings = ({ | |
| } | ||
| ); | ||
|
|
||
| const DEFAULT_SETTINGS_SECTION = OS_SETTINGS_NAV_ITEMS[0]; | ||
| const filteredNavItems = useMemo(() => { | ||
| if (isTeamTechnician || isGlobalTechnician) { | ||
| return OS_SETTINGS_NAV_ITEMS.filter( | ||
| (item) => item.title !== "Certificates" | ||
| ); | ||
| } | ||
| return OS_SETTINGS_NAV_ITEMS; | ||
| }, [isTeamTechnician, isGlobalTechnician]); | ||
|
Comment on lines
+55
to
+62
Member
Author
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. Technicians can only see Disk encryption and Custom settings. |
||
|
|
||
| const DEFAULT_SETTINGS_SECTION = filteredNavItems[0]; | ||
|
|
||
| const currentFormSection = | ||
| OS_SETTINGS_NAV_ITEMS.find((item) => item.urlSection === section) ?? | ||
| filteredNavItems.find((item) => item.urlSection === section) ?? | ||
| DEFAULT_SETTINGS_SECTION; | ||
|
|
||
| // Redirect to the default section if the URL section is not in the filtered list | ||
| if ( | ||
| section && | ||
| currentFormSection === DEFAULT_SETTINGS_SECTION && | ||
| section !== DEFAULT_SETTINGS_SECTION.urlSection | ||
| ) { | ||
| router.replace(DEFAULT_SETTINGS_SECTION.path.concat(queryString)); | ||
| return null; | ||
| } | ||
|
|
||
| const CurrentCard = currentFormSection.Card; | ||
|
|
||
| return ( | ||
|
|
@@ -71,7 +92,7 @@ const OSSettings = ({ | |
| /> | ||
| <SideNav | ||
| className={`${baseClass}__side-nav`} | ||
| navItems={OS_SETTINGS_NAV_ITEMS.map((navItem) => ({ | ||
| navItems={filteredNavItems.map((navItem) => ({ | ||
| ...navItem, | ||
| path: navItem.path.concat(queryString), | ||
| }))} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import { IMdmProfile } from "interfaces/mdm"; | |
|
|
||
| import mdmAPI, { IMdmProfilesResponse } from "services/entities/mdm"; | ||
|
|
||
| import Card from "components/Card/Card"; | ||
| import CustomLink from "components/CustomLink"; | ||
| import SectionHeader from "components/SectionHeader"; | ||
| import PageDescription from "components/PageDescription"; | ||
|
|
@@ -46,7 +47,14 @@ const CustomSettings = ({ | |
| onMutation, | ||
| }: ICustomSettingsProps) => { | ||
| const { renderFlash } = useContext(NotificationContext); | ||
| const { config, isPremiumTier } = useContext(AppContext); | ||
| const { | ||
| config, | ||
| isPremiumTier, | ||
| isGlobalTechnician, | ||
| isTeamTechnician, | ||
| } = useContext(AppContext); | ||
|
|
||
| const isTechnician = isGlobalTechnician || isTeamTechnician; | ||
|
|
||
| const mdmEnabled = | ||
| config?.mdm.enabled_and_configured || | ||
|
|
@@ -163,6 +171,13 @@ const CustomSettings = ({ | |
| } | ||
|
|
||
| if (!profiles?.length) { | ||
| if (isTechnician) { | ||
| return ( | ||
| <Card className="empty-profiles"> | ||
| No configuration profiles have been added. | ||
| </Card> | ||
| ); | ||
| } | ||
| return <AddProfileCard setShowModal={setShowAddProfileModal} />; | ||
| } | ||
|
|
||
|
|
@@ -173,7 +188,9 @@ const CustomSettings = ({ | |
| listItems={profiles} | ||
| HeadingComponent={() => ( | ||
| <UploadListHeading | ||
| onClickAdd={() => setShowAddProfileModal(true)} | ||
| onClickAdd={ | ||
| isTechnician ? undefined : () => setShowAddProfileModal(true) | ||
| } | ||
|
Comment on lines
+191
to
+193
Member
Author
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. Hide Add profile button, but keep the heading. See https://www.figma.com/design/4FbBd8bVQ20fHyiUNwMqry/-35696-Add-a-new-role-for-helpdesk?node-id=5338-620&t=Dl8CHuqud0kdhYGZ-0 |
||
| entityName="Configuration profile" | ||
| createEntityText="Add profile" | ||
| /> | ||
|
|
@@ -185,6 +202,7 @@ const CustomSettings = ({ | |
| setProfileLabelsModalData={setProfileLabelsModalData} | ||
| onClickInfo={onClickInfo} | ||
| onClickDelete={onClickDelete} | ||
| isTechnician={isTechnician} | ||
| /> | ||
| )} | ||
| /> | ||
|
|
@@ -213,11 +231,13 @@ const CustomSettings = ({ | |
| variant="right-panel" | ||
| content={ | ||
| <> | ||
| Create and upload configuration profiles to apply custom settings.{" "} | ||
| {isTechnician | ||
| ? "View configuration profiles that apply custom settings." | ||
| : "Create and upload configuration profiles to apply custom settings."}{" "} | ||
| <CustomLink | ||
| newTab | ||
| text="Learn how" | ||
| url="https://fleetdm.com/learn-more-about/custom-os-settings" | ||
| text="Learn more" | ||
| url="https://fleetdm.com/guides/custom-os-settings" | ||
| /> | ||
| </> | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,7 @@ interface IProfileListItemProps { | |
| setProfileLabelsModalData: React.Dispatch< | ||
| React.SetStateAction<IMdmProfile | null> | ||
| >; | ||
| isTechnician?: boolean; | ||
| } | ||
|
|
||
| const ProfileListItem = ({ | ||
|
|
@@ -103,6 +104,7 @@ const ProfileListItem = ({ | |
| onClickInfo, | ||
| onClickDelete, | ||
| setProfileLabelsModalData, | ||
| isTechnician, | ||
| }: IProfileListItemProps) => { | ||
| const { | ||
| updated_at, | ||
|
|
@@ -180,18 +182,20 @@ const ProfileListItem = ({ | |
| > | ||
| <Icon name="download" /> | ||
| </Button> | ||
| <GitOpsModeTooltipWrapper | ||
| renderChildren={(disableChildren) => ( | ||
| <Button | ||
| disabled={disableChildren} | ||
| className={`${subClass}__action-button`} | ||
| variant="icon" | ||
| onClick={() => onClickDelete(profile)} | ||
| > | ||
| <Icon name="trash" /> | ||
| </Button> | ||
| )} | ||
| /> | ||
| {!isTechnician && ( | ||
| <GitOpsModeTooltipWrapper | ||
| renderChildren={(disableChildren) => ( | ||
| <Button | ||
| disabled={disableChildren} | ||
| className={`${subClass}__action-button`} | ||
| variant="icon" | ||
| onClick={() => onClickDelete(profile)} | ||
| > | ||
| <Icon name="trash" /> | ||
| </Button> | ||
| )} | ||
| /> | ||
| )} | ||
|
Comment on lines
+185
to
+198
Member
Author
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. Technicians can't delete a configuration profile. See https://www.figma.com/design/4FbBd8bVQ20fHyiUNwMqry/-35696-Add-a-new-role-for-helpdesk?node-id=5318-462&t=Dl8CHuqud0kdhYGZ-0 Might rename isTechnician to something more generic so that we don't couple this component to specific roles. |
||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
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.
Similar to one of the comments above.
We hide Certificates tab to Technicians, but I was still able to navigate to https://localhost:8080/controls/os-settings/certificates?team_id=0. This didn't render the Certificates content, but the Disk encryption content. However, the URL didn't reflect that, and this logic fixes it.