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

Unlink as coverage #1847

Merged
merged 22 commits into from
Sep 13, 2024
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
29 changes: 28 additions & 1 deletion client/planning-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,41 @@ function onSendBefore(superdesk: ISuperdesk, items: Array<IArticle>, desk: IDesk
const extension: IExtension = {
activate: (superdesk: ISuperdesk) => {
const extensionConfig: IPlanningExtensionConfigurationOptions = superdesk.getExtensionConfig();

const displayTopbarWidget = superdesk.privileges.hasPrivilege('planning_assignments_view')
&& extensionConfig?.assignmentsTopBarWidget === true;
const {gettext} = superdesk.localization;

const result: IExtensionActivationResult = {
contributions: {
entities: {
article: {
getActions: (item) => [
{
label: gettext('Unlink as Coverage'),
groupId: 'planning-actions',
icon: 'cut',
onTrigger: () => {
const superdeskArticle = superdesk.entities.article;

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

Choose a reason for hiding this comment

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

Did you take these conditions from somewhere else? In order not to duplicate it, we should add canUnlinkAscoverage function and expose it via extensions bridge.

Copy link
Contributor Author

@thecalcc thecalcc Sep 13, 2024

Choose a reason for hiding this comment

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

The thing is, we can't add it 1-to-1, because in the angular world permissions work under the hood, so if we do add it it'll still be chopped up. Personally I don't think it's necessary when this is the case, so we can keep it like this

Copy link
Member

Choose a reason for hiding this comment

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

add the comment about keeping it up to date

superdesk.privileges.hasPrivilege('archive') &&
item.assignment_id != null &&
!superdeskArticle.isPersonal(item) &&
!superdeskArticle.isLockedInOtherSession(item) &&
(
superdeskArticle.itemAction(item).edit ||
superdeskArticle.itemAction(item).correct ||
superdeskArticle.itemAction(item).deschedule
)
) {
const event = new CustomEvent('planning:unlinkfromcoverage', {detail: {item}});

window.dispatchEvent(event);
}
},
}
],
onSpike: (item: IArticle) => onSpike(superdesk, item),
onSpikeMultiple: (items: Array<IArticle>) => onSpikeMultiple(superdesk, items),
onPublish: (item: IArticle) => onPublishArticle(superdesk, item),
Expand Down
16 changes: 15 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import planningModule from './client';
import * as ctrl from './client/controllers';
import {gettext} from './client/utils/gettext';
import {isContentLinkToCoverageAllowed} from './client/utils/archive';

import ng from 'superdesk-core/scripts/core/services/ng';

configurePlanning.$inject = ['superdeskProvider'];
function configurePlanning(superdesk) {
Expand Down Expand Up @@ -103,6 +103,8 @@ function configurePlanning(superdesk) {
!['killed', 'recalled', 'unpublished', 'spiked', 'correction'].includes(item.state);
}],
})

// TAG: AUTHORING-ANGULAR
Copy link
Member

Choose a reason for hiding this comment

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

image

I'm wondering about that external-app action.

image

It looks like the same action also appears in the topbar. Could you double check whether we also have it in authoring-react?

Copy link
Member

Choose a reason for hiding this comment

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

@thecalcc have you looked into this yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm doing so yep, but I plan to address it in a different PR. haven't forgotten about it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm doing so yep, but I plan to address it in a different PR. haven't forgotten about it

In short, looks like this is some filtering based on which we calculate whether to show the action in the three dots menu or not

.activity('planning.unlink', {
label: gettext('Unlink as Coverage'),
icon: 'cut',
Expand All @@ -120,6 +122,8 @@ function configurePlanning(superdesk) {
],
group: gettext('Planning'),
privileges: {archive: 1},

// keep in sync with client/planning-extension/src/extension.ts:126
additionalCondition: ['archiveService', 'item', 'authoring',
function(archiveService, item, authoring) {
return item.assignment_id &&
Expand All @@ -134,5 +138,15 @@ function configurePlanning(superdesk) {
});
}

window.addEventListener('planning:unlinkfromcoverage', (event: CustomEvent) => {
ctrl.UnlinkAssignmentController(
event.detail,
ng.get('notify'),
ng.get('gettext'),
ng.get('api'),
ng.get('lock'),
);
});

export default planningModule
.config(configurePlanning);
Loading
Loading