Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,18 @@
</VContainer>
</VWindowItem>
</VWindow>
<MessageDialog
v-model="showUnsavedDialog"
:header="$tr('unsavedChangesHeader')"
:text="$tr('unsavedChangesText')"
<KModal
v-if="showUnsavedDialog"
:title="$tr('unsavedChangesHeader')"
:submitText="$tr('saveButton')"
:cancelText="$tr('closeButton')"
data-test="dialog-unsaved"
:data-test-visible="showUnsavedDialog"
@submit="save"
@cancel="confirmCancel"
>
<template #buttons>
<VSpacer />
<VBtn
flat
@click="confirmCancel"
>
{{ $tr('closeButton') }}
</VBtn>
<VBtn
color="primary"
@click="save"
>
{{ $tr('saveButton') }}
</VBtn>
</template>
</MessageDialog>
{{ $tr('unsavedChangesText') }}
</KModal>
<template #bottom>
<div class="mx-4 subheading">
{{ $tr('channelSelectedCountText', { channelCount: channels.length }) }}
Expand Down Expand Up @@ -210,13 +199,13 @@
import { set } from 'vue';
import { mapGetters, mapActions } from 'vuex';
import difference from 'lodash/difference';
import KModal from 'kolibri-design-system/lib/KModal';
Copy link
Member

Choose a reason for hiding this comment

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

We don't have to import KModal from KDS, this line can be removed :)

import { RouteNames } from '../../constants';
import ChannelItem from './ChannelItem';
import ChannelSelectionList from './ChannelSelectionList';
import { ChannelListTypes, ErrorTypes } from 'shared/constants';
import { constantsTranslationMixin, routerMixin } from 'shared/mixins';
import CopyToken from 'shared/views/CopyToken';
import MessageDialog from 'shared/views/MessageDialog';
import FullscreenModal from 'shared/views/FullscreenModal';
import Tabs from 'shared/views/Tabs';
import LoadingText from 'shared/views/LoadingText';
Expand All @@ -226,9 +215,9 @@
components: {
CopyToken,
ChannelSelectionList,
MessageDialog,
ChannelItem,
FullscreenModal,
KModal,
Copy link
Member

Choose a reason for hiding this comment

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

Likewise, this line should be removed, we don't need to insert KModal as a child component.

Tabs,
LoadingText,
},
Expand Down Expand Up @@ -433,6 +422,7 @@
}
},
confirmCancel() {
this.showUnsavedDialog = false;
Copy link
Member

Choose a reason for hiding this comment

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

showUnsavedDialog is set to false within this.close(), which is called in this function already, so we don't need this line added here.

if (this.isNew) {
if (this.channelSet && this.channelSet.id) {
return this.deleteChannelSet(this.channelSet).then(this.close);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ describe('ChannelSetModal', () => {
});

it('should prompt user if there are unsaved changes', async () => {
expect(getUnsavedDialog(wrapper).attributes('data-test-visible')).toBeFalsy();
expect(getUnsavedDialog(wrapper).exists()).toBeFalsy();

await getCollectionNameInput(wrapper).setValue('My collection');
await getCloseButton(wrapper).trigger('click');

expect(getUnsavedDialog(wrapper).attributes('data-test-visible')).toBeTruthy();
expect(getUnsavedDialog(wrapper).exists()).toBeTruthy();
});
});

Expand Down