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

Fix : Locked items in package widget cannot be opened [SDESK-6706] #4168

Merged
merged 4 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions scripts/apps/authoring/authoring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ angular.module('superdesk.apps.authoring', [
{action: 'list', type: 'archive'},
{action: 'edit', type: 'item'},
],
additionalCondition: ['authoring', 'item', function(authoring, item) {
return authoring.itemActions(item).edit;
additionalCondition: ['authoring', 'item', async function(authoring, item) {
Copy link
Member

Choose a reason for hiding this comment

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

For one we aren't using async/await in the codebase, so you'd need to rewrite this using promises. On the other hand, itemActions function is synchronous so neither .then nor await can be used.

Copy link
Member

Choose a reason for hiding this comment

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

you should probably step into use a debugger to step into authoringWorkspace.edit on line 213, go to the implementation and do the thing you tried to do in the initial PR version. I'm still not sure actually what's the issue and how you are trying to fix it. Can you comment on that too?

Copy link
Member Author

Choose a reason for hiding this comment

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

When we are trying to edit locked packages inside locked packages then We are not getting response on time from
return authoring.itemActions(item) and because of that error which is not handled by us,and we are not able to reach at
authoringWorkspace.edit(data.item ? data.item : data); so, the main problem is not in this , problem lies in return authoring.itemActions(item).

image (12)

Copy link
Member

Choose a reason for hiding this comment

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

We are not getting response on time

Which line in your opinion is asynchronous? I looked into it and it seems to me that we do get the response, it's simply false - I mean it refused to allow to edit it. I've looked into removing the condition in the first place, but it would likely change behavior somewhere else so I applied a targeted fix in packages.

return await authoring.itemActions(item).edit;
}],
})
.activity('edit.item.popup', {
Expand Down
4 changes: 1 addition & 3 deletions scripts/apps/authoring/packages/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ function PackagesCtrl($scope, superdesk, api, search) {
if (packageItem._type === 'published') {
superdesk.intent('view', 'item', packageItem);
} else {
superdesk.intent('edit', 'item', packageItem).then(null, () => {
superdesk.intent('view', 'item', packageItem);
});
superdesk.intent('edit', 'item', packageItem);
}
};

Expand Down