fleet/frontend/components/Modal/Modal.tsx

134 lines
3.6 KiB
TypeScript
Raw Normal View History

import React, { useEffect } from "react";
import classnames from "classnames";
import Button from "components/buttons/Button/Button";
import Icon from "components/Icon/Icon";
const baseClass = "modal";
UI: Make all Modal widths consistent (#11722) ## Addresses #11356 Images of 3 fixed modals referenced in the issue: <img width="1235" alt="Screenshot 2023-05-12 at 4 11 52 PM" src="https://github.com/fleetdm/fleet/assets/61553566/098081c7-15d4-4009-92a0-7a2e14ffaab1"> <img width="1235" alt="Screenshot 2023-05-12 at 4 12 50 PM" src="https://github.com/fleetdm/fleet/assets/61553566/7d0f268d-f2dc-4686-a64d-94e28a94c717"> <img width="1235" alt="Screenshot 2023-05-12 at 4 13 26 PM" src="https://github.com/fleetdm/fleet/assets/61553566/d486b005-1344-4656-adec-c4929332816b"> ## Implemented: - [x] Updated global modal styles for consistency - [x] Add optional "width" prop to `Modal` - [x] Misc cleanup: - [x] Restore missing padding from inverse-alert buttons - [x] Improve naming, lots of cleanup - [x] More coming in separate PR - [x] Check each of the following modals, define `width` where necessary: - [x] Add hosts - [x] EnrollSecret - [x] Also fix misaligned icons - [x] SecretEditor - [x] DeleteSecret - [x] ShowQuery - [x] AddIntegration - [x] DeleteIntegration - [x] EditIntegration - [x] EditTeam - [x] RequestCSR - [x] HostStatusWebhook - [x] CreateTeam - [x] DeleteTeam - [x] EditTeam - [x] AddMember - [x] RemoveMember - [x] CreateUser - [x] DeleteUser - [x] EditUser - [x] Also fix randomly shorter 'Password' field - [x] ResetPassword - [x] ResetSessions - [x] WelcomeHost - [x] DeletHost - [x] TransferHost - [x] POlicyDetails - [x] AutoEnrollMdm - [x] Info - [x] ManualEnrollMdm - [x] ResetKey - [x] BootstrapPackage - [x] DiskEncryption - [x] OSPOlicy - [x] SelectQuery - [x] UnenrollMdm - [x] MacSettings - [x] DeleteLabel - [x] EditCOlumns - WIP, cannot QA yet (cc @ghernandez345): - DeleteScript - RerunScript - [x] DeleteProfile - [x] DeletePackage - allow to conform to default "m" width, 650px - [x] PackQueryEditor - allow to conform to default "m" width - [x] RemovePackQuery - allow to conform to default "m" width - [x] DeletePack - allow to conform to default "m" width - [x] AddPolicy - [x] DeletePolicy - allow to conform to default "m" width - [x] NewPolicy (now "SaveNewPolicyModal") - allow to conform to default "m" width - [x] DeleteQuery - [x] NewQuery - allow to conform to default "m" width - [x] PreviewData - [x] RemoveScheduledQuery - [x] ScheduleEditor - [x] UserSettingsPage (aka "get API token") - [x] 2 x ManageAutomations – set to large - [x] 2 x PreviewPayload - allow to conform to default "m" width - [x] 2 x PreviewTicket - same as ManageAutomations ## 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>
2023-05-17 17:07:38 +00:00
type ModalWidth = "medium" | "large" | "xlarge" | "auto";
export interface IModalProps {
UI: Make all Modal widths consistent (#11722) ## Addresses #11356 Images of 3 fixed modals referenced in the issue: <img width="1235" alt="Screenshot 2023-05-12 at 4 11 52 PM" src="https://github.com/fleetdm/fleet/assets/61553566/098081c7-15d4-4009-92a0-7a2e14ffaab1"> <img width="1235" alt="Screenshot 2023-05-12 at 4 12 50 PM" src="https://github.com/fleetdm/fleet/assets/61553566/7d0f268d-f2dc-4686-a64d-94e28a94c717"> <img width="1235" alt="Screenshot 2023-05-12 at 4 13 26 PM" src="https://github.com/fleetdm/fleet/assets/61553566/d486b005-1344-4656-adec-c4929332816b"> ## Implemented: - [x] Updated global modal styles for consistency - [x] Add optional "width" prop to `Modal` - [x] Misc cleanup: - [x] Restore missing padding from inverse-alert buttons - [x] Improve naming, lots of cleanup - [x] More coming in separate PR - [x] Check each of the following modals, define `width` where necessary: - [x] Add hosts - [x] EnrollSecret - [x] Also fix misaligned icons - [x] SecretEditor - [x] DeleteSecret - [x] ShowQuery - [x] AddIntegration - [x] DeleteIntegration - [x] EditIntegration - [x] EditTeam - [x] RequestCSR - [x] HostStatusWebhook - [x] CreateTeam - [x] DeleteTeam - [x] EditTeam - [x] AddMember - [x] RemoveMember - [x] CreateUser - [x] DeleteUser - [x] EditUser - [x] Also fix randomly shorter 'Password' field - [x] ResetPassword - [x] ResetSessions - [x] WelcomeHost - [x] DeletHost - [x] TransferHost - [x] POlicyDetails - [x] AutoEnrollMdm - [x] Info - [x] ManualEnrollMdm - [x] ResetKey - [x] BootstrapPackage - [x] DiskEncryption - [x] OSPOlicy - [x] SelectQuery - [x] UnenrollMdm - [x] MacSettings - [x] DeleteLabel - [x] EditCOlumns - WIP, cannot QA yet (cc @ghernandez345): - DeleteScript - RerunScript - [x] DeleteProfile - [x] DeletePackage - allow to conform to default "m" width, 650px - [x] PackQueryEditor - allow to conform to default "m" width - [x] RemovePackQuery - allow to conform to default "m" width - [x] DeletePack - allow to conform to default "m" width - [x] AddPolicy - [x] DeletePolicy - allow to conform to default "m" width - [x] NewPolicy (now "SaveNewPolicyModal") - allow to conform to default "m" width - [x] DeleteQuery - [x] NewQuery - allow to conform to default "m" width - [x] PreviewData - [x] RemoveScheduledQuery - [x] ScheduleEditor - [x] UserSettingsPage (aka "get API token") - [x] 2 x ManageAutomations – set to large - [x] 2 x PreviewPayload - allow to conform to default "m" width - [x] 2 x PreviewTicket - same as ManageAutomations ## 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>
2023-05-17 17:07:38 +00:00
title: string | JSX.Element;
children: JSX.Element;
onExit: () => void;
onEnter?: () => void;
feat: enable multiple ABM and VPP tokens (#21693) > Related issue: #9956 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Martin Angers <martin.n.angers@gmail.com> Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> Co-authored-by: Roberto Dip <rroperzh@gmail.com> Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com> Co-authored-by: Dante Catalfamo <43040593+dantecatalfamo@users.noreply.github.com> Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
2024-08-29 22:51:46 +00:00
/** medium 650px, large 800px, xlarge 850px, auto auto-width
* @default "medium"
*/
UI: Make all Modal widths consistent (#11722) ## Addresses #11356 Images of 3 fixed modals referenced in the issue: <img width="1235" alt="Screenshot 2023-05-12 at 4 11 52 PM" src="https://github.com/fleetdm/fleet/assets/61553566/098081c7-15d4-4009-92a0-7a2e14ffaab1"> <img width="1235" alt="Screenshot 2023-05-12 at 4 12 50 PM" src="https://github.com/fleetdm/fleet/assets/61553566/7d0f268d-f2dc-4686-a64d-94e28a94c717"> <img width="1235" alt="Screenshot 2023-05-12 at 4 13 26 PM" src="https://github.com/fleetdm/fleet/assets/61553566/d486b005-1344-4656-adec-c4929332816b"> ## Implemented: - [x] Updated global modal styles for consistency - [x] Add optional "width" prop to `Modal` - [x] Misc cleanup: - [x] Restore missing padding from inverse-alert buttons - [x] Improve naming, lots of cleanup - [x] More coming in separate PR - [x] Check each of the following modals, define `width` where necessary: - [x] Add hosts - [x] EnrollSecret - [x] Also fix misaligned icons - [x] SecretEditor - [x] DeleteSecret - [x] ShowQuery - [x] AddIntegration - [x] DeleteIntegration - [x] EditIntegration - [x] EditTeam - [x] RequestCSR - [x] HostStatusWebhook - [x] CreateTeam - [x] DeleteTeam - [x] EditTeam - [x] AddMember - [x] RemoveMember - [x] CreateUser - [x] DeleteUser - [x] EditUser - [x] Also fix randomly shorter 'Password' field - [x] ResetPassword - [x] ResetSessions - [x] WelcomeHost - [x] DeletHost - [x] TransferHost - [x] POlicyDetails - [x] AutoEnrollMdm - [x] Info - [x] ManualEnrollMdm - [x] ResetKey - [x] BootstrapPackage - [x] DiskEncryption - [x] OSPOlicy - [x] SelectQuery - [x] UnenrollMdm - [x] MacSettings - [x] DeleteLabel - [x] EditCOlumns - WIP, cannot QA yet (cc @ghernandez345): - DeleteScript - RerunScript - [x] DeleteProfile - [x] DeletePackage - allow to conform to default "m" width, 650px - [x] PackQueryEditor - allow to conform to default "m" width - [x] RemovePackQuery - allow to conform to default "m" width - [x] DeletePack - allow to conform to default "m" width - [x] AddPolicy - [x] DeletePolicy - allow to conform to default "m" width - [x] NewPolicy (now "SaveNewPolicyModal") - allow to conform to default "m" width - [x] DeleteQuery - [x] NewQuery - allow to conform to default "m" width - [x] PreviewData - [x] RemoveScheduledQuery - [x] ScheduleEditor - [x] UserSettingsPage (aka "get API token") - [x] 2 x ManageAutomations – set to large - [x] 2 x PreviewPayload - allow to conform to default "m" width - [x] 2 x PreviewTicket - same as ManageAutomations ## 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>
2023-05-17 17:07:38 +00:00
width?: ModalWidth;
feat: enable multiple ABM and VPP tokens (#21693) > Related issue: #9956 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Martin Angers <martin.n.angers@gmail.com> Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> Co-authored-by: Roberto Dip <rroperzh@gmail.com> Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com> Co-authored-by: Dante Catalfamo <43040593+dantecatalfamo@users.noreply.github.com> Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
2024-08-29 22:51:46 +00:00
/** isHidden can be set true to hide the modal when opening another modal
* @default false
*/
isHidden?: boolean;
feat: enable multiple ABM and VPP tokens (#21693) > Related issue: #9956 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Martin Angers <martin.n.angers@gmail.com> Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> Co-authored-by: Roberto Dip <rroperzh@gmail.com> Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com> Co-authored-by: Dante Catalfamo <43040593+dantecatalfamo@users.noreply.github.com> Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
2024-08-29 22:51:46 +00:00
/** isLoading can be set true to enable targeting elements by loading state
* @default false
*/
isLoading?: boolean;
feat: enable multiple ABM and VPP tokens (#21693) > Related issue: #9956 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Martin Angers <martin.n.angers@gmail.com> Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> Co-authored-by: Roberto Dip <rroperzh@gmail.com> Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com> Co-authored-by: Dante Catalfamo <43040593+dantecatalfamo@users.noreply.github.com> Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
2024-08-29 22:51:46 +00:00
/** `isContentDisabled` can be set to true to display the modal content as disabled.
* At the moment this will place an overlay over the modal content and make it
feat: enable multiple ABM and VPP tokens (#21693) > Related issue: #9956 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Martin Angers <martin.n.angers@gmail.com> Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> Co-authored-by: Roberto Dip <rroperzh@gmail.com> Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com> Co-authored-by: Dante Catalfamo <43040593+dantecatalfamo@users.noreply.github.com> Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
2024-08-29 22:51:46 +00:00
* unclickable. The top right will not be disabled and will still be clickable.
*
* @default false
*/
isContentDisabled?: boolean;
/** `disableClosingModal` can be set to disable the users ability to manually
* close the modal.
* @default false
* */
disableClosingModal?: boolean;
className?: string;
}
const Modal = ({
UI: Make all Modal widths consistent (#11722) ## Addresses #11356 Images of 3 fixed modals referenced in the issue: <img width="1235" alt="Screenshot 2023-05-12 at 4 11 52 PM" src="https://github.com/fleetdm/fleet/assets/61553566/098081c7-15d4-4009-92a0-7a2e14ffaab1"> <img width="1235" alt="Screenshot 2023-05-12 at 4 12 50 PM" src="https://github.com/fleetdm/fleet/assets/61553566/7d0f268d-f2dc-4686-a64d-94e28a94c717"> <img width="1235" alt="Screenshot 2023-05-12 at 4 13 26 PM" src="https://github.com/fleetdm/fleet/assets/61553566/d486b005-1344-4656-adec-c4929332816b"> ## Implemented: - [x] Updated global modal styles for consistency - [x] Add optional "width" prop to `Modal` - [x] Misc cleanup: - [x] Restore missing padding from inverse-alert buttons - [x] Improve naming, lots of cleanup - [x] More coming in separate PR - [x] Check each of the following modals, define `width` where necessary: - [x] Add hosts - [x] EnrollSecret - [x] Also fix misaligned icons - [x] SecretEditor - [x] DeleteSecret - [x] ShowQuery - [x] AddIntegration - [x] DeleteIntegration - [x] EditIntegration - [x] EditTeam - [x] RequestCSR - [x] HostStatusWebhook - [x] CreateTeam - [x] DeleteTeam - [x] EditTeam - [x] AddMember - [x] RemoveMember - [x] CreateUser - [x] DeleteUser - [x] EditUser - [x] Also fix randomly shorter 'Password' field - [x] ResetPassword - [x] ResetSessions - [x] WelcomeHost - [x] DeletHost - [x] TransferHost - [x] POlicyDetails - [x] AutoEnrollMdm - [x] Info - [x] ManualEnrollMdm - [x] ResetKey - [x] BootstrapPackage - [x] DiskEncryption - [x] OSPOlicy - [x] SelectQuery - [x] UnenrollMdm - [x] MacSettings - [x] DeleteLabel - [x] EditCOlumns - WIP, cannot QA yet (cc @ghernandez345): - DeleteScript - RerunScript - [x] DeleteProfile - [x] DeletePackage - allow to conform to default "m" width, 650px - [x] PackQueryEditor - allow to conform to default "m" width - [x] RemovePackQuery - allow to conform to default "m" width - [x] DeletePack - allow to conform to default "m" width - [x] AddPolicy - [x] DeletePolicy - allow to conform to default "m" width - [x] NewPolicy (now "SaveNewPolicyModal") - allow to conform to default "m" width - [x] DeleteQuery - [x] NewQuery - allow to conform to default "m" width - [x] PreviewData - [x] RemoveScheduledQuery - [x] ScheduleEditor - [x] UserSettingsPage (aka "get API token") - [x] 2 x ManageAutomations – set to large - [x] 2 x PreviewPayload - allow to conform to default "m" width - [x] 2 x PreviewTicket - same as ManageAutomations ## 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>
2023-05-17 17:07:38 +00:00
title,
children,
onExit,
onEnter,
UI: Make all Modal widths consistent (#11722) ## Addresses #11356 Images of 3 fixed modals referenced in the issue: <img width="1235" alt="Screenshot 2023-05-12 at 4 11 52 PM" src="https://github.com/fleetdm/fleet/assets/61553566/098081c7-15d4-4009-92a0-7a2e14ffaab1"> <img width="1235" alt="Screenshot 2023-05-12 at 4 12 50 PM" src="https://github.com/fleetdm/fleet/assets/61553566/7d0f268d-f2dc-4686-a64d-94e28a94c717"> <img width="1235" alt="Screenshot 2023-05-12 at 4 13 26 PM" src="https://github.com/fleetdm/fleet/assets/61553566/d486b005-1344-4656-adec-c4929332816b"> ## Implemented: - [x] Updated global modal styles for consistency - [x] Add optional "width" prop to `Modal` - [x] Misc cleanup: - [x] Restore missing padding from inverse-alert buttons - [x] Improve naming, lots of cleanup - [x] More coming in separate PR - [x] Check each of the following modals, define `width` where necessary: - [x] Add hosts - [x] EnrollSecret - [x] Also fix misaligned icons - [x] SecretEditor - [x] DeleteSecret - [x] ShowQuery - [x] AddIntegration - [x] DeleteIntegration - [x] EditIntegration - [x] EditTeam - [x] RequestCSR - [x] HostStatusWebhook - [x] CreateTeam - [x] DeleteTeam - [x] EditTeam - [x] AddMember - [x] RemoveMember - [x] CreateUser - [x] DeleteUser - [x] EditUser - [x] Also fix randomly shorter 'Password' field - [x] ResetPassword - [x] ResetSessions - [x] WelcomeHost - [x] DeletHost - [x] TransferHost - [x] POlicyDetails - [x] AutoEnrollMdm - [x] Info - [x] ManualEnrollMdm - [x] ResetKey - [x] BootstrapPackage - [x] DiskEncryption - [x] OSPOlicy - [x] SelectQuery - [x] UnenrollMdm - [x] MacSettings - [x] DeleteLabel - [x] EditCOlumns - WIP, cannot QA yet (cc @ghernandez345): - DeleteScript - RerunScript - [x] DeleteProfile - [x] DeletePackage - allow to conform to default "m" width, 650px - [x] PackQueryEditor - allow to conform to default "m" width - [x] RemovePackQuery - allow to conform to default "m" width - [x] DeletePack - allow to conform to default "m" width - [x] AddPolicy - [x] DeletePolicy - allow to conform to default "m" width - [x] NewPolicy (now "SaveNewPolicyModal") - allow to conform to default "m" width - [x] DeleteQuery - [x] NewQuery - allow to conform to default "m" width - [x] PreviewData - [x] RemoveScheduledQuery - [x] ScheduleEditor - [x] UserSettingsPage (aka "get API token") - [x] 2 x ManageAutomations – set to large - [x] 2 x PreviewPayload - allow to conform to default "m" width - [x] 2 x PreviewTicket - same as ManageAutomations ## 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>
2023-05-17 17:07:38 +00:00
width = "medium",
isHidden = false,
isLoading = false,
isContentDisabled = false,
disableClosingModal = false,
className,
}: IModalProps): JSX.Element => {
useEffect(() => {
const closeWithEscapeKey = (e: KeyboardEvent) => {
if (e.key === "Escape") {
onExit();
}
};
if (!disableClosingModal) {
document.addEventListener("keydown", closeWithEscapeKey);
}
return () => {
if (!disableClosingModal) {
document.removeEventListener("keydown", closeWithEscapeKey);
}
};
}, [disableClosingModal, onExit]);
useEffect(() => {
if (onEnter) {
const closeOrSaveWithEnterKey = (event: KeyboardEvent) => {
if (event.code === "Enter" || event.code === "NumpadEnter") {
event.preventDefault();
onEnter();
}
};
document.addEventListener("keydown", closeOrSaveWithEnterKey);
return () => {
document.removeEventListener("keydown", closeOrSaveWithEnterKey);
};
}
}, [onEnter]);
const backgroundClasses = classnames(`${baseClass}__background`, {
[`${baseClass}__hidden`]: isHidden,
});
const modalContainerClasses = classnames(
UI: Make all Modal widths consistent (#11722) ## Addresses #11356 Images of 3 fixed modals referenced in the issue: <img width="1235" alt="Screenshot 2023-05-12 at 4 11 52 PM" src="https://github.com/fleetdm/fleet/assets/61553566/098081c7-15d4-4009-92a0-7a2e14ffaab1"> <img width="1235" alt="Screenshot 2023-05-12 at 4 12 50 PM" src="https://github.com/fleetdm/fleet/assets/61553566/7d0f268d-f2dc-4686-a64d-94e28a94c717"> <img width="1235" alt="Screenshot 2023-05-12 at 4 13 26 PM" src="https://github.com/fleetdm/fleet/assets/61553566/d486b005-1344-4656-adec-c4929332816b"> ## Implemented: - [x] Updated global modal styles for consistency - [x] Add optional "width" prop to `Modal` - [x] Misc cleanup: - [x] Restore missing padding from inverse-alert buttons - [x] Improve naming, lots of cleanup - [x] More coming in separate PR - [x] Check each of the following modals, define `width` where necessary: - [x] Add hosts - [x] EnrollSecret - [x] Also fix misaligned icons - [x] SecretEditor - [x] DeleteSecret - [x] ShowQuery - [x] AddIntegration - [x] DeleteIntegration - [x] EditIntegration - [x] EditTeam - [x] RequestCSR - [x] HostStatusWebhook - [x] CreateTeam - [x] DeleteTeam - [x] EditTeam - [x] AddMember - [x] RemoveMember - [x] CreateUser - [x] DeleteUser - [x] EditUser - [x] Also fix randomly shorter 'Password' field - [x] ResetPassword - [x] ResetSessions - [x] WelcomeHost - [x] DeletHost - [x] TransferHost - [x] POlicyDetails - [x] AutoEnrollMdm - [x] Info - [x] ManualEnrollMdm - [x] ResetKey - [x] BootstrapPackage - [x] DiskEncryption - [x] OSPOlicy - [x] SelectQuery - [x] UnenrollMdm - [x] MacSettings - [x] DeleteLabel - [x] EditCOlumns - WIP, cannot QA yet (cc @ghernandez345): - DeleteScript - RerunScript - [x] DeleteProfile - [x] DeletePackage - allow to conform to default "m" width, 650px - [x] PackQueryEditor - allow to conform to default "m" width - [x] RemovePackQuery - allow to conform to default "m" width - [x] DeletePack - allow to conform to default "m" width - [x] AddPolicy - [x] DeletePolicy - allow to conform to default "m" width - [x] NewPolicy (now "SaveNewPolicyModal") - allow to conform to default "m" width - [x] DeleteQuery - [x] NewQuery - allow to conform to default "m" width - [x] PreviewData - [x] RemoveScheduledQuery - [x] ScheduleEditor - [x] UserSettingsPage (aka "get API token") - [x] 2 x ManageAutomations – set to large - [x] 2 x PreviewPayload - allow to conform to default "m" width - [x] 2 x PreviewTicket - same as ManageAutomations ## 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>
2023-05-17 17:07:38 +00:00
className,
`${baseClass}__modal_container`,
`${baseClass}__modal_container__${width}`,
{
[`${className}__loading`]: isLoading,
}
);
const contentWrapperClasses = classnames(`${baseClass}__content-wrapper`, {
[`${baseClass}__content-wrapper-disabled`]: isContentDisabled,
});
const contentClasses = classnames(`${baseClass}__content`, {
[`${baseClass}__content-disabled`]: isContentDisabled,
});
return (
<div className={backgroundClasses}>
<div className={modalContainerClasses}>
<div className={`${baseClass}__header`}>
<span>{title}</span>
{!disableClosingModal && (
<div className={`${baseClass}__ex`}>
<Button variant="unstyled" onClick={onExit}>
<Icon name="close" color="core-fleet-black" size="medium" />
</Button>
</div>
)}
</div>
<div className={contentWrapperClasses}>
{isContentDisabled && (
<div className={`${baseClass}__disabled-overlay`} />
)}
<div className={contentClasses}>{children}</div>
</div>
</div>
</div>
);
};
export default Modal;