Skip to content

Commit 22ce2ea

Browse files
migrate Select channels list layout/input from Vuetify to KDS (#5774)
1 parent 502b5ce commit 22ce2ea

2 files changed

Lines changed: 75 additions & 32 deletions

File tree

contentcuration/contentcuration/frontend/channelList/views/ChannelSet/ChannelSelectionList.vue

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
<template>
22

3-
<VContainer
4-
fluid
5-
class="pa-0 pb-5"
6-
>
7-
<LoadingText
8-
v-if="loading"
9-
class="pt-4"
3+
<div class="selection-list">
4+
<StudioLargeLoader
5+
v-if="show(loaderKey, loading, 400)"
6+
class="selection-loader"
107
/>
118
<template v-else>
12-
<VTextField
9+
<KTextbox
1310
v-model="search"
14-
style="max-width: 350px"
15-
class="mt-4"
16-
box
11+
class="search-input"
1712
:label="$tr('searchText')"
1813
/>
1914
<p
2015
v-if="!listChannels.length"
21-
class="grey--text mb-0 mt-4"
16+
class="grey--text no-channels-found"
2217
>
2318
{{ $tr('noChannelsFound') }}
2419
</p>
@@ -28,41 +23,37 @@
2823
:key="channel.id"
2924
flat
3025
hover
31-
class="list-card-hover px-3"
26+
class="list-card-hover selection-card"
3227
>
33-
<VLayout
34-
align-center
35-
row
36-
>
37-
<Checkbox
38-
v-model="selectedChannels"
39-
color="primary"
28+
<div class="selection-row">
29+
<KCheckbox
30+
:checked="selectedChannels.includes(channel.id)"
4031
:data-testid="`checkbox-${channel.id}`"
41-
:value="channel.id"
42-
class="channel ma-0"
32+
class="channel-checkbox"
33+
@change="handleSelectChannel(channel.id)"
4334
/>
4435
<ChannelItem
4536
:channelId="channel.id"
4637
:data-testid="`channel-item-${channel.id}`"
4738
@click="handleSelectChannel"
4839
/>
49-
</VLayout>
40+
</div>
5041
</VCard>
5142
</template>
5243
</template>
53-
</VContainer>
44+
</div>
5445

5546
</template>
5647

5748

5849
<script>
5950
6051
import sortBy from 'lodash/sortBy';
52+
import useKShow from 'kolibri-design-system/lib/composables/useKShow';
6153
import { mapGetters, mapActions } from 'vuex';
6254
import ChannelItem from './ChannelItem';
6355
import { ChannelListTypes } from 'shared/constants';
64-
import Checkbox from 'shared/views/form/Checkbox';
65-
import LoadingText from 'shared/views/LoadingText';
56+
import StudioLargeLoader from 'shared/views/StudioLargeLoader';
6657
6758
function listTypeValidator(value) {
6859
// The value must match one of the ListTypes
@@ -72,9 +63,12 @@
7263
export default {
7364
name: 'ChannelSelectionList',
7465
components: {
75-
Checkbox,
7666
ChannelItem,
77-
LoadingText,
67+
StudioLargeLoader,
68+
},
69+
setup() {
70+
const { show } = useKShow();
71+
return { show };
7872
},
7973
props: {
8074
value: {
@@ -117,6 +111,9 @@
117111
'name',
118112
);
119113
},
114+
loaderKey() {
115+
return `channel-selection-list-${this.listType}`;
116+
},
120117
},
121118
mounted() {
122119
this.loading = true;
@@ -146,12 +143,36 @@
146143

147144
<style lang="scss" scoped>
148145
149-
.add-channel-button {
150-
margin: 0;
146+
.selection-list {
147+
padding-bottom: 20px;
148+
}
149+
150+
.selection-loader {
151+
padding-top: 16px;
152+
}
153+
154+
.search-input {
155+
max-width: 350px;
156+
margin-top: 16px;
151157
}
152158
153-
.channel /deep/ .k-checkbox {
154-
vertical-align: middle;
159+
.no-channels-found {
160+
margin-top: 16px;
161+
margin-bottom: 0;
162+
}
163+
164+
.selection-card {
165+
padding-inline: 12px;
166+
}
167+
168+
.selection-row {
169+
display: flex;
170+
align-items: center;
171+
}
172+
173+
.channel-checkbox {
174+
margin: 0;
175+
padding-inline-end: 4px;
155176
}
156177
157178
.list-card-hover {

contentcuration/contentcuration/frontend/channelList/views/ChannelSet/__tests__/channelSelectionList.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import { Store } from 'vuex';
55
import ChannelSelectionList from '../ChannelSelectionList';
66
import { ChannelListTypes } from 'shared/constants';
77

8+
jest.mock('kolibri-design-system/lib/composables/useKShow', () => ({
9+
__esModule: true,
10+
default: () => ({
11+
show: (_id, loading) => loading,
12+
}),
13+
}));
14+
815
const searchWord = 'search test';
916

1017
const editChannel = {
@@ -84,6 +91,21 @@ describe('ChannelSelectionList', () => {
8491
expect(screen.queryByText(publicChannel.name)).not.toBeInTheDocument();
8592
});
8693

94+
it('shows loader while the channel list is loading', async () => {
95+
let resolveLoad;
96+
const loadingPromise = new Promise(resolve => {
97+
resolveLoad = resolve;
98+
});
99+
mockActions.loadChannelList.mockReturnValueOnce(loadingPromise);
100+
101+
await renderComponent();
102+
103+
expect(screen.getByTestId('loader')).toBeInTheDocument();
104+
105+
resolveLoad();
106+
expect(await screen.findByLabelText('Search for a channel')).toBeInTheDocument();
107+
});
108+
87109
it('filters the channel list when the user types in the search box', async () => {
88110
const user = userEvent.setup();
89111
await renderComponent();

0 commit comments

Comments
 (0)