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

Refactored Action Filters #261

Merged
merged 8 commits into from Nov 15, 2016
Merged

Refactored Action Filters #261

merged 8 commits into from Nov 15, 2016

Conversation

exyi
Copy link
Member

@exyi exyi commented Nov 5, 2016

  • ActionFilterAttribute is splitted into interfaces - request filter, viewModel filter and command filter
  • Now they also work when applied to IDotvvmPresenter and global request filters are applied to requests to any presenter not only the default one

Review it please.

* ActionFilterAttribute is splitted into interfaces - request filter, viewModel filter and command filter
* Now they also work when applied to IDotvvmPresenter and global request filters are applied to requests to any presenter not only the default one
{
foreach (var f in filters)
{
await f.OnPageExceptionAsync(context, exception);
Copy link
Contributor

Choose a reason for hiding this comment

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

The method is now called also for DotvvmControlException and DotvvmHttpException rethrown in DotvvmPresenter (L66, L221). Is this intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

DotvvmPresenter rethrows only HttpException, DotvvmControlException should be handled like any other. I'll fix it.

foreach (var f in filters)
{
await f.OnPageExceptionAsync(context, exception);
if (context.IsCommandExceptionHandled) context.InterruptRequest();
Copy link
Contributor

@djanosik djanosik Nov 10, 2016

Choose a reason for hiding this comment

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

Shouldn't we check IsPageExceptionHandled instead?

@djanosik
Copy link
Contributor

djanosik commented Nov 10, 2016

I like this PR, but we should probably consider more changes:

  • Rename IRequestActionFilter to IResourceActionFilter and methods to OnResourceLoadingAsync, etc. Custom presenters will not always be used to load pages.
  • Remove ActionFilterAttribute base class from global action filters that are not meant to be used like attributes (eg. AuthorizeFilterAttribute).
  • Update Authorize filters to work on custom presenters (it will fix Authorization filters for custom presenters #216).

@exyi
Copy link
Member Author

exyi commented Nov 10, 2016

@djanosik I have just fixed the little issues you reported, thank you for review.
I would not rename the IRequestActionFilter since it contains filter applied per request. The Page... should also stay as OnPageExceptionAsync was there before and I'd not change it. I also think that everyone will understand what Page means.

@djanosik
Copy link
Contributor

djanosik commented Nov 10, 2016

@exyi I see, it'd be a breaking change. That's unfortunate, the name feels a bit confusing. Couldn't we keep OnPageExceptionAsync on ActionFilterAttribute as Obsolete for some time? Maybe it's not worth it.

@exyi
Copy link
Member Author

exyi commented Nov 10, 2016

@djanosik It is not a solution because it is an interface user will implement :(. And I actually don't think that the name is confusing, there is only better alternative.

@djanosik
Copy link
Contributor

@exyi Ok then. :)

@exyi
Copy link
Member Author

exyi commented Nov 15, 2016

@djanosik Authorize attribute should be working correctly on IDotvvmPresenters.

@tomasherceg tomasherceg merged commit 76ba7f3 into master Nov 15, 2016
@exyi exyi deleted the feature-action-filters branch December 30, 2016 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants