Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge hotfix 2.6.3 develop #1868

Merged
merged 36 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2b5c9eb
[SDAAP-64] Fix null location crash in notifications (#1773)
marwoodandrew Mar 17, 2023
08c95a6
[SDESK-6873] fix: Backport moment-timezone upgrade
MarkLark86 Apr 4, 2023
6bc379f
fix(client): Change moment import to moment-timezone
MarkLark86 Dec 14, 2022
76a8ebb
fix lint errors
MarkLark86 Apr 5, 2023
e0fec2d
[SDNTB-804] feature: Add priority to Events, Planning and Coverages (…
MarkLark86 Apr 11, 2023
8e67be3
change limit when calling onclusive api (#1783)
petrjasek Apr 12, 2023
9f0ab26
fix date filtering for all day events (#1782)
petrjasek Apr 14, 2023
6afa221
avoid dynamic mapping for event calendars (#1784)
petrjasek Apr 17, 2023
ce4288a
[SDNTB-804] fix(ui): Load ContentProfiles using its name not _id (#1785)
MarkLark86 Apr 17, 2023
96aee19
fix onclusive ingest (#1786)
petrjasek Apr 20, 2023
a357a54
check all timezones when parsing onclusive (#1787)
petrjasek Apr 24, 2023
f2b3a96
fix events not visible in the UI (#1790)
petrjasek Apr 24, 2023
3a3c76c
there was an error in timezone detection (#1792)
petrjasek Apr 25, 2023
869860a
fix event date not visible in preview (#1791)
petrjasek Apr 25, 2023
4949713
Fix : Some events ingested from Onclusive do not contain the complete…
devketanpro Apr 26, 2023
f50bd3b
set language for onclusive events based on product (#1796)
petrjasek Apr 28, 2023
32f25d6
fix timestamps from onclusive (#1797)
petrjasek Apr 28, 2023
6b10dda
use languages with -CA for onclusive events (#1798)
petrjasek May 2, 2023
1943b39
Merge remote-tracking branch 'origin/hotfix/2.5.2' into hotfix/2.6.2
petrjasek May 3, 2023
b7bda8f
use /date api for initial import from onclusive (#1801)
petrjasek May 10, 2023
33ba528
[SDESK-6829] fix(ingest_rule): Skip autopost action if item is alread…
MarkLark86 May 16, 2023
c596b2e
fix server requirements (#1804)
petrjasek May 17, 2023
6d5a6a5
release 2.6.2
petrjasek May 17, 2023
3dc04d4
[SDESK-6972] fix(api): Allow Event dates.tz to have a null value (#1816)
MarkLark86 Jun 27, 2023
78d7529
Update UIF (#1851)
thecalcc Sep 15, 2023
4d884f3
fix switch label param (#1855)
petrjasek Sep 27, 2023
10ffa65
update server requirements
petrjasek Oct 13, 2023
b7d1008
log each event id we process from onclusive (#1864)
petrjasek Oct 13, 2023
837cd94
Merge branch 'hotfix/2.6.3' into develop
MarkLark86 Oct 20, 2023
67cff61
fix missed conflict in package.json
MarkLark86 Oct 20, 2023
0df96f5
fix: add default values to util functions
MarkLark86 Oct 20, 2023
44decac
add missing import
MarkLark86 Oct 20, 2023
7f8a480
fix merge issues
MarkLark86 Oct 20, 2023
244a410
fix default planning language value
MarkLark86 Oct 20, 2023
5601304
fix(e2e): Select tree popover from body not dom parent
MarkLark86 Oct 23, 2023
d0bdc39
fix(unit tests): Store utcnow before checking versionposted
MarkLark86 Oct 24, 2023
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
6 changes: 6 additions & 0 deletions .github/workflows/lint-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install black~=23.0
- run: black --check server

Expand All @@ -16,6 +18,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install flake8
- run: flake8 server

Expand All @@ -24,5 +28,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install -Ur server/mypy-requirements.txt
- run: mypy server
14 changes: 12 additions & 2 deletions client/actions/agenda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {cloneDeep, pick, get, sortBy, findIndex} from 'lodash';
import {Moment} from 'moment';

import {IEventItem, IPlanningItem, IAgenda} from '../interfaces';
import {planningApi} from '../superdeskApi';

import {AGENDA, MODALS, EVENTS} from '../constants';
import {getErrorMessage, gettext, planningUtils} from '../utils';
Expand Down Expand Up @@ -240,15 +241,20 @@ const addEventToCurrentAgenda = (
);

export function convertEventToPlanningItem(event: IEventItem): Partial<IPlanningItem> {
const defaultPlace = selectors.general.defaultPlaceList(planningApi.redux.store.getState());
const defaultValues = planningUtils.defaultPlanningValues(null, defaultPlace);

let newPlanningItem: Partial<IPlanningItem> = {
...defaultValues,
type: 'planning',
event_item: event._id,
planning_date: event._sortDate || event.dates?.start,
place: event.place,
place: event.place || defaultPlace,
subject: event.subject,
anpa_category: event.anpa_category,
agendas: [],
language: event.language,
language: event.language || defaultValues.language,
languages: event.languages || defaultValues.languages,
};

newPlanningItem = convertStringFields(
Expand All @@ -269,6 +275,10 @@ export function convertEventToPlanningItem(event: IEventItem): Partial<IPlanning
newPlanningItem.languages = event.languages;
}

if (event.priority != null) {
newPlanningItem.priority = event.priority;
}

return newPlanningItem;
}

Expand Down
8 changes: 6 additions & 2 deletions client/actions/events/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,15 +741,19 @@ const receiveEventHistory = (eventHistoryItems) => ({
*/
const createEventFromPlanning = (plan: IPlanningItem) => (
(dispatch, getState) => {
const defaultDurationOnChange = selectors.forms.defaultEventDuration(getState());
const occurStatuses = selectors.vocabs.eventOccurStatuses(getState());
const state = getState();
const defaultDurationOnChange = selectors.forms.defaultEventDuration(state);
const occurStatuses = selectors.vocabs.eventOccurStatuses(state);
const defaultCalendar = selectors.events.defaultCalendarValue(state);
const defaultPlace = selectors.general.defaultPlaceList(state);
const unplannedStatus = getItemInArrayById(occurStatuses, 'eocstat:eos0', 'qcode') || {
label: 'Unplanned event',
qcode: 'eocstat:eos0',
name: 'Unplanned event',
};
const eventProfile = selectors.forms.eventProfile(getState());
let newEvent: Partial<IEventItem> = {
...eventUtils.defaultEventValues(occurStatuses, defaultCalendar, defaultPlace),
dates: {
start: moment(plan.planning_date).clone(),
end: moment(plan.planning_date)
Expand Down
10 changes: 9 additions & 1 deletion client/actions/tests/agenda_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ describe('agenda', () => {
{},
{
type: 'planning',
state: 'draft',
item_class: 'plinat:newscoverage',
language: 'en',
languages: ['en'],
flags: {
marked_for_not_publication: false,
overide_auto_assign_to_workflow: false,
},
coverages: [],
event_item: events[0]._id,
planning_date: events[0].dates.start,
slugline: events[0].slugline,
Expand All @@ -345,7 +354,6 @@ describe('agenda', () => {
}],
internal_note: 'internal note',
ednote: 'Editorial note about this Event',
language: undefined,
},
]);

Expand Down
1 change: 1 addition & 0 deletions client/api/combined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function convertCombinedParams(params: ISearchParams): Partial<ISearchAPIParams>
include_associated_planning: params.include_associated_planning,
source: cvsToString(params.source, 'id'),
coverage_user_id: params.coverage_user_id,
priority: arrayToString(params.priority),
};
}

Expand Down
49 changes: 49 additions & 0 deletions client/api/contentProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
IPlanningContentProfile,
IPlanningAPI,
IEventOrPlanningItem,
IPlanningCoverageItem,
IProfileMultilingualDetails,
IProfileSchemaTypeString,
} from '../interfaces';
Expand All @@ -30,11 +31,45 @@ function getAll(): Promise<Array<IPlanningContentProfile>> {
)
.then((response) => {
response._items.forEach(sortProfileGroups);
enablePriorityInSearchProfile(response._items);

return response._items;
});
}

function enablePriorityInSearchProfile(profiles: Array<IPlanningContentProfile>) {
// Hack to enable/disable priority field in search profiles based on the content profiles
// TODO: Remove this hack when we implement a solution for all searchable fields
const profilesById: {[id: string]: IPlanningContentProfile} = profiles.reduce((profileMap, profile) => {
profileMap[profile.name] = profile;

return profileMap;
}, {});
const searchProfile = profilesById.advanced_search.editor;
const priorityEnabled = {
event: profilesById.event.editor.priority?.enabled === true,
planning: profilesById.planning.editor.priority?.enabled === true,
};

const priorityField = {
enabled: true,
index: 5,
group: 'common',
search_enabled: true,
filter_enabled: true,
};

if (priorityEnabled.event) {
searchProfile.event.priority = priorityField;
if (priorityEnabled.planning) {
searchProfile.combined.priority = priorityField;
}
}
if (priorityEnabled.planning) {
searchProfile.planning.priority = priorityField;
}
}

function getProfile(contentType: string): IPlanningContentProfile {
const {getState} = planningApi.redux.store;

Expand Down Expand Up @@ -192,9 +227,23 @@ function updateProfilesInStore(): Promise<void> {
});
}

function getDefaultValues(profile: IPlanningContentProfile): DeepPartial<IEventOrPlanningItem | IPlanningCoverageItem> {
return Object.keys(profile?.schema ?? {}).reduce(
(defaults, field) => {
if (profile.schema[field]?.default_value != null) {
defaults[field] = profile.schema[field].default_value;
}

return defaults;
},
{}
);
}

export const contentProfiles: IPlanningAPI['contentProfiles'] = {
getAll: getAll,
get: getProfile,
getDefaultValues: getDefaultValues,
patch: patch,
showManagePlanningProfileModal: showManagePlanningProfileModal,
showManageEventProfileModal: showManageEventProfileModal,
Expand Down
3 changes: 2 additions & 1 deletion client/api/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {IRestApiResponse} from 'superdesk-api';
import {planningApi, superdeskApi} from '../superdeskApi';
import {EVENTS, TEMP_ID_PREFIX} from '../constants';

import {convertCommonParams, cvsToString, searchRaw, searchRawGetAll} from './search';
import {arrayToString, convertCommonParams, cvsToString, searchRaw, searchRawGetAll} from './search';
import {eventUtils, planningUtils} from '../utils';
import {eventProfile, eventSearchProfile} from '../selectors/forms';
import * as actions from '../actions';
Expand All @@ -23,6 +23,7 @@ function convertEventParams(params: ISearchParams): Partial<ISearchAPIParams> {
location: params.location?.qcode,
calendars: cvsToString(params.calendars),
no_calendar_assigned: params.no_calendar_assigned,
priority: arrayToString(params.priority),
};
}

Expand Down
3 changes: 2 additions & 1 deletion client/api/planning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function convertPlanningParams(params: ISearchParams): Partial<ISearchAPIParams>
g2_content_type: params.g2_content_type?.qcode,
source: cvsToString(params.source, 'id'),
coverage_user_id: params.coverage_user_id,
coverage_assignment_status: params.coverage_assignment_status
coverage_assignment_status: params.coverage_assignment_status,
priority: arrayToString(params.priority),
};
}

Expand Down
4 changes: 3 additions & 1 deletion client/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {ISearchAPIParams, ISearchParams} from '../interfaces';
import {superdeskApi} from '../superdeskApi';
import {IRestApiResponse} from 'superdesk-api';
import {getDateTimeElasticFormat, getTimeZoneOffset} from '../utils';
import {default as timeUtils} from '../utils/time';


export function cvsToString(items?: Array<{[key: string]: any}>, field: string = 'qcode'): string {
Expand All @@ -11,7 +12,7 @@ export function cvsToString(items?: Array<{[key: string]: any}>, field: string =
);
}

export function arrayToString(items?: Array<string>): string {
export function arrayToString(items?: Array<string | number>): string {
return (items ?? [])
.join(',');
}
Expand Down Expand Up @@ -48,6 +49,7 @@ export function convertCommonParams(params: ISearchParams): Partial<ISearchAPIPa
sort_order: params.sort_order,
sort_field: params.sort_field,
tz_offset: params.date_filter ? getTimeZoneOffset() : null,
time_zone: timeUtils.localTimeZone(),
};
}

Expand Down
4 changes: 4 additions & 0 deletions client/components/AdvancedSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ export class AdvancedSearch extends React.PureComponent<IProps> {
location: {
disableAddLocation: false,
},
priority: {
multiple: true,
defaultValue: [],
},
},
null,
this.props.enabledField
Expand Down
2 changes: 2 additions & 0 deletions client/components/ContentProfiles/FieldTab/FieldEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class FieldEditor extends React.Component<IProps, IState> {
!['language', 'location'].includes(this.props.item.name)
)
)},
'schema.default_value': {enabled: this.props.item.name === 'priority'},
};
const noOptionsAvailable = !(
Object.values(fieldProps)
Expand Down Expand Up @@ -189,6 +190,7 @@ export class FieldEditor extends React.Component<IProps, IState> {
'schema.languages': {enabled: true, index: 12},
'schema.default_language': {enabled: true, index: 13},
'schema.planning_auto_publish': {enabled: true, index: 14},
'schema.default_value': {enabled: true, index: 11},
},
{
item: this.props.item,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ export class CoverageFormComponent extends React.Component<IProps, IState> {
this.props.value.planning?.g2_content_type === 'text'
),
},
priority: {field: 'planning.priority'},
};

const profile = editor.item.planning.getCoverageFields();
Expand Down
5 changes: 2 additions & 3 deletions client/components/Events/EventDateTime.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import moment from 'moment';

import {superdeskApi} from '../../superdeskApi';
import {IEventItem} from '../../interfaces';
Expand All @@ -20,8 +19,8 @@ export class EventDateTime extends React.PureComponent<IProps> {
render() {
const {gettext} = superdeskApi.localization;
const {item, ignoreAllDay, displayLocalTimezone} = this.props;
const start = moment(item.dates.start);
const end = moment(item.dates.end);
const start = eventUtils.getStartDate(item);
const end = eventUtils.getEndDate(item);
const isAllDay = eventUtils.isEventAllDay(start, end);
const multiDay = !eventUtils.isEventSameDay(start, end);
const isRemoteTimeZone = timeUtils.isEventInDifferentTimeZone(item);
Expand Down
3 changes: 2 additions & 1 deletion client/components/Events/EventScheduleSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
forUpdating = false,
useEventTimezone = false
}: IProps) => {
if (!event)
if (!event) {
return null;
}

const eventSchedule: IEventItem['dates'] = get(event, 'dates', {});
const doesRepeat = get(eventSchedule, 'recurring_rule', null) !== null;
Expand Down Expand Up @@ -68,7 +69,7 @@
remoteDateText = datesToShowRemote;
currentDateLabel = gettext('Current Date');
if (useEventTimezone && isRemoteTimeZone) {
currentDateText = newDateString.replace(/[\(\)]/g, '');

Check warning on line 72 in client/components/Events/EventScheduleSummary/index.tsx

View workflow job for this annotation

GitHub Actions / client (14.x)

Unnecessary escape character: \(
remoteDateText = `(${eventDateText})`;
currentDateLabel = gettext('Current Date (Based on Event timezone)');
}
Expand Down
27 changes: 27 additions & 0 deletions client/components/fields/editor/ProfileFieldDefaultValue.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react';

import {IEditorFieldProps, IProfileFieldEntry} from '../../../interfaces';

import {renderFieldsForPanel} from '../index';

interface IProps extends IEditorFieldProps {
item: IProfileFieldEntry;
onChange(field: string, value: string | number): void;
}

export function ProfileFieldDefaultValue({item, onChange, ...props}: IProps) {
return renderFieldsForPanel(
'editor',
{[item.name]: {enabled: true, index: 1}},
{
item: item,
onChange: onChange,
},
{
[item.name]: {
...props,
field: 'schema.default_value',
},
}
);
}
Loading
Loading