-
-
Notifications
You must be signed in to change notification settings - Fork 300
Issue#5123 : Migrated the offline alert bar in Settings from Vuetify to Kolibri Design System. #5162
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
Issue#5123 : Migrated the offline alert bar in Settings from Vuetify to Kolibri Design System. #5162
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b54f9a1
feat: create StudioOfflineAlert component using Kolibri Design System
AadarshM07 3c41aba
Refactor(settings): migrate offline alert-bar from vuetify to KDS
AadarshM07 06493c1
style(settings): adjust top margin to ensure no gap for StudioOffline…
AadarshM07 7a054fc
fix(StudioOfflineAlert) : adjust z-index for proper layering
AadarshM07 cc33af2
refactor: remove unused code and prevent icon resizing
AadarshM07 6098d24
test: add unit tests for StudioOfflineAlert
AadarshM07 22e3d73
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 8106787
style(StudioOfflineAlert): adjust right margin
AadarshM07 3017375
style(StudioOfflineAlert): adjust left margin
AadarshM07 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
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
90 changes: 90 additions & 0 deletions
90
contentcuration/contentcuration/frontend/shared/views/StudioOfflineAlert.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,90 @@ | ||
| <template> | ||
|
|
||
| <KTransition kind="component-vertical-slide-out-in"> | ||
| <div | ||
| v-if="offline && !libraryMode" | ||
| class="studio-offline-alert" | ||
| :style="computedstyle" | ||
| data-test="studio-offline-alert" | ||
MisRob marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| > | ||
| <KIcon | ||
| icon="disconnected" | ||
| class="kicon-style" | ||
| /> | ||
| <span>{{ $tr('offlineText') }}</span> | ||
| </div> | ||
| </KTransition> | ||
|
|
||
| </template> | ||
|
|
||
|
|
||
| <script> | ||
|
|
||
| import { mapState } from 'vuex'; | ||
| import useKLiveRegion from 'kolibri-design-system/lib/composables/useKLiveRegion'; | ||
|
|
||
| export default { | ||
| name: 'StudioOfflineAlert', | ||
| setup() { | ||
| const { sendPoliteMessage } = useKLiveRegion(); | ||
| return { sendPoliteMessage }; | ||
| }, | ||
| props: { | ||
| offset: { | ||
| type: Number, | ||
| default: 0, | ||
| }, | ||
| }, | ||
| computed: { | ||
| ...mapState({ | ||
| offline: state => !state.connection.online, | ||
| }), | ||
| libraryMode() { | ||
| return window.libraryMode; | ||
| }, | ||
| computedstyle() { | ||
| return { | ||
| position: 'fixed', | ||
| top: `${this.offset}px`, | ||
| left: '0', | ||
| right: '0', | ||
| backgroundColor: this.$themeTokens.surface, | ||
| zIndex: 16, | ||
| }; | ||
| }, | ||
| }, | ||
| watch: { | ||
| offline(newVal) { | ||
| if (newVal) { | ||
| this.sendPoliteMessage(this.$tr('offlineText')); | ||
| } else { | ||
| this.sendPoliteMessage(this.$tr('onlineText')); | ||
| } | ||
| }, | ||
| }, | ||
| $trs: { | ||
| offlineText: | ||
| 'You seem to be offline. Your changes will be saved once your connection is back.', | ||
| onlineText: 'You are back online.', | ||
| }, | ||
| }; | ||
|
|
||
| </script> | ||
|
|
||
|
|
||
| <style scoped> | ||
|
|
||
| .studio-offline-alert { | ||
| display: flex; | ||
| width: 100%; | ||
| padding: 12px; | ||
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | ||
| } | ||
|
|
||
| .kicon-style { | ||
| flex-shrink: 0; | ||
| margin-right: 14px; | ||
| margin-left: 10px; | ||
| } | ||
|
|
||
| </style> | ||
40 changes: 40 additions & 0 deletions
40
contentcuration/contentcuration/frontend/shared/views/__tests__/StudioOfflineAlert.spec.js
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,40 @@ | ||
| import { mount } from '@vue/test-utils'; | ||
| import StudioOfflineAlert from '../StudioOfflineAlert.vue'; | ||
| import storeFactory from 'shared/vuex/baseStore'; | ||
|
|
||
| function makeWrapper() { | ||
| const store = storeFactory(); | ||
| return { | ||
| wrapper: mount(StudioOfflineAlert, { | ||
| store, | ||
| }), | ||
| store, | ||
| }; | ||
| } | ||
|
|
||
| describe('StudioOfflineAlert', () => { | ||
| let wrapper, store; | ||
|
|
||
| beforeEach(() => { | ||
| const setup = makeWrapper(); | ||
| wrapper = setup.wrapper; | ||
| store = setup.store; | ||
| }); | ||
|
|
||
| it('displays alert component when offline', async () => { | ||
| store.state.connection.online = false; | ||
| await wrapper.vm.$nextTick(); | ||
|
|
||
| expect(wrapper.find('[data-test="studio-offline-alert"]').exists()).toBe(true); | ||
| expect(wrapper.text()).toMatch( | ||
| 'You seem to be offline. Your changes will be saved once your connection is back', | ||
| ); | ||
| }); | ||
|
|
||
| it('hides alert component when online', async () => { | ||
| store.state.connection.online = true; | ||
| await wrapper.vm.$nextTick(); | ||
|
|
||
| expect(wrapper.find('[data-test="studio-offline-alert"]').exists()).toBe(false); | ||
| }); | ||
| }); |
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.