Skip to content

Commit

Permalink
Merge branch 'main' into SteveDMurphy-3329-dsr-ssh-option
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDMurphy authored Jun 14, 2023
2 parents d787c43 + 225f211 commit 5764332
Show file tree
Hide file tree
Showing 17 changed files with 366 additions and 284 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ The types of changes are:
## [Unreleased](https://github.com/ethyca/fides/compare/2.15.0...main)

### Added

- Included optional env vars to have postgres or Redshift connected via bastion host [#3374](https://github.com/ethyca/fides/pull/3374/)
- Support for acknowledge button for notice-only Privacy Notices and to disable toggling them off [#3546](https://github.com/ethyca/fides/pull/3546)

### Fixed

Expand Down
93 changes: 22 additions & 71 deletions clients/fides-js/src/components/ConsentBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,88 +1,39 @@
import { h, FunctionComponent } from "preact";
import { ButtonType, ExperienceConfig } from "../lib/consent-types";
import Button from "./Button";
import { h, FunctionComponent, VNode } from "preact";
import { ExperienceConfig } from "../lib/consent-types";
import CloseButton from "./CloseButton";

interface BannerProps {
experience: ExperienceConfig;
onAcceptAll: () => void;
onRejectAll: () => void;
onManagePreferences: () => void;
onClose: () => void;
bannerIsOpen: boolean;
buttonGroup: VNode;
}

const ConsentBanner: FunctionComponent<BannerProps> = ({
experience,
onAcceptAll,
onRejectAll,
onManagePreferences,
buttonGroup,
onClose,
bannerIsOpen,
}) => {
const {
title = "Manage your consent",
description = "This website processes your data respectfully, so we require your consent to use cookies.",
accept_button_label: acceptButtonLabel = "Accept All",
reject_button_label: rejectButtonLabel = "Reject All",
privacy_preferences_link_label:
privacyPreferencesLabel = "Manage preferences",
} = experience;

const handleRejectAll = () => {
onRejectAll();
onClose();
};

const handleAcceptAll = () => {
onAcceptAll();
onClose();
};

return (
<div
id="fides-banner-container"
className={`fides-banner fides-banner-bottom ${
bannerIsOpen ? "" : "fides-banner-hidden"
} `}
>
<div id="fides-banner">
<div id="fides-banner-inner">
<CloseButton ariaLabel="Close banner" onClick={onClose} />
<div id="fides-banner-title" className="fides-banner-title">
{title}
</div>
<div
id="fides-banner-description"
className="fides-banner-description"
>
{description}
</div>
<div id="fides-banner-buttons" className="fides-banner-buttons">
<span className="fides-banner-buttons-left">
<Button
buttonType={ButtonType.TERTIARY}
label={privacyPreferencesLabel}
onClick={onManagePreferences}
/>
</span>
<span className="fides-banner-buttons-right">
<Button
buttonType={ButtonType.PRIMARY}
label={rejectButtonLabel}
onClick={handleRejectAll}
/>
<Button
buttonType={ButtonType.PRIMARY}
label={acceptButtonLabel}
onClick={handleAcceptAll}
/>
</span>
</div>
}) => (
<div
id="fides-banner-container"
className={`fides-banner fides-banner-bottom ${
bannerIsOpen ? "" : "fides-banner-hidden"
} `}
>
<div id="fides-banner">
<div id="fides-banner-inner">
<CloseButton ariaLabel="Close banner" onClick={onClose} />
<div id="fides-banner-title" className="fides-banner-title">
{experience.title}
</div>
<div id="fides-banner-description" className="fides-banner-description">
{experience.description}
</div>
{buttonGroup}
</div>
</div>
);
};
</div>
);

export default ConsentBanner;
98 changes: 98 additions & 0 deletions clients/fides-js/src/components/ConsentButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { h } from "preact";
import Button from "./Button";
import {
ButtonType,
PrivacyExperience,
ConsentMechanism,
PrivacyNotice,
} from "../lib/consent-types";

type NoticeKeys = Array<PrivacyNotice["notice_key"]>;

const ConsentButtons = ({
experience,
onManagePreferencesClick,
onSave,
enabledKeys,
isInModal,
}: {
experience: PrivacyExperience;
onSave: (noticeKeys: NoticeKeys) => void;
onManagePreferencesClick?: () => void;
enabledKeys: NoticeKeys;
isInModal?: boolean;
}) => {
if (!experience.experience_config || !experience.privacy_notices) {
return null;
}

const { experience_config: config, privacy_notices: notices } = experience;
const isAllNoticeOnly = notices.every(
(n) => n.consent_mechanism === ConsentMechanism.NOTICE_ONLY
);

const handleAcceptAll = () => {
onSave(notices.map((n) => n.notice_key));
};

const handleRejectAll = () => {
onSave(
notices
.filter((n) => n.consent_mechanism === ConsentMechanism.NOTICE_ONLY)
.map((n) => n.notice_key)
);
};

if (isAllNoticeOnly) {
return (
<div
className={`fides-acknowledge-button-container ${
isInModal ? "" : "fides-banner-acknowledge"
}`}
>
<Button
buttonType={ButtonType.PRIMARY}
label={config.acknowledge_button_label}
onClick={handleAcceptAll}
/>
</div>
);
}

return (
<div id="fides-button-group">
{onManagePreferencesClick ? (
<div>
<Button
buttonType={ButtonType.TERTIARY}
label={config.privacy_preferences_link_label}
onClick={onManagePreferencesClick}
/>
</div>
) : null}
<div className={isInModal ? "fides-modal-button-group" : undefined}>
{isInModal ? (
<Button
buttonType={ButtonType.SECONDARY}
label={config.save_button_label}
onClick={() => {
onSave(enabledKeys);
}}
/>
) : null}
<Button
buttonType={ButtonType.PRIMARY}
label={config.reject_button_label}
onClick={handleRejectAll}
/>
<Button
buttonType={ButtonType.PRIMARY}
label={config.accept_button_label}
onClick={handleAcceptAll}
/>
</div>
</div>
);
};

export default ConsentButtons;
51 changes: 5 additions & 46 deletions clients/fides-js/src/components/ConsentModal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { h } from "preact";
import { h, VNode } from "preact";
import { Attributes } from "../lib/a11y-dialog";
import Button from "./Button";
import {
ButtonType,
PrivacyNotice,
ExperienceConfig,
} from "../lib/consent-types";
import { PrivacyNotice, ExperienceConfig } from "../lib/consent-types";
import NoticeToggles from "./NoticeToggles";
import CloseButton from "./CloseButton";

Expand All @@ -17,38 +12,18 @@ const ConsentModal = ({
notices,
enabledNoticeKeys,
onChange,
onClose,
onSave,
onRejectAll,
onAcceptAll,
buttonGroup,
}: {
attributes: Attributes;
experience: ExperienceConfig;
notices: PrivacyNotice[];
enabledNoticeKeys: NoticeKeys;
onClose: () => void;
onChange: (enabledNoticeKeys: NoticeKeys) => void;
onSave: (enabledNoticeKeys: NoticeKeys) => void;
onRejectAll: () => void;
onAcceptAll: () => void;
buttonGroup: VNode;
}) => {
const { container, overlay, dialog, title, closeButton } = attributes;

const handleSave = () => {
onSave(enabledNoticeKeys);
onClose();
};

const handleAcceptAll = () => {
onAcceptAll();
onClose();
};

const handleRejectAll = () => {
onRejectAll();
onClose();
};

return (
// @ts-ignore A11yDialog ref obj type isn't quite the same
<div
Expand Down Expand Up @@ -83,23 +58,7 @@ const ConsentModal = ({
onChange={onChange}
/>
</div>
<div className="fides-modal-button-group">
<Button
label={experience.save_button_label}
buttonType={ButtonType.SECONDARY}
onClick={handleSave}
/>
<Button
label={experience.reject_button_label}
buttonType={ButtonType.PRIMARY}
onClick={handleRejectAll}
/>
<Button
label={experience.accept_button_label}
buttonType={ButtonType.PRIMARY}
onClick={handleAcceptAll}
/>
</div>
{buttonGroup}
{experience.privacy_policy_link_label &&
experience.privacy_policy_url ? (
<a
Expand Down
3 changes: 2 additions & 1 deletion clients/fides-js/src/components/NoticeToggles.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h } from "preact";

import { PrivacyNotice } from "../lib/consent-types";
import { ConsentMechanism, PrivacyNotice } from "../lib/consent-types";
import Toggle from "./Toggle";
import Divider from "./Divider";
import { useDisclosure } from "../lib/hooks";
Expand Down Expand Up @@ -52,6 +52,7 @@ const NoticeToggle = ({
id={notice.notice_key}
checked={checked}
onChange={onToggle}
disabled={notice.consent_mechanism === ConsentMechanism.NOTICE_ONLY}
/>
</div>
<p {...getDisclosureProps()}>{notice.description}</p>
Expand Down
38 changes: 24 additions & 14 deletions clients/fides-js/src/components/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import "./fides.css";
import { useA11yDialog } from "../lib/a11y-dialog";
import ConsentModal from "./ConsentModal";
import { useHasMounted } from "../lib/hooks";
import ConsentButtons from "./ConsentButtons";

export interface OverlayProps {
options: FidesOptions;
Expand Down Expand Up @@ -149,13 +150,6 @@ const Overlay: FunctionComponent<OverlayProps> = ({
setBannerIsOpen(false);
};

const handleAcceptAll = () => {
handleUpdatePreferences(privacyNotices.map((n) => n.notice_key));
};
const handleRejectAll = () => {
handleUpdatePreferences([]);
};

if (!hasMounted) {
return null;
}
Expand All @@ -166,17 +160,25 @@ const Overlay: FunctionComponent<OverlayProps> = ({
}

return (
<div id="fides-js-root">
<div>
{showBanner ? (
<ConsentBanner
experience={experience.experience_config}
onAcceptAll={handleAcceptAll}
onRejectAll={handleRejectAll}
onManagePreferences={handleManagePreferencesClick}
bannerIsOpen={bannerIsOpen}
onClose={() => {
setBannerIsOpen(false);
}}
buttonGroup={
<ConsentButtons
experience={experience}
onManagePreferencesClick={handleManagePreferencesClick}
enabledKeys={draftEnabledNoticeKeys}
onSave={(keys) => {
handleUpdatePreferences(keys);
setBannerIsOpen(false);
}}
/>
}
/>
) : null}
<ConsentModal
Expand All @@ -186,9 +188,17 @@ const Overlay: FunctionComponent<OverlayProps> = ({
onChange={setDraftEnabledNoticeKeys}
notices={privacyNotices}
onClose={handleCloseModal}
onAcceptAll={handleAcceptAll}
onRejectAll={handleRejectAll}
onSave={handleUpdatePreferences}
buttonGroup={
<ConsentButtons
experience={experience}
enabledKeys={draftEnabledNoticeKeys}
isInModal
onSave={(keys) => {
handleUpdatePreferences(keys);
handleCloseModal();
}}
/>
}
/>
</div>
);
Expand Down
Loading

0 comments on commit 5764332

Please sign in to comment.