Skip to content

Commit

Permalink
create preliminary DSA configuration on tenant settings
Browse files Browse the repository at this point in the history
adds a new option under Admin > Configure > Advanced
  • Loading branch information
nick-funk committed Sep 25, 2023
1 parent 106f9a6 commit 3b8440b
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AdvancedConfigContainer_settings } from "coral-admin/__generated__/Adva
import AMPConfig from "./AMPConfig";
import CommentStreamLiveUpdatesContainer from "./CommentStreamLiveUpdatesContainer";
import CustomCSSConfig from "./CustomCSSConfig";
import { DSAConfigContainer } from "./DSAConfigContainer";
import EmbeddedCommentRepliesConfig from "./EmbeddedCommentRepliesConfig";
import ForReviewQueueConfig from "./ForReviewQueueConfig";
import StoryCreationConfig from "./StoryCreationConfig";
Expand All @@ -39,6 +40,7 @@ const AdvancedConfigContainer: React.FunctionComponent<Props> = ({
<StoryCreationConfig disabled={submitting} />
<AMPConfig disabled={submitting} />
<ForReviewQueueConfig disabled={submitting} />
<DSAConfigContainer disabled={submitting} />
</HorizontalGutter>
);
};
Expand All @@ -53,6 +55,7 @@ const enhanced = withFragmentContainer<Props>({
...CommentStreamLiveUpdatesContainer_settings
...AMPConfig_formValues @relay(mask: false)
...ForReviewQueueConfig_formValues @relay(mask: false)
...DSAConfigContainer_formValues @relay(mask: false)
}
`,
})(AdvancedConfigContainer);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Localized } from "@fluent/react/compat";
import React, { FunctionComponent } from "react";
import { graphql } from "react-relay";

import Header from "../../Header";
import ConfigBoxWithToggleField from "../Auth/ConfigBoxWithToggleField";

// eslint-disable-next-line no-unused-expressions
graphql`
fragment DSAConfigContainer_formValues on Settings {
dsa {
enabled
}
}
`;

interface Props {
disabled: boolean;
}

export const DSAConfigContainer: FunctionComponent<Props> = ({ disabled }) => {
return (
<ConfigBoxWithToggleField
data-testid="configure-advanced-dsaConfig"
title={
<Localized id="configure-advanced-dsaConfig-title">
<Header container="h2">DSA Features</Header>
</Localized>
}
name="dsa.enabled"
disabled={disabled}
>
{(disabledInside) => <>TODO</>}
</ConfigBoxWithToggleField>
);
};
9 changes: 9 additions & 0 deletions server/src/core/server/graph/resolvers/DSAConfiguration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as settings from "coral-server/models/settings";

import { GQLDSAConfigurationTypeResolver } from "coral-server/graph/schema/__generated__/types";

export const DSAConfiguration: GQLDSAConfigurationTypeResolver<settings.RTEConfiguration> =
{
enabled: (config, args, { tenant }) =>
tenant.dsa && tenant.dsa.enabled ? tenant.dsa.enabled : false,
};
6 changes: 5 additions & 1 deletion server/src/core/server/graph/resolvers/Settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { defaultRTEConfiguration } from "coral-server/models/settings";
import {
defaultDSAConfiguration,
defaultRTEConfiguration,
} from "coral-server/models/settings";
import validFeatureFlagsFilter from "coral-server/models/settings/validFeatureFlagsFilter";
import {
areRepliesFlattened,
Expand Down Expand Up @@ -69,4 +72,5 @@ export const Settings: GQLSettingsTypeResolver<Tenant> = {
}
return flairBadges;
},
dsa: ({ dsa = defaultDSAConfiguration }) => dsa,
};
28 changes: 28 additions & 0 deletions server/src/core/server/graph/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,14 @@ type RTEConfiguration {
sarcasm: Boolean!
}

type DSAConfiguration {
"""
enabled when true turns on the European Union DSA compliance
features for commenting, reporting, and moderation flows.
"""
enabled: Boolean!
}

"""
Settings stores the global settings for a given Tenant.
"""
Expand Down Expand Up @@ -2222,6 +2230,12 @@ type Settings @cacheControl(maxAge: 30) {
they are enabled and any configured image urls
"""
flairBadges: FlairBadgeConfiguration

"""
dsa specifies the configuration for the European Union's DSA compliance
features and whether they are enabled.
"""
dsa: DSAConfiguration!
}

################################################################################
Expand Down Expand Up @@ -5598,6 +5612,14 @@ input FlairBadgeConfigurationInput {
flairBadgeURLs: [String!]
}

"""
DSAConfigurationInput specifies the configuration for DSA European Union
moderation and reporting features.
"""
input DSAConfigurationInput {
enabled: Boolean
}

"""
SettingsInput is the partial type of the Settings type for performing mutations.
"""
Expand Down Expand Up @@ -5802,6 +5824,12 @@ input SettingsInput {
they are enabled and any configured image urls
"""
flairBadges: FlairBadgeConfigurationInput

"""
dsa specifies the configuration for DSA European Union moderation and
reporting features.
"""
dsa: DSAConfigurationInput
}

"""
Expand Down
9 changes: 9 additions & 0 deletions server/src/core/server/models/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export type Settings = GlobalModerationSettings &
| "announcement"
| "memberBios"
| "embeddedComments"
| "dsa"
> & {
/**
* auth is the set of configured authentication integrations.
Expand Down Expand Up @@ -417,3 +418,11 @@ export const defaultRTEConfiguration: RTEConfiguration = {
spoiler: false,
strikethrough: false,
};

export interface DSAConfiguration {
enabled: boolean;
}

export const defaultDSAConfiguration: DSAConfiguration = {
enabled: false,
};
3 changes: 3 additions & 0 deletions server/src/core/server/models/tenant/tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ export async function createTenant(
flairBadgesEnabled: false,
badges: [],
},
dsa: {
enabled: false,
},
};

// Create the new Tenant by merging it together with the defaults.
Expand Down
3 changes: 3 additions & 0 deletions server/src/core/server/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ export const createTenantFixture = (
flattenReplies: false,
disableDefaultFonts: false,
emailDomainModeration: [],
dsa: {
enabled: false,
},
};

return merge(fixture, defaults);
Expand Down

0 comments on commit 3b8440b

Please sign in to comment.