From 5bf4f22931edc02dd587217d0b7812f6fbaf027b Mon Sep 17 00:00:00 2001 From: Tessa Thornton Date: Thu, 5 Sep 2019 11:35:16 -0400 Subject: [PATCH] [CORL-392] add settings config for story configuration on advanced panel (#2499) * add settings config for story configuration on advanced panel * include external link in proxy description * update copy * update copy * fix lints * update snap --- .../sections/Advanced/AdvancedConfig.tsx | 9 +- .../Advanced/AdvancedConfigContainer.tsx | 1 + .../sections/Advanced/StoryCreationConfig.tsx | 97 ++++++++ .../Advanced/StoryCreationConfigContainer.tsx | 41 ++++ .../__snapshots__/advanced.spec.tsx.snap | 208 ++++++++++++++++++ src/core/client/admin/test/fixtures.ts | 6 + src/locales/en-US/admin.ftl | 14 +- 7 files changed, 374 insertions(+), 2 deletions(-) create mode 100644 src/core/client/admin/routes/Configure/sections/Advanced/StoryCreationConfig.tsx create mode 100644 src/core/client/admin/routes/Configure/sections/Advanced/StoryCreationConfigContainer.tsx diff --git a/src/core/client/admin/routes/Configure/sections/Advanced/AdvancedConfig.tsx b/src/core/client/admin/routes/Configure/sections/Advanced/AdvancedConfig.tsx index 2a65b3487..6af1fb294 100644 --- a/src/core/client/admin/routes/Configure/sections/Advanced/AdvancedConfig.tsx +++ b/src/core/client/admin/routes/Configure/sections/Advanced/AdvancedConfig.tsx @@ -7,6 +7,7 @@ import CommentStreamLiveUpdatesContainer from "./CommentStreamLiveUpdatesContain import CustomCSSConfigContainer from "./CustomCSSConfigContainer"; import EmbedCodeContainer from "./EmbedCodeContainer"; import PermittedDomainsConfigContainer from "./PermittedDomainsConfigContainer"; +import StoryCreationConfigContainer from "./StoryCreationConfigContainer"; interface Props { disabled: boolean; @@ -14,7 +15,8 @@ interface Props { PropTypesOf["settings"] & PropTypesOf["settings"] & PropTypesOf["settingsReadOnly"] & - PropTypesOf["settings"]; + PropTypesOf["settings"] & + PropTypesOf["settings"]; onInitValues: (values: any) => void; } @@ -41,6 +43,11 @@ const AdvancedConfig: FunctionComponent = ({ settings={settings} onInitValues={onInitValues} /> + ); diff --git a/src/core/client/admin/routes/Configure/sections/Advanced/AdvancedConfigContainer.tsx b/src/core/client/admin/routes/Configure/sections/Advanced/AdvancedConfigContainer.tsx index fa5e4b23a..a07853973 100644 --- a/src/core/client/admin/routes/Configure/sections/Advanced/AdvancedConfigContainer.tsx +++ b/src/core/client/admin/routes/Configure/sections/Advanced/AdvancedConfigContainer.tsx @@ -50,6 +50,7 @@ const enhanced = withFragmentContainer({ ...PermittedDomainsConfigContainer_settings ...CommentStreamLiveUpdatesContainer_settings ...CommentStreamLiveUpdatesContainer_settingsReadOnly + ...StoryCreationConfigContainer_settings } `, })(AdvancedConfigContainer); diff --git a/src/core/client/admin/routes/Configure/sections/Advanced/StoryCreationConfig.tsx b/src/core/client/admin/routes/Configure/sections/Advanced/StoryCreationConfig.tsx new file mode 100644 index 000000000..ad72ad9ec --- /dev/null +++ b/src/core/client/admin/routes/Configure/sections/Advanced/StoryCreationConfig.tsx @@ -0,0 +1,97 @@ +import { Localized } from "fluent-react/compat"; +import React, { FunctionComponent } from "react"; +import { Field } from "react-final-form"; + +import { ValidationMessage } from "coral-framework/lib/form"; +import { ExternalLink } from "coral-framework/lib/i18n/components"; +import { validateURL } from "coral-framework/lib/validation"; +import { + FormField, + HorizontalGutter, + InputLabel, + TextField, + Typography, +} from "coral-ui/components"; +import OnOffField from "../../OnOffField"; + +import Header from "../../Header"; + +interface Props { + disabled: boolean; +} + +const StoryCreationConfig: FunctionComponent = ({ disabled }) => ( + + + +
Story Creation
+
+ + Details + +
+ + + + + Lazy story creation + + + Details + + + + + + + + Story scraping + + + Details + + + + + + + + + Scraper proxy URL + + + + } + > + + When specified, allows scraping requests to use the provided + proxy. All requests will then be passed through the appropriote + proxy as parsed by the npm proxy-agent package. + + + + {({ input, meta }) => ( + <> + + + + )} + + + + +
+); + +export default StoryCreationConfig; diff --git a/src/core/client/admin/routes/Configure/sections/Advanced/StoryCreationConfigContainer.tsx b/src/core/client/admin/routes/Configure/sections/Advanced/StoryCreationConfigContainer.tsx new file mode 100644 index 000000000..eff26496b --- /dev/null +++ b/src/core/client/admin/routes/Configure/sections/Advanced/StoryCreationConfigContainer.tsx @@ -0,0 +1,41 @@ +import React from "react"; +import { graphql } from "react-relay"; + +import { StoryCreationConfigContainer_settings as SettingsData } from "coral-admin/__generated__/StoryCreationConfigContainer_settings.graphql"; +import { withFragmentContainer } from "coral-framework/lib/relay"; + +import StoryCreationConfig from "./StoryCreationConfig"; + +interface Props { + settings: SettingsData; + onInitValues: (values: SettingsData) => void; + disabled: boolean; +} + +class StoryCreationConfigContainer extends React.Component { + constructor(props: Props) { + super(props); + props.onInitValues(props.settings); + } + + public render() { + const { disabled } = this.props; + return ; + } +} + +const enhanced = withFragmentContainer({ + settings: graphql` + fragment StoryCreationConfigContainer_settings on Settings { + stories { + scraping { + enabled + proxyURL + } + disableLazy + } + } + `, +})(StoryCreationConfigContainer); + +export default enhanced; diff --git a/src/core/client/admin/test/configure/__snapshots__/advanced.spec.tsx.snap b/src/core/client/admin/test/configure/__snapshots__/advanced.spec.tsx.snap index 6e943411a..d369d1e01 100644 --- a/src/core/client/admin/test/configure/__snapshots__/advanced.spec.tsx.snap +++ b/src/core/client/admin/test/configure/__snapshots__/advanced.spec.tsx.snap @@ -329,6 +329,214 @@ https://domain.com). +
+
+

+ Story creation +

+

+ Advanced settings for how stories are created within Coral. +

+
+
+
+
+ +

+ Enable stories to be automatically created when they are published from your CMS. +

+
+
+ + +
+
+ + +
+
+
+
+
+
+ +

+ Enable story metadata to be automatically scraped when they are published from your CMS. +

+
+
+ + +
+
+ + +
+
+
+
+
+
+ +

+ When specified, allows scraping requests to use the provided +proxy. All requests will then be passed through the appropriote +proxy as parsed by the + + npm proxy-agent + + package. +

+
+ +
+
+
+
+
diff --git a/src/core/client/admin/test/fixtures.ts b/src/core/client/admin/test/fixtures.ts index e34b7860b..13f4dcdb5 100644 --- a/src/core/client/admin/test/fixtures.ts +++ b/src/core/client/admin/test/fixtures.ts @@ -141,6 +141,12 @@ export const settings = createFixture({ }, }, }, + stories: { + scraping: { + enabled: true, + }, + disableLazy: false, + }, accountFeatures: { downloadComments: true, changeUsername: true, diff --git a/src/locales/en-US/admin.ftl b/src/locales/en-US/admin.ftl index 3938aea10..7d7b18a86 100644 --- a/src/locales/en-US/admin.ftl +++ b/src/locales/en-US/admin.ftl @@ -760,4 +760,16 @@ configure-account-features-download-comments = Download their comments configure-account-features-download-comments-details = Commenters can download a csv of their comment history. configure-account-features-delete-account = Delete their account configure-account-features-delete-account-details = - Removes all of their comment data, username, and email address from the site and the database. \ No newline at end of file + Removes all of their comment data, username, and email address from the site and the database. + +configure-advanced-stories = Story creation +configure-advanced-stories-explanation = Advanced settings for how stories are created within Coral. +configure-advanced-stories-lazy = Lazy story creation +configure-advanced-stories-lazy-detail = Enable stories to be automatically created when they are published from your CMS. +configure-advanced-stories-scraping = Story scraping +configure-advanced-stories-scraping-detail = Enable story metadata to be automatically scraped when they are published from your CMS. +configure-advanced-stories-proxy = Scraper proxy url +configure-advanced-stories-proxy-detail = + When specified, allows scraping requests to use the provided + proxy. All requests will then be passed through the appropriote + proxy as parsed by the npm proxy-agent package. \ No newline at end of file