-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Feat/1187 cloud bus refresh #3947
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4157b90
WIP spring cloud bus-refresh
ulischulte 5146dcb
WIP spring cloud bus-refresh
ulischulte c8a7662
WIP spring cloud bus-refresh
ulischulte 1f9264f
spring cloud bus-refresh: removed unused slots and data
ulischulte 4b8be73
revert mockServiceWorker
ulischulte 71208a6
Spring Cloud Bus refresh error handling
ulischulte 01f620c
Spring Cloud Bus refresh error handling
ulischulte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
spring-boot-admin-server-ui/src/main/frontend/views/instances/env/busrefresh.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { screen } from '@testing-library/vue'; | ||
| import { HttpResponse, http } from 'msw'; | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { server } from '@/mocks/server'; | ||
| import Instance from '@/services/instance'; | ||
| import { render } from '@/test-utils'; | ||
| import Busrefresh from '@/views/instances/env/busrefresh.vue'; | ||
|
|
||
| describe('Busrefresh', () => { | ||
| const busRefreshInstanceContextMock = vi.fn(); | ||
| let emitted; | ||
|
|
||
| function createInstance() { | ||
| const instance = new Instance({ id: 1233 }); | ||
| instance.busRefreshContext = busRefreshInstanceContextMock; | ||
| return instance; | ||
| } | ||
|
|
||
| beforeEach(async () => { | ||
| server.use( | ||
| http.post('/instances/:instanceId/actuator/busrefresh', () => { | ||
| return HttpResponse.json({}); | ||
| }), | ||
| ); | ||
| const vm = render(Busrefresh, { | ||
| props: { | ||
| instance: createInstance(), | ||
| }, | ||
| }); | ||
| emitted = vm.emitted; | ||
| }); | ||
|
|
||
| it('should trigger busrefresh on confirm', async () => { | ||
| busRefreshInstanceContextMock.mockResolvedValue({}); | ||
| const busRefreshButton = await screen.findByText( | ||
| 'instances.env.bus_refresh', | ||
| ); | ||
| await userEvent.click(busRefreshButton); | ||
|
|
||
| const confirmButton = await screen.findByText('Confirm'); | ||
| await userEvent.click(confirmButton); | ||
|
|
||
| expect(emitted().refresh[0][0]).toBe(true); | ||
| }); | ||
|
|
||
| it('should handle busrefresh failure gracefully', async () => { | ||
| busRefreshInstanceContextMock.mockRejectedValueOnce(new Error()); | ||
|
|
||
| const busRefreshButton = await screen.findByText( | ||
| 'instances.env.bus_refresh', | ||
| ); | ||
| await userEvent.click(busRefreshButton); | ||
|
|
||
| const confirmButton = await screen.findByText('Confirm'); | ||
| await userEvent.click(confirmButton); | ||
|
|
||
| expect(emitted().refresh).toBeUndefined(); | ||
| }); | ||
| }); |
52 changes: 52 additions & 0 deletions
52
spring-boot-admin-server-ui/src/main/frontend/views/instances/env/busrefresh.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <template> | ||
| <sba-confirm-button | ||
| :title="$t('instances.env.bus_refresh_title')" | ||
| class="inline-flex focus:z-10" | ||
| @click="refreshInstance" | ||
| > | ||
| <span v-text="t('instances.env.bus_refresh')" /> | ||
| </sba-confirm-button> | ||
| </template> | ||
|
|
||
| <script lang="ts"> | ||
| import { useNotificationCenter } from '@stekoe/vue-toast-notificationcenter'; | ||
| import { useI18n } from 'vue-i18n'; | ||
|
|
||
| import SbaConfirmButton from '@/components/sba-confirm-button.vue'; | ||
|
|
||
| import Instance from '@/services/instance'; | ||
|
|
||
| const notificationCenter = useNotificationCenter({}); | ||
|
|
||
| export default { | ||
| components: { SbaConfirmButton }, | ||
| props: { | ||
| instance: { | ||
| type: Instance, | ||
| required: true, | ||
| }, | ||
| }, | ||
| emits: ['refresh'], | ||
| setup() { | ||
| const i18n = useI18n(); | ||
| return { | ||
| t: i18n.t, | ||
| }; | ||
| }, | ||
| methods: { | ||
| async refreshInstance() { | ||
| this.instance | ||
| .busRefreshContext() | ||
| .then(() => { | ||
| notificationCenter.success( | ||
| this.t('instances.env.bus_refresh_success'), | ||
| ); | ||
| this.$emit('refresh', true); | ||
| }) | ||
| .catch(() => { | ||
| notificationCenter.error(this.t('instances.env.bus_refresh_failure')); | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.