fleet/frontend/components/EnrollSecrets/EnrollSecretModal/EnrollSecretModal.tsx

143 lines
4.3 KiB
TypeScript
Raw Normal View History

2022-11-07 17:18:06 +00:00
import React from "react";
import { ITeam } from "interfaces/team";
import { IEnrollSecret } from "interfaces/enroll_secret";
2025-09-29 17:10:41 +00:00
import Card from "components/Card";
import EmptyTable from "components/EmptyTable";
UI - GitOps Mode: Core abstractions, first batch of applications (#26401) ## For #26229 – Part 1 ![ezgif-6bbe6d60c12ed4](https://github.com/user-attachments/assets/37a04b64-abd7-4605-b4ac-9542836ff562) - This PR contains the core abstractions, routes, API updates, and types for GitOps mode in the UI. Since this work will touch essentially every part of the Fleet UI, it is ripe for merge conflicts. To mitigate such conflicts, I'll be merging this work in a number of iterative PRs. ~To effectively gate any of this work from showing until it is all merged to `main`, [this commit](feedbb2d4c25ec2e304e1f18d409cee62f6752ed) hides the settings section that allows enabling/disabling this setting, effectively feature flagging the entire thing. In the last of these iterative PRs, that commit will be reverted to engage the entire feature. For testing purposes, reviewers can `git revert feedbb2d4c25ec2e304e1f18d409cee62f6752ed` locally~ The new settings section for this feature is feature flagged until all PRs are merged - to show the setting section while testing, run `ALLOW_GITOPS_MODE=true NODE_ENV=development yarn run webpack --progress --watch` in place of `make generate-dev` - Changes file will be added and feature flag removed in the last PR - [x] Settings page with routing, form, API integration (hidden until last PR) - [x] Activities - [x] Navbar indicator - Apply GOM conditional UI to: - [x] Manage enroll secret modal: .5 - Controls > - [x] Scripts: - Setup experience > - [x] Install software > Select software modal - [x] OS Settings > - [x] Custom settings - [x] Disk encryption - [x] OS Updates 2/18/25, added to this PR: - [x] Controls > Setup experience > Run script - [x] Software > - [x] Manage automations modal - [x] Add software > - [x] App Store (VPP) - [x] Custom package - [x] Queries - [x] Manage - [x] Automations modal - [x] New - [x] Edit - [x] Policies - [x] Manage - [x] New - [x] Edit - Manage automations - [x] Calendar events - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2025-02-20 16:41:07 +00:00
import GitOpsModeTooltipWrapper from "components/GitOpsModeTooltipWrapper";
import Modal from "components/Modal";
import Button from "components/buttons/Button";
import Icon from "components/Icon/Icon";
import EnrollSecretTable from "../EnrollSecretTable";
interface IEnrollSecretModal {
UI: In Primo mode, enforce `No team` or `All teams`, depending on the page, to preserve premium functionality (#30291) ## #30198 [Video demo](https://drive.google.com/file/d/1RBk5QNQdQvXTHJveCNkIeMXj5hWFA5Ft/view?usp=sharing) - Implement the following logic for `teamId` in the UI when in Primo mode: <img width="870" alt="Screenshot 2025-06-24 at 12 47 48 PM" src="https://github.com/user-attachments/assets/8ae81c3f-223f-4dda-954d-c42c7008de45" /> - Above logic is enforced - if trying to change/add/remove `team_id`, automatically pushed to appropriate team - Fixes originally reported issue - user in Primo mode can access installable software (on the hidden "No team" which is now enforced): - Software page on No team - Update header help text ![ezgif-49ce1977ab6474](https://github.com/user-attachments/assets/0d011f94-7c90-4d42-92ec-135baafe7927) - Handle UI edge cases the above surfaces: - Queries page on All teams (No team not supported): <img width="1624" alt="Screenshot 2025-06-24 at 1 10 40 PM" src="https://github.com/user-attachments/assets/84bb2ca0-b8e7-44e8-9bf5-9f8f243d5584" /> - Policies page on No team: <img width="1624" alt="Screenshot 2025-06-24 at 1 10 53 PM" src="https://github.com/user-attachments/assets/144d745f-e9b0-4933-be45-2db4fe428cfe" /> - update `useTeamIdParam` hook's strip query params on change team logic to optionally also consider the current team **Important notes** - Software page: Software automations are only accessible via All teams, while Add software is only accessible on a team, including No team. In lieu of specs around this, I decided to favor Add software functionality over Software automations functionality, aka, push to "No team" on this page. Enabling _both_ functionalities would be a very large ticket and need to go through a proper drafting process, since Fleet doesn't currently support both in any state. - Policies page: - "Other workflows" (tickets and webhooks) is available on All Teams and specific teams, but not on No Team, so "Other workflows" is currently unavailable in Primo mode - If any of the Primo customers have created policies on All Teams already, they won't be able to manage automations on them anymore. All Teams policies can only have ticket/webhook workflows - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2025-06-25 16:26:36 +00:00
selectedTeamId: number;
primoMode: boolean;
onReturnToApp: () => void;
teams: ITeam[];
toggleSecretEditorModal: () => void;
toggleDeleteSecretModal: () => void;
setSelectedSecret: React.Dispatch<
React.SetStateAction<IEnrollSecret | undefined>
>;
globalSecrets?: IEnrollSecret[] | undefined;
}
const baseClass = "enroll-secret-modal";
const EnrollSecretModal = ({
onReturnToApp,
UI: In Primo mode, enforce `No team` or `All teams`, depending on the page, to preserve premium functionality (#30291) ## #30198 [Video demo](https://drive.google.com/file/d/1RBk5QNQdQvXTHJveCNkIeMXj5hWFA5Ft/view?usp=sharing) - Implement the following logic for `teamId` in the UI when in Primo mode: <img width="870" alt="Screenshot 2025-06-24 at 12 47 48 PM" src="https://github.com/user-attachments/assets/8ae81c3f-223f-4dda-954d-c42c7008de45" /> - Above logic is enforced - if trying to change/add/remove `team_id`, automatically pushed to appropriate team - Fixes originally reported issue - user in Primo mode can access installable software (on the hidden "No team" which is now enforced): - Software page on No team - Update header help text ![ezgif-49ce1977ab6474](https://github.com/user-attachments/assets/0d011f94-7c90-4d42-92ec-135baafe7927) - Handle UI edge cases the above surfaces: - Queries page on All teams (No team not supported): <img width="1624" alt="Screenshot 2025-06-24 at 1 10 40 PM" src="https://github.com/user-attachments/assets/84bb2ca0-b8e7-44e8-9bf5-9f8f243d5584" /> - Policies page on No team: <img width="1624" alt="Screenshot 2025-06-24 at 1 10 53 PM" src="https://github.com/user-attachments/assets/144d745f-e9b0-4933-be45-2db4fe428cfe" /> - update `useTeamIdParam` hook's strip query params on change team logic to optionally also consider the current team **Important notes** - Software page: Software automations are only accessible via All teams, while Add software is only accessible on a team, including No team. In lieu of specs around this, I decided to favor Add software functionality over Software automations functionality, aka, push to "No team" on this page. Enabling _both_ functionalities would be a very large ticket and need to go through a proper drafting process, since Fleet doesn't currently support both in any state. - Policies page: - "Other workflows" (tickets and webhooks) is available on All Teams and specific teams, but not on No Team, so "Other workflows" is currently unavailable in Primo mode - If any of the Primo customers have created policies on All Teams already, they won't be able to manage automations on them anymore. All Teams policies can only have ticket/webhook workflows - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2025-06-25 16:26:36 +00:00
selectedTeamId,
primoMode,
teams,
toggleSecretEditorModal,
toggleDeleteSecretModal,
setSelectedSecret,
globalSecrets,
}: IEnrollSecretModal): JSX.Element => {
UI: In Primo mode, enforce `No team` or `All teams`, depending on the page, to preserve premium functionality (#30291) ## #30198 [Video demo](https://drive.google.com/file/d/1RBk5QNQdQvXTHJveCNkIeMXj5hWFA5Ft/view?usp=sharing) - Implement the following logic for `teamId` in the UI when in Primo mode: <img width="870" alt="Screenshot 2025-06-24 at 12 47 48 PM" src="https://github.com/user-attachments/assets/8ae81c3f-223f-4dda-954d-c42c7008de45" /> - Above logic is enforced - if trying to change/add/remove `team_id`, automatically pushed to appropriate team - Fixes originally reported issue - user in Primo mode can access installable software (on the hidden "No team" which is now enforced): - Software page on No team - Update header help text ![ezgif-49ce1977ab6474](https://github.com/user-attachments/assets/0d011f94-7c90-4d42-92ec-135baafe7927) - Handle UI edge cases the above surfaces: - Queries page on All teams (No team not supported): <img width="1624" alt="Screenshot 2025-06-24 at 1 10 40 PM" src="https://github.com/user-attachments/assets/84bb2ca0-b8e7-44e8-9bf5-9f8f243d5584" /> - Policies page on No team: <img width="1624" alt="Screenshot 2025-06-24 at 1 10 53 PM" src="https://github.com/user-attachments/assets/144d745f-e9b0-4933-be45-2db4fe428cfe" /> - update `useTeamIdParam` hook's strip query params on change team logic to optionally also consider the current team **Important notes** - Software page: Software automations are only accessible via All teams, while Add software is only accessible on a team, including No team. In lieu of specs around this, I decided to favor Add software functionality over Software automations functionality, aka, push to "No team" on this page. Enabling _both_ functionalities would be a very large ticket and need to go through a proper drafting process, since Fleet doesn't currently support both in any state. - Policies page: - "Other workflows" (tickets and webhooks) is available on All Teams and specific teams, but not on No Team, so "Other workflows" is currently unavailable in Primo mode - If any of the Primo customers have created policies on All Teams already, they won't be able to manage automations on them anymore. All Teams policies can only have ticket/webhook workflows - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2025-06-25 16:26:36 +00:00
const teamInfo =
selectedTeamId <= 0
? { name: "No team", secrets: globalSecrets }
: teams.find((team) => team.id === selectedTeamId);
const addNewSecretClick = () => {
setSelectedSecret(undefined);
toggleSecretEditorModal();
};
return (
<Modal
onExit={onReturnToApp}
onEnter={onReturnToApp}
title="Manage enroll secrets"
className={baseClass}
>
UI – refactor forms and form fields (#16159) ## Addresses #15325 - Define shared global styles for forms (`form` and `.form`s) and `.form-field`s - Sweep through the app, updating each form from being locally styled to first prioritizing the global styles and only defining local styles where needed for custom behavior - Remove lots of unnecessary nesting of elements - Other small bug fixes and improvements ### Samples, before (L) | after (R): **Save query modal** ![Screenshot 2024-01-17 at 11 49 14 AM](https://github.com/fleetdm/fleet/assets/61553566/14f209fb-31db-41ef-8e63-e0d8994698c1) **Edit query form** ![Screenshot 2024-01-17 at 11 50 35 AM](https://github.com/fleetdm/fleet/assets/61553566/b07e70ea-3095-4e4f-be73-95a3c499839b) **Add hosts modal** ![Screenshot 2024-01-17 at 11 51 48 AM](https://github.com/fleetdm/fleet/assets/61553566/4ef1f410-a823-41d1-b2f6-ea8eb5231f93) ## QA Plan: @xpkoala here's the same list from the issue, freshly de-checked for you to use if it's helpful: * Please check error states of each field #### Specified by issue: ##### In "Save query" modal: - [ ] Reduce space between checkboxes and their help text to 8px/0.5rem for the following fields: - [ ] Observers can run - [ ] Discard data - [ ] Update the following checkbox labels to have normal font weight (not bold): - [ ] Discard data ##### On "Edit query" page: - [ ] Update the following checkbox labels to have normal font weight (not bold): - [ ] Observers can run - [ ] Discard data ##### In "Add hosts" modal, for copy text fields: - [ ] match typical form form field styles - [ ] Adjust the positioning of the copy icon to keep it from being too far down ##### Further locations to check - [ ] ChangeEmailForm.jsx - [ ] ChangePasswordForm.jsx - [ ] ConfirmInviteForm.jsx - [ ] ConfirmSSOInviteForm.jsx - [ ] EnrollSecretModal.tsx - [ ] ForgotPasswordForm.jsx - [ ] LoginForm.tsx - [ ] EditPackForm.tsx - [ ] (New)PackForm.tsx - [ ] AdminDetails.jsx - [ ] ConfirmationPage.tsx - [ ] FleetDetails.jsx - [ ] OrgDetails.jsx - [ ] ResetPasswordForm.tsx - [ ] UserSettingsForm.jsx - [ ] EditTeamModal.tsx - [ ] IdpSection.tsx - [ ] DeleteIntegrationModal.tsx - [ ] IntegrationForm.tsx - [ ] EndUserMigrationSection.tsx - [ ] RequestCSRModal.tsx - [ ] Advanced.tsx - [ ] Agents.tsx - [ ] FleetDesktop.tsx - [ ] HostStatusWebhook.tsx front - [ ] Info.tsx - [ ] Smtp.tsx - [ ] Sso.tsx - [ ] Statistics.tsx - [ ] WebAddress.tsx - [ ] CreateTeamModal.tsx - [ ] DeleteTeamModal.tsx - [ ] EditTeamModal.tsx - [ ] AgentOptionsPage.tsx - updated the layout of this page to align with the rest of the forms in the UI – can easily revert if it's not what we want - [ ] AddMemberModal.tsx - [ ] RemoveMemberModal.tsx - [ ] UserForm.tsx - Used by both `EditUserModal` and `CreateUserModal` - A few different conditions that cause different rendering behavior - [ ] DeleteHostModal.tsx - [ ] TransferHostModal.tsx - [ ] LabelForm.tsx - [ ] MacOSTargetForm.tsx - [ ] WindowsTargetForm.tsx - [ ] BootstrapPackageListltem.ts - [ ] EndUserAuthForm.tsx - [ ] PackQueryEditorModal.tsx - [ ] PolicyForm.tsx - [ ] SaveNewPolicyModal.tsx - [ ] ConfirmSaveChangesModal.tsx - [ ] Query automations modal - [ ] Policy automations modal - addresses #16010 - [ ] SoftwareAutomationsModal ## Checklist for submitter - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com> Co-authored-by: RachelElysia <71795832+RachelElysia@users.noreply.github.com>
2024-01-18 15:48:44 +00:00
<div className={`${baseClass} form`}>
UI: In Primo mode, enforce `No team` or `All teams`, depending on the page, to preserve premium functionality (#30291) ## #30198 [Video demo](https://drive.google.com/file/d/1RBk5QNQdQvXTHJveCNkIeMXj5hWFA5Ft/view?usp=sharing) - Implement the following logic for `teamId` in the UI when in Primo mode: <img width="870" alt="Screenshot 2025-06-24 at 12 47 48 PM" src="https://github.com/user-attachments/assets/8ae81c3f-223f-4dda-954d-c42c7008de45" /> - Above logic is enforced - if trying to change/add/remove `team_id`, automatically pushed to appropriate team - Fixes originally reported issue - user in Primo mode can access installable software (on the hidden "No team" which is now enforced): - Software page on No team - Update header help text ![ezgif-49ce1977ab6474](https://github.com/user-attachments/assets/0d011f94-7c90-4d42-92ec-135baafe7927) - Handle UI edge cases the above surfaces: - Queries page on All teams (No team not supported): <img width="1624" alt="Screenshot 2025-06-24 at 1 10 40 PM" src="https://github.com/user-attachments/assets/84bb2ca0-b8e7-44e8-9bf5-9f8f243d5584" /> - Policies page on No team: <img width="1624" alt="Screenshot 2025-06-24 at 1 10 53 PM" src="https://github.com/user-attachments/assets/144d745f-e9b0-4933-be45-2db4fe428cfe" /> - update `useTeamIdParam` hook's strip query params on change team logic to optionally also consider the current team **Important notes** - Software page: Software automations are only accessible via All teams, while Add software is only accessible on a team, including No team. In lieu of specs around this, I decided to favor Add software functionality over Software automations functionality, aka, push to "No team" on this page. Enabling _both_ functionalities would be a very large ticket and need to go through a proper drafting process, since Fleet doesn't currently support both in any state. - Policies page: - "Other workflows" (tickets and webhooks) is available on All Teams and specific teams, but not on No Team, so "Other workflows" is currently unavailable in Primo mode - If any of the Primo customers have created policies on All Teams already, they won't be able to manage automations on them anymore. All Teams policies can only have ticket/webhook workflows - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2025-06-25 16:26:36 +00:00
{teamInfo?.secrets?.length ? (
<>
2025-09-29 17:10:41 +00:00
<div className={`${baseClass}__header`}>
<div className={`${baseClass}__description`}>
Use these secret(s) to enroll hosts
UI: In Primo mode, enforce `No team` or `All teams`, depending on the page, to preserve premium functionality (#30291) ## #30198 [Video demo](https://drive.google.com/file/d/1RBk5QNQdQvXTHJveCNkIeMXj5hWFA5Ft/view?usp=sharing) - Implement the following logic for `teamId` in the UI when in Primo mode: <img width="870" alt="Screenshot 2025-06-24 at 12 47 48 PM" src="https://github.com/user-attachments/assets/8ae81c3f-223f-4dda-954d-c42c7008de45" /> - Above logic is enforced - if trying to change/add/remove `team_id`, automatically pushed to appropriate team - Fixes originally reported issue - user in Primo mode can access installable software (on the hidden "No team" which is now enforced): - Software page on No team - Update header help text ![ezgif-49ce1977ab6474](https://github.com/user-attachments/assets/0d011f94-7c90-4d42-92ec-135baafe7927) - Handle UI edge cases the above surfaces: - Queries page on All teams (No team not supported): <img width="1624" alt="Screenshot 2025-06-24 at 1 10 40 PM" src="https://github.com/user-attachments/assets/84bb2ca0-b8e7-44e8-9bf5-9f8f243d5584" /> - Policies page on No team: <img width="1624" alt="Screenshot 2025-06-24 at 1 10 53 PM" src="https://github.com/user-attachments/assets/144d745f-e9b0-4933-be45-2db4fe428cfe" /> - update `useTeamIdParam` hook's strip query params on change team logic to optionally also consider the current team **Important notes** - Software page: Software automations are only accessible via All teams, while Add software is only accessible on a team, including No team. In lieu of specs around this, I decided to favor Add software functionality over Software automations functionality, aka, push to "No team" on this page. Enabling _both_ functionalities would be a very large ticket and need to go through a proper drafting process, since Fleet doesn't currently support both in any state. - Policies page: - "Other workflows" (tickets and webhooks) is available on All Teams and specific teams, but not on No Team, so "Other workflows" is currently unavailable in Primo mode - If any of the Primo customers have created policies on All Teams already, they won't be able to manage automations on them anymore. All Teams policies can only have ticket/webhook workflows - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2025-06-25 16:26:36 +00:00
{primoMode ? (
""
) : (
<>
{" "}
to <b>{teamInfo?.name}</b>
</>
)}
.
2025-09-29 17:10:41 +00:00
</div>
<div className={`${baseClass}__add-secret`}>
<GitOpsModeTooltipWrapper
position="right"
tipOffset={8}
renderChildren={(disableChildren) => (
<Button
disabled={disableChildren}
onClick={addNewSecretClick}
className={`${baseClass}__add-secret-btn`}
variant="brand-inverse-icon"
iconStroke
>
Add secret <Icon name="plus" color="core-fleet-green" />
</Button>
)}
/>
</div>
</div>
2025-09-29 17:10:41 +00:00
<EnrollSecretTable
secrets={teamInfo?.secrets}
toggleSecretEditorModal={toggleSecretEditorModal}
toggleDeleteSecretModal={toggleDeleteSecretModal}
setSelectedSecret={setSelectedSecret}
/>
</>
2025-09-29 17:10:41 +00:00
) : (
<Card color="grey" paddingSize="small">
<EmptyTable
header="You have no enroll secrets."
info={
<>
Add secret(s) to enroll hosts
{primoMode ? (
""
) : (
<>
{" "}
to <b>{teamInfo?.name}</b>
</>
)}
.
</>
}
primaryButton={
<GitOpsModeTooltipWrapper
position="right"
tipOffset={8}
renderChildren={(disableChildren) => (
<Button
disabled={disableChildren}
onClick={addNewSecretClick}
className={`${baseClass}__add-secret-btn`}
variant="brand-inverse-icon"
iconStroke
>
Add secret <Icon name="plus" color="core-fleet-green" />
</Button>
)}
/>
}
/>
</Card>
)}
<div className="modal-cta-wrap">
<Button onClick={onReturnToApp}>Done</Button>
</div>
</div>
</Modal>
);
};
export default EnrollSecretModal;