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

Feature/JA-80 UiMessagesService #66

Merged
merged 17 commits into from
Jun 4, 2024
Merged

Conversation

Zjyslav
Copy link
Collaborator

@Zjyslav Zjyslav commented Apr 21, 2024

I know it's not what we're supposed to be focusing or right now, but I was a little inspired to make a centralized way of showing notifications.

I reduced out notifications to 2 types - Success and Failure. Message text is still added via TempData, but not directly.
To use this system, you inject INotificationService and call ShowSuccessNotification(string message) or ShowFailureNotification(string message) on it.

I also added a static class with public const string fields with names of partials and notification types, so if we want to add a new partial, I suggest we add its name to the PartialNames class and use it in Razor like this: <partial name="@PartialNames.MyPartial">. This way we reduce the number of hardcoded strings and keep them in a single location.

@GrzegorzKmiecinski
Copy link
Collaborator

looks good, I'll approve this once we're done with services

@Zjyslav Zjyslav marked this pull request as draft May 12, 2024 18:03
Zjyslav added 7 commits May 29, 2024 09:27
Except ValidationScriptsPartial
Also added missing calls to show messages and fixed minor issues found in code.
Test - Ads_WhenResponseIsUnsuccessful_ShouldShowFailureMessage
Tests:
- ShowMessage_WhenHttpContextIsNull_ShouldNotThrowException
- ShowMessage_WhenMessageIsNull_ShouldReplaceItWithEmptyString
- ShowMessage_WhenMessageTypeIsNull_ShouldReplaceItWithEmptyString
- ShowMessage_WhenCalled_ShouldCorrectlyAddMessageToTempData
- ShowSuccessMessage_WhenCalled_ShouldAddMessageWithCorrectType
- ShowFailureMessage_WhenCalled_ShouldAddMessageWithCorrectType
@Zjyslav Zjyslav changed the title Feature/JA-80 NotificationService Feature/JA-80 UiMessagesService May 29, 2024
@Zjyslav
Copy link
Collaborator Author

Zjyslav commented May 29, 2024

I changed name of the service to UiMessagesService and changed any use of notification to message in this context. I hope I didn't miss any.

I added some missing messages to be shown, but I didn't touch our Admin Panel controllers.

I added tests for the service and 1 for BrowseController to check if failure message is shown. I suggest we make tests for it in other controllers as well.

@Zjyslav Zjyslav marked this pull request as ready for review May 29, 2024 10:14
Copy link
Collaborator

@GrzegorzKmiecinski GrzegorzKmiecinski left a comment

Choose a reason for hiding this comment

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

Looks clean.

@Zjyslav Zjyslav merged commit fc446a8 into develop Jun 4, 2024
1 check passed
@Zjyslav Zjyslav deleted the feature/ja-80-notification-service branch June 4, 2024 18:20
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.

2 participants