Skip to content

V13: Webhook corrections#15077

Merged
Zeegaan merged 21 commits intoumbraco:v13/devfrom
bjarnef:feature/webhook-corrections
Nov 1, 2023
Merged

V13: Webhook corrections#15077
Zeegaan merged 21 commits intoumbraco:v13/devfrom
bjarnef:feature/webhook-corrections

Conversation

@bjarnef
Copy link
Copy Markdown
Contributor

@bjarnef bjarnef commented Oct 31, 2023

Prerequisites

  • I have added steps to test this contribution in the description below

Description

Some corrections for #15050

image

  • Added webhook icon (it need to be a "solid" icon using fill and not stroke/outline). https://www.svgrepo.com/svg/503141/webhook (the icon may be updated in the new backoffice)
  • Localize tree.
  • Datalist with common headers for webhook events.
  • Modified content type picker to not allow folder (entity container) selection - maybe also exclude element types?
  • Promises to load events and webhook in overview and show loading indicator + sync of tree node.
  • Changed buttons to <button> elements.
  • Stop event bubbling when clicking delete button in overview to not open edit overlay at the same time.
  • Removed the globe icon since I didn't think it had any value and not to confuse with languages.
  • Some formatting and cleanup.

Furthermore I think editing webhook shouldn't modify model directly, but only if actually saved and not update in background, e.g. when typing URL or toggle enabled state.

I also noticed when unchecking the selected events, it reset to original selection. Maybe selecting Content or Media events should filter the others, but just disable them?

@bjarnef bjarnef marked this pull request as draft October 31, 2023 15:01
@github-actions
Copy link
Copy Markdown

Hi there @bjarnef, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@bjarnef
Copy link
Copy Markdown
Contributor Author

bjarnef commented Oct 31, 2023

@Zeegaan I have updated a few lots of things.

@bjarnef bjarnef changed the title Feature/webhook corrections Webhook corrections Oct 31, 2023
@bjarnef bjarnef marked this pull request as ready for review October 31, 2023 21:38
@bjarnef bjarnef changed the title Webhook corrections V13: Webhook corrections Oct 31, 2023
@bjarnef
Copy link
Copy Markdown
Contributor Author

bjarnef commented Oct 31, 2023

Similar to content type picker in MNTP configuration, so folder selection is disabled.

function add() {
if (!currentItemType) {
return;
}
var editor = {
multiPicker: true,
filterCssClass: "not-allowed not-published",
filter: function (item) {
// filter out folders (containers), element types (for content) and already selected items
return item.nodeType === "container" || item.metaData.isElement || !!_.findWhere(vm.itemTypes, { udi: item.udi });
},
submit: function (model) {
var newItemTypes = _.map(model.selection,
function(selected) {
return _.findWhere(allItemTypes, { udi: selected.udi });
});
vm.itemTypes = _.uniq(_.union(vm.itemTypes, newItemTypes));
updateModel();
editorService.close();
},
close: function() {
editorService.close();
}
};
switch (currentItemType) {
case "content":
editorService.contentTypePicker(editor);
break;
case "media":
editorService.mediaTypePicker(editor);
break;
case "member":
editorService.memberTypePicker(editor);
break;
}
}

image

Like this PR #15034 regarding contentTypeEditor is would be great if the contentTypePicker handled different entities. The contentTypePicker does however open document types, but we could probably avoid a breaking change either with another parameter or pass in entity type to editor arguments with fallback to documentType, but it would be great if it is consistent with contentTypeEditor.

size="xxs"
label="Details">
</umb-button>
</td>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It had a column too much and there shouldn't be a delete webhook button in log entry :)


function clearContentType(contentTypeKey) {
if (Array.isArray($scope.model.webhook.contentTypeKeys)) {
if (Utilities.isArray($scope.model.webhook.contentTypeKeys)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just for my own knowledge, what is the difference between using Utilities & Array ? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not much, it is just a wrapper we use much elsewhere in codebase and some of the methods have replaced the angular functions.

const isArray = val => Array.isArray(val) || val instanceof Array;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Most of the time there won't be a difference.
Not sure if Array.isArray(val) could return a different result than val instanceof Array

I tried with [], "", null, undefined, NaN .. all returned same result.

case "member":
editorService.memberTypePicker(editor);
break;
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It would be great if we could use this here: #15080

Would it make sense the support webhooks for Member events @Zeegaan ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is in the pipeline for rc-2 (but no promises 😛), so I think it's okay 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At least it never opens member type picker for now and if #15080 gets merged, we can eventually refactor this part, but anyway it should still work 😎

<div class="flx-g0 flx-s0" style="flex-basis: 40px;">
<umb-checkmark checked="true" size="m" style="cursor: default"></umb-checkmark>
<i class="icon-wrong umb-checkmark umb-checkmark--m" style="cursor: default;" ng-if="model.webhookLogEntry.response.isSuccess === false"></i>
<umb-icon icon="icon-wrong" class="umb-checkmark umb-checkmark--m" style="cursor: default;" ng-if="model.webhookLogEntry.response.isSuccess === false"></umb-icon>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't have any logs, but we should use <umb-icon> instead of the <i> element :)

@Zeegaan
Copy link
Copy Markdown
Member

Zeegaan commented Nov 1, 2023

Seems to be a bug with already existing webhooks, when trying to change events, it seems like unselecting the last one i causing issues 🤣
Heres my showing it off:
WierdnessWithAlreadyCreatted

@bjarnef
Copy link
Copy Markdown
Contributor Author

bjarnef commented Nov 1, 2023

Seems to be a bug with already existing webhooks, when trying to change events, it seems like unselecting the last one i causing issues 🤣 Heres my showing it off: WierdnessWithAlreadyCreatted

Yes, that's what I mentioned in the description :)

I also noticed when unchecking the selected events, it reset to original selection. Maybe selecting Content or Media events should filter the others, but just disable them?

@Zeegaan
Copy link
Copy Markdown
Member

Zeegaan commented Nov 1, 2023

Aha totally missed that!
Yes, perhaps the filtering should just disable them I guess 🤷

@bjarnef
Copy link
Copy Markdown
Contributor Author

bjarnef commented Nov 1, 2023

Aha totally missed that! Yes, perhaps the filtering should just disable them I guess 🤷

We can have a look in another PR 👍

@Zeegaan
Copy link
Copy Markdown
Member

Zeegaan commented Nov 1, 2023

Looks good, tests good 🚀

@Zeegaan Zeegaan merged commit 29be27b into umbraco:v13/dev Nov 1, 2023
@bjarnef bjarnef deleted the feature/webhook-corrections branch November 1, 2023 15:56
Zeegaan pushed a commit that referenced this pull request Nov 6, 2023
* Update icons

* Update tree headers

* Cleanup and change icon name

* Use button element instead

* Disable button instead

* Fix overlay title

* Simplify labels

* Add datalist for common headers

* Use Utilties function

* Events in plural form

* Cleanup and formatting

* Formatting

* More formatting

* Stop event bubbling when clicking delete button

* Sync tree node and show loading indicator

* Add webhook icon

* Remove globe icon to not confuse with languages

* Update logs

* Remove extra column with delete button which shouldn't be there

* Use umb-icon and update titles

* Use content type picker

(cherry picked from commit 29be27b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants