Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
2 changes: 1 addition & 1 deletion app/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"redux-logger": "3.0.6",
"styled-components": "6.1.11",
"stylis": "4.3.2",
"tno-core": "1.0.27"
"tno-core": "1.0.28"
},
"devDependencies": {
"@simbathesailor/use-what-changed": "2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export const ReportContentOptions = () => {
name="settings.content.excludeHistorical"
tooltip="Exclude content already reported on in prior instances of this report"
/>
<FormikCheckbox
label="Remove duplicate titles from the last 3 days"
name="settings.content.removeDuplicateTitles3Days"
tooltip="Keep only the most recent story when duplicate titles are published within the past three days."
/>
<FormikSelect
label="Excludes content already reported on in the selected reports"
name="settings.content.excludeReports"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export const ReportSectionContent = ({ index }: IReportSectionContentProps) => {
label="Remove Duplicate Content"
tooltip="Remove content from this section that is in above sections"
/>
<FormikCheckbox
name={`sections.${index}.settings.removeDuplicateTitles3Days`}
label="Remove duplicate titles from the last 3 days"
tooltip="Keep only the most recent story when duplicate titles are published within the past three days."
/>
<Show visible={!!section.folderId || !!section.linkedReportId}>
<FormikCheckbox
name={`sections.${index}.settings.overrideExcludeHistorical`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export const ReportSectionGallery = ({ index }: IReportSectionGalleryProps) => {
label="Remove Duplicate Content"
tooltip="Remove content from this section that is in above sections"
/>
<FormikCheckbox
name={`sections.${index}.settings.removeDuplicateTitles3Days`}
label="Remove duplicate titles from the last 3 days"
tooltip="Keep only the most recent story when duplicate titles are published within the past three days."
/>
<Show visible={!!section.folderId || !!section.linkedReportId}>
<FormikCheckbox
name={`sections.${index}.settings.overrideExcludeHistorical`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export const ReportSectionMediaAnalytics = ({ index }: IReportSectionMediaAnalyt
label="Remove duplicate content"
tooltip="Remove content from this section that is in above sections"
/>
<FormikCheckbox
name={`sections.${index}.settings.removeDuplicateTitles3Days`}
label="Remove duplicate titles from the last 3 days"
tooltip="Keep only the most recent story when duplicate titles are published within the past three days."
/>
</Show>
<Show visible={!!section.folderId || !!section.linkedReportId}>
<FormikCheckbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const defaultReport: IReportModel = {
excludeHistorical: false,
excludeReports: [],
highlightKeywords: false,
removeDuplicateTitles3Days: false,
showLinkToStory: false,
clearFolders: false,
onlyNewContent: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const createReportSection = (
label: '',
useAllContent: type === ReportSectionTypeName.MediaAnalytics,
removeDuplicates: false,
removeDuplicateTitles3Days: false,
overrideExcludeHistorical: false,
showHeadlines: type === ReportSectionTypeName.TableOfContents,
showFullStory: type === ReportSectionTypeName.Content,
Expand Down
10 changes: 5 additions & 5 deletions app/editor/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12209,7 +12209,7 @@ __metadata:
sass-extract-loader: 1.1.0
styled-components: 6.1.11
stylis: 4.3.2
tno-core: 1.0.27
tno-core: 1.0.28
typescript: 4.9.5
vitest: 3.0.7
languageName: unknown
Expand Down Expand Up @@ -16674,9 +16674,9 @@ __metadata:
languageName: node
linkType: hard

"tno-core@npm:1.0.27":
version: 1.0.27
resolution: "tno-core@npm:1.0.27"
"tno-core@npm:1.0.28":
version: 1.0.28
resolution: "tno-core@npm:1.0.28"
dependencies:
"@elastic/elasticsearch": ^8.13.1
"@fortawesome/free-solid-svg-icons": ^6.4.2
Expand Down Expand Up @@ -16709,7 +16709,7 @@ __metadata:
styled-components: ^6.1.11
stylis: ^4.3.2
yup: ^1.1.1
checksum: 0a37ba95419455d675d723d1373aab1c17d534d85c9ead4192653bb722b8da1d2c386444b4bdc9c4a806f0df8fc54f2e944ee24f7ae32d3ff9b28445b841384b
checksum: 69ecabc7713077cf82d686e05335a373a83f609d4eac6298f197ed6801ce832d5624801e2fb5eccafef971e7c0c88509a3178aae95a8b2f131086ced71e5b6c9
languageName: node
linkType: hard

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion app/subscriber/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"sheetjs": "file:packages/xlsx-0.20.1.tgz",
"styled-components": "6.1.11",
"stylis": "4.3.2",
"tno-core": "1.0.27"
"tno-core": "1.0.28"
},
"devDependencies": {
"@testing-library/jest-dom": "6.6.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const defaultReport = (ownerId: number, templateId: number): IReportForm
excludeReports: [],
highlightKeywords: false,
showLinkToStory: false,
removeDuplicateTitles3Days: false,
clearFolders: false,
onlyNewContent: false,
copyPriorInstance: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const defaultReportSection = (
showImage: false,
direction: type === ReportSectionTypeName.Gallery ? 'row' : 'column',
removeDuplicates: false,
removeDuplicateTitles3Days: false,
overrideExcludeHistorical: false,
hideEmpty:
type === ReportSectionTypeName.TableOfContents ||
Expand Down
10 changes: 7 additions & 3 deletions app/subscriber/src/features/my-reports/edit/ReportEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from 'tno-core';

import { IReportForm, IReportInstanceContentForm } from '../interfaces';
import { toForm } from '../utils';
import { sanitizeReport, toForm } from '../utils';
import {
ReportContentMenuOption,
ReportHistoryMenuOption,
Expand Down Expand Up @@ -125,10 +125,14 @@ export const ReportEditForm = React.forwardRef<HTMLDivElement | null, IReportEdi

const handleStartNewReport = React.useCallback(
async (values: IReportForm) => {
const sanitizedValues = sanitizeReport(values);
try {
setSubmitting(true);
const result = await updateReport(values);
const form = await onGenerate(toForm({ ...result, instances: values.instances }), true);
const result = await updateReport(sanitizedValues);
const form = await onGenerate(
toForm({ ...result, instances: sanitizedValues.instances }),
true,
);
if (form) updateForm(form);
} catch {
} finally {
Expand Down
37 changes: 19 additions & 18 deletions app/subscriber/src/features/my-reports/edit/ReportEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Col, IReportMessageModel, MessageTargetKey, ReportStatusName, Show } fr

import { defaultReport } from '../constants';
import { IReportForm } from '../interfaces';
import { sortContent, toForm } from '../utils';
import { sanitizeReport, sortContent, toForm } from '../utils';
import { ContentEditForm } from './content';
import { ReportEditContextProvider } from './ReportEditContext';
import { ReportEditForm } from './ReportEditForm';
Expand Down Expand Up @@ -210,27 +210,28 @@ export const ReportEditPage = () => {

const handleSubmit = React.useCallback(
async (values: IReportForm) => {
const sanitizedValues = sanitizeReport(values);
try {
const originalId = values.id;
const originalReportSections = values.sections;
const originalId = sanitizedValues.id;
const originalReportSections = sanitizedValues.sections;
const sameNameReport = myReports.some(
(r) =>
r.name.trim().toLocaleLowerCase() === values.name.trim().toLocaleLowerCase() &&
r.id !== values.id,
r.name.trim().toLocaleLowerCase() === sanitizedValues.name.trim().toLocaleLowerCase() &&
r.id !== sanitizedValues.id,
);
if (sameNameReport) {
toast.error(`A report with the name '${values.name}' already exists.`);
toast.error(`A report with the name '${sanitizedValues.name}' already exists.`);
} else {
if (values.instances.length) {
if (sanitizedValues.instances.length) {
// Apply new sort order values for content to stop content from moving around when it has the same sort order value.
values.instances[0] = {
...values.instances[0],
content: sortContent(values.instances[0].content, true),
sanitizedValues.instances[0] = {
...sanitizedValues.instances[0],
content: sortContent(sanitizedValues.instances[0].content, true),
};
}
const report = originalId
? await updateReport(
values,
sanitizedValues,
instance &&
[
ReportStatusName.Pending,
Expand All @@ -240,15 +241,15 @@ export const ReportEditPage = () => {
].includes(instance.status),
)
: await addReport({
...values,
ownerId: values.ownerId ?? userInfo?.id ?? 0,
...sanitizedValues,
ownerId: sanitizedValues.ownerId ?? userInfo?.id ?? 0,
settings: {
...values.settings,
...sanitizedValues.settings,
subject: {
...values.settings.subject,
text: values.settings.subject.text.length // Default email subject line
? values.settings.subject.text
: values.name,
...sanitizedValues.settings.subject,
text: sanitizedValues.settings.subject.text.length // Default email subject line
? sanitizedValues.settings.subject.text
: sanitizedValues.name,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Bar } from 'components/bar';
import { Sentiment } from 'components/sentiment';
import { IReportForm, IReportInstanceContentForm } from 'features/my-reports/interfaces';
import { IContentValidationErrors } from 'features/my-reports/interfaces/IContentValidationErrors';
import { toForm } from 'features/my-reports/utils';
import { sanitizeReport, toForm } from 'features/my-reports/utils';
import { formatDate } from 'features/utils';
import React from 'react';
import { useApp, useContent, useReports } from 'store/hooks';
Expand Down Expand Up @@ -186,7 +186,7 @@ export const ContentEditForm = React.forwardRef<HTMLDivElement | null, IContentE
}
let contentIndex = 0;

const updatedReport = {
const updatedReport = sanitizeReport({
...values,
instances: values.instances.map((instance) => ({
...instance,
Expand All @@ -197,7 +197,9 @@ export const ContentEditForm = React.forwardRef<HTMLDivElement | null, IContentE
return c;
}),
})),
};
});

setValues(updatedReport);

// Update the report instances with the latest content.
const reportResult = await updateReport(updatedReport, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Modal } from 'components/modal';
import { RefreshButton } from 'components/refresh-button';
import { StartNextReportInfo } from 'features/my-reports/components';
import { IReportForm, IReportInstanceContentForm } from 'features/my-reports/interfaces';
import { toForm } from 'features/my-reports/utils';
import { sanitizeReport, toForm } from 'features/my-reports/utils';
import React from 'react';
import { FaArrowsRotate, FaToggleOff, FaToggleOn } from 'react-icons/fa6';
import { FaAngleDown, FaMinus } from 'react-icons/fa6';
Expand Down Expand Up @@ -190,13 +190,15 @@ export const ReportEditContentForm = React.forwardRef<
if (
excludeContentInUnsentReport !== values.settings.content.excludeContentInUnsentReport
) {
const result = await updateReport({
...values,
settings: {
...values.settings,
content: { ...values.settings.content, excludeContentInUnsentReport },
},
});
const result = await updateReport(
sanitizeReport({
...values,
settings: {
...values.settings,
content: { ...values.settings.content, excludeContentInUnsentReport },
},
}),
);
form = toForm(result);
}
form = await onGenerate(form, true);
Expand All @@ -205,17 +207,19 @@ export const ReportEditContentForm = React.forwardRef<
excludeContentInUnsentReport !== values.settings.content.excludeContentInUnsentReport
) {
setExcludeContentInUnsentReport(values.settings.content.excludeContentInUnsentReport);
const result = await updateReport({
...form,
settings: {
...values.settings,
content: {
...values.settings.content,
excludeContentInUnsentReport:
values.settings.content.excludeContentInUnsentReport,
const result = await updateReport(
sanitizeReport({
...form,
settings: {
...values.settings,
content: {
...values.settings.content,
excludeContentInUnsentReport:
values.settings.content.excludeContentInUnsentReport,
},
},
},
});
}),
);
form = toForm(result);
}
if (form) updateForm(form);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ export const ReportEditPreferencesForm = () => {
name="settings.content.excludeHistorical"
label="Exclude stories that have been sent out in previous report"
/>
<Row>
<FormikCheckbox
name="settings.content.removeDuplicateTitles3Days"
label="Remove duplicate titles from the last 3 days"
/>
<span className="info">
Keep only the most recent story when duplicate titles are published within the past
three days.
</span>
</Row>
<Checkbox
label="Exclude stories that appeared in the following report(s):"
checked={excludeContentInReports}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ export const ReportSectionContent = React.forwardRef<HTMLDivElement, IReportSect
not apply to charts that link to other reports)
</span>
</Row>
<Row>
<FormikCheckbox
name={`sections.${index}.settings.removeDuplicateTitles3Days`}
label="Remove duplicate titles from the last 3 days"
/>
<span className="info">
Keep only the most recent story when duplicate titles occur within the last three
days.
</span>
</Row>
<Show visible={!!section.folderId || !!section.linkedReportId}>
<Row>
<FormikCheckbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ export const ReportSectionGallery = React.forwardRef<HTMLDivElement, IReportSect
(does not apply to charts that link to other reports)
</span>
</Row>
<Row>
<FormikCheckbox
name={`sections.${index}.settings.removeDuplicateTitles3Days`}
label="Remove duplicate titles from the last 3 days"
/>
<span className="info">
Keep only the most recent story when duplicate titles occur within the last three
days.
</span>
</Row>
</Show>
<Row>
<FormikCheckbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export const ReportSectionMediaAnalytics = React.forwardRef<
not apply to charts that link to other reports)
</span>
</Row>
<Row>
<FormikCheckbox
name={`sections.${index}.settings.removeDuplicateTitles3Days`}
label="Remove duplicate titles from the last 3 days"
/>
<span className="info">
Keep only the most recent story when duplicate titles occur within the last three
days.
</span>
</Row>
</Show>
<Row>
<FormikCheckbox
Expand Down
Loading
Loading