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

Fulfil assignment #1848

Merged
merged 32 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
998cff9
adjust API
tomaskikutis Apr 20, 2023
209db09
update gettext usage
tomaskikutis Apr 20, 2023
def1a61
Fix event template (#1812)
thecalcc Jun 14, 2023
629c2e8
Fix show modal (#1814)
thecalcc Jun 14, 2023
46387f7
UIF version update (#1818)
thecalcc Jun 28, 2023
a9fe557
[email protected]
tomaskikutis Jul 27, 2023
63b3795
Fulfil assignment
thecalcc Aug 31, 2023
3b4db41
Sync extension bridge
thecalcc Aug 31, 2023
d309048
Fix lint
thecalcc Sep 14, 2023
6ee85a5
Merge remote-tracking branch 'origin/develop' into authoring-react-po…
petrjasek Oct 31, 2023
400ef62
fix lint
petrjasek Oct 31, 2023
9a8ec9e
fix e2e client build
petrjasek Oct 31, 2023
25ff5e5
Fix ng import
thecalcc Nov 6, 2023
8c7e9ad
Merge branch 'authoring-react-post-broadcasting' into fulfil-assignment
thecalcc Nov 6, 2023
7cc6b74
Fix CI
thecalcc Nov 6, 2023
e768699
Merge branch 'develop' into fulfil-assignment
thecalcc Aug 30, 2024
1bdb1bd
Fix lint
thecalcc Aug 30, 2024
cd6150c
Update client-core
thecalcc Sep 11, 2024
1804301
Update e2e client-core
thecalcc Sep 12, 2024
2bb3a63
Update artifact version
thecalcc Sep 12, 2024
ecc568e
Fix type
thecalcc Sep 12, 2024
e7e5715
Merge branch 'develop' into fulfil-assignment
thecalcc Sep 12, 2024
adaa48b
Merge branch 'develop' into fulfil-assignment
thecalcc Sep 16, 2024
dfc8cfb
Fix lint
thecalcc Sep 16, 2024
93da8b6
Merge branch 'develop' into fulfil-assignment
thecalcc Sep 18, 2024
950608f
Small changes
thecalcc Sep 18, 2024
ce435ba
Fix import
thecalcc Sep 18, 2024
7e4b490
Code cleanup
thecalcc Sep 19, 2024
59b038e
Get latest article, fix conditions, fix initialization of action
thecalcc Sep 26, 2024
3193af5
Fix lint
thecalcc Sep 27, 2024
1dca13f
Update client-core
thecalcc Sep 30, 2024
652b26a
Add notification
thecalcc Oct 9, 2024
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
5 changes: 4 additions & 1 deletion client/extension_bridge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import {IVocabularyItem} from 'superdesk-api';
import {IArticle, IVocabularyItem} from 'superdesk-api';

import {getAssignmentTypeInfo} from './utils/assignments';
import {SluglineComponent} from './components/Assignments/AssignmentItem/fields/Slugline';
Expand All @@ -10,6 +10,7 @@ import {EditorFieldVocabulary, IEditorFieldVocabularyProps} from './components/f

import {getVocabularyItemFieldTranslated} from './utils/vocabularies';
import {getUserInterfaceLanguageFromCV} from './utils/users';
import {isContentLinkToCoverageAllowed} from 'utils/archive';

import {registerEditorField} from './components/fields/resources/registerEditorFields';
import {IAssignmentItem, IEditorFieldProps, IPlanningAppState} from 'interfaces';
Expand All @@ -18,6 +19,7 @@ import {IAssignmentItem, IEditorFieldProps, IPlanningAppState} from 'interfaces'
interface IExtensionBridge {
assignments: {
utils: {
isContentLinkToCoverageAllowed(item: IArticle): boolean;
getAssignmentTypeInfo(
assignment: IAssignmentItem,
contentTypes: Array<IVocabularyItem>,
Expand Down Expand Up @@ -68,6 +70,7 @@ export const extensionBridge: IExtensionBridge = {
assignments: {
utils: {
getAssignmentTypeInfo,
isContentLinkToCoverageAllowed,
},
components: {
SluglineComponent,
Expand Down
28 changes: 26 additions & 2 deletions client/planning-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {IPlanningExtensionConfigurationOptions} from './extension_configuration_
import {AutopostIngestRuleEditor} from './ingest_rule_autopost/AutopostIngestRuleEditor';
import {AutopostIngestRulePreview} from './ingest_rule_autopost/AutopostIngestRulePreview';
import {extensionBridge} from './extension_bridge';
const {isContentLinkToCoverageAllowed} = extensionBridge.assignments.utils;

function onSpike(superdesk: ISuperdesk, item: IArticle) {
const {gettext} = superdesk.localization;
Expand Down Expand Up @@ -108,6 +109,7 @@ const extension: IExtension = {
const displayTopbarWidget = superdesk.privileges.hasPrivilege('planning_assignments_view')
&& extensionConfig?.assignmentsTopBarWidget === true;
const {gettext} = superdesk.localization;
const planningActionsGroupId = 'planning-actions';

const result: IExtensionActivationResult = {
contributions: {
Expand All @@ -116,12 +118,12 @@ const extension: IExtension = {
getActions: (item) => [
{
label: gettext('Unlink as Coverage'),
groupId: 'planning-actions',
groupId: planningActionsGroupId,
icon: 'cut',
onTrigger: () => {
const superdeskArticle = superdesk.entities.article;

// keep in sync with client/planning-extension/src/extension.ts:123
// keep in sync with index.ts:108
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better keep relative path. There are lots of index files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean the absolute it would be something like superdesk-planning/index.ts

If relative, then this is it, and coincidentally index.ts really is the path & file name, relative to the project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant relative to the project. You get it by right clicking open file tab and choosing "copy relative path"

if (
superdesk.privileges.hasPrivilege('archive') &&
item.assignment_id != null &&
Expand All @@ -135,6 +137,28 @@ const extension: IExtension = {
) {
const event = new CustomEvent('planning:unlinkfromcoverage', {detail: {item}});

window.dispatchEvent(event);
}
},
},
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether this would appear in authoring-angular as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're asking wether there would be a conflict thus two of the same actions rendering because of being registered in two places yes. I plan to address this in another PR, together with the external-app thingy, as this is something that affects all actions so we need a generic solution.

I think doing a simple collision detection mechanism would suffice for now. If we have an action with the same id coming from extensions as well, we don't push it to the e.g. allActions array. We skip that one, while prioritising existing ones. In react we don't show the angular registered ones, so this should be enough to ignore the react side for now. Later when we remove the angular implementation we will remove the filtering

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extensions API have access to authoringReactViewEnabled variable. What about using it to conditionally push the action?

Alternativelly, what about if we dropped the old action and kept only the new one? I did that with planning details widget - dropped the angular version of a widget - and the react one works in both - angular and react based authoring.

label: superdesk.localization.gettext('Fulfil assignment'),
groupId: planningActionsGroupId,
icon: 'calendar-list',
onTrigger: () => {
const itemStates = ['killed', 'recalled', 'unpublished', 'spiked', 'correction'];

// keep in sync with index.ts:79
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link relative path

if (
!item.assignment_id &&
isContentLinkToCoverageAllowed(item) &&
!superdesk.entities.article.isPersonal(item) &&
superdesk.privileges.hasPrivilege('archive') &&
!superdesk.entities.article.isLockedInOtherSession(item) &&
!itemStates.includes(item.state)
) {
const event = new CustomEvent('planning:fulfilassignment', {detail: item});

window.dispatchEvent(event);
}
},
Expand Down
2 changes: 2 additions & 0 deletions client/planning-extension/src/extension_bridge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import {IVocabularyItem} from 'superdesk-api';
import {IAssignmentItem, IEditorFieldProps, IPlanningAppState} from '../../interfaces';
import {IArticle} from 'superdesk-api';

interface IEditorFieldVocabularyProps extends IEditorFieldProps {
options: Array<any>;
Expand All @@ -16,6 +17,7 @@ interface IEditorFieldVocabularyProps extends IEditorFieldProps {
interface IExtensionBridge {
assignments: {
utils: {
isContentLinkToCoverageAllowed(item: IArticle): boolean;
getAssignmentTypeInfo(
assignment: IAssignmentItem,
contentTypes: Array<IVocabularyItem>,
Expand Down
29 changes: 29 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,35 @@ function configurePlanning(superdesk) {
});
}

window.addEventListener('planning:fulfilassignment', (event: CustomEvent) => {
const element = window.$(document.createElement('div'));
const localScope = ng.get('$rootScope').$new(true);
const handleDestroy = () => {
localScope.$broadcast('$destroy');
element[0].remove();
};

localScope.resolve = handleDestroy;
localScope.reject = handleDestroy;
localScope.locals = {data: {item: event.detail}};

new ctrl.FulFilAssignmentController(
element,
localScope,
ng.get('sdPlanningStore'),
ng.get('notify'),
ng.get('gettext'),
ng.get('lock'),
ng.get('session'),
ng.get('userList'),
ng.get('api'),
ng.get('$timeout'),
ng.get('superdeskFlags'),
ng.get('desks')
);
});


window.addEventListener('planning:unlinkfromcoverage', (event: CustomEvent) => {
ctrl.UnlinkAssignmentController(
event.detail,
Expand Down
Loading