Skip to content

Commit f5d6f31

Browse files
authored
Merge branch 'unstable' into fix/channel-details-in-channel
2 parents 2e61f90 + 4180024 commit f5d6f31

File tree

33 files changed

+2329
-1309
lines changed

33 files changed

+2329
-1309
lines changed

contentcuration/contentcuration/frontend/accounts/pages/AccountsMain.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<VDivider />
7878
<p class="mt-4 text-xs-center">
7979
<KButton
80-
href="/channels"
80+
href="/channels/#public"
8181
:text="$tr('guestModeLink')"
8282
appearance="basic-link"
8383
/>

contentcuration/contentcuration/frontend/administration/pages/Channels/ChannelActionsDropdown.vue

Lines changed: 73 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,32 @@
11
<template>
22

33
<div>
4-
<ConfirmationDialog
5-
v-model="restoreDialog"
6-
title="Restore channel"
7-
:text="`Are you sure you want to restore ${name} and make it active again?`"
8-
data-test="confirm-restore"
9-
confirmButtonText="Restore"
10-
@confirm="restoreHandler"
11-
/>
4+
<KModal
5+
v-if="activeDialog"
6+
:title="dialogConfig.title"
7+
:submitText="dialogConfig.submitText"
8+
cancelText="Cancel"
9+
data-test="confirm-dialog"
10+
:submitDisabled="dialogConfig.submitDisabled"
11+
@submit="handleSubmit"
12+
@cancel="activeDialog = null"
13+
>
14+
<p>{{ dialogConfig.message }}</p>
15+
<StudioBanner
16+
v-if="dialogConfig.errorMessage"
17+
error
18+
>
19+
{{ dialogConfig.errorMessage }}
20+
</StudioBanner>
21+
</KModal>
1222

13-
<ConfirmationDialog
14-
v-model="makePublicDialog"
15-
title="Make channel public"
16-
:text="`All users will be able to view and import content from ${name}.`"
17-
:error-text="communityChannelErrorMessage"
18-
:disable-submit="isCommunityChannel"
19-
data-test="confirm-public"
20-
confirmButtonText="Make public"
21-
@confirm="makePublicHandler"
22-
/>
23-
<ConfirmationDialog
24-
v-model="makePrivateDialog"
25-
title="Make channel private"
26-
:text="`Only users with view-only or edit permissions will be able to access ${name}.`"
27-
data-test="confirm-private"
28-
confirmButtonText="Make private"
29-
@confirm="makePrivateHandler"
30-
/>
31-
<ConfirmationDialog
32-
v-model="deleteDialog"
33-
title="Permanently delete channel"
34-
:text="`Are you sure you want to permanently delete ${name}? This can not be undone.`"
35-
data-test="confirm-delete"
36-
confirmButtonText="Delete permanently"
37-
@confirm="deleteHandler"
38-
/>
39-
<ConfirmationDialog
40-
v-model="softDeleteDialog"
41-
title="Permanently delete channel"
42-
:text="`Are you sure you want to delete ${name}?`"
43-
data-test="confirm-softdelete"
44-
confirmButtonText="Delete"
45-
@confirm="softDeleteHandler"
46-
/>
4723
<BaseMenu>
4824
<template #activator="{ on }">
4925
<VBtn
5026
v-bind="$attrs"
5127
v-on="on"
5228
>
53-
actions
29+
Actions
5430
<Icon
5531
icon="dropdown"
5632
class="ml-1"
@@ -61,13 +37,13 @@
6137
<template v-if="channel.deleted">
6238
<VListTile
6339
data-test="restore"
64-
@click="restoreDialog = true"
40+
@click="openDialog('restore')"
6541
>
6642
<VListTileTitle>Restore</VListTileTitle>
6743
</VListTile>
6844
<VListTile
6945
data-test="delete"
70-
@click="deleteDialog = true"
46+
@click="openDialog('permanentDelete')"
7147
>
7248
<VListTileTitle>Delete permanently</VListTileTitle>
7349
</VListTile>
@@ -94,21 +70,21 @@
9470
<VListTile
9571
v-if="channel.public"
9672
data-test="private"
97-
@click="makePrivateDialog = true"
73+
@click="openDialog('makePrivate')"
9874
>
9975
<VListTileTitle>Make private</VListTileTitle>
10076
</VListTile>
10177
<VListTile
10278
v-else
10379
data-test="public"
104-
@click="makePublicDialog = true"
80+
@click="openDialog('makePublic')"
10581
>
10682
<VListTileTitle>Make public</VListTileTitle>
10783
</VListTile>
10884
<VListTile
10985
v-if="!channel.public"
11086
data-test="softdelete"
111-
@click="softDeleteDialog = true"
87+
@click="openDialog('softDelete')"
11288
>
11389
<VListTileTitle>Delete channel</VListTileTitle>
11490
</VListTile>
@@ -123,15 +99,15 @@
12399
<script>
124100
125101
import { mapActions, mapGetters } from 'vuex';
126-
import ConfirmationDialog from '../../components/ConfirmationDialog';
127102
import { RouteNames } from '../../constants';
128103
import { channelExportMixin } from 'shared/views/channel/mixins';
129104
import { CommunityLibraryStatus } from 'shared/constants';
105+
import StudioBanner from 'shared/views/StudioBanner';
130106
131107
export default {
132108
name: 'ChannelActionsDropdown',
133109
components: {
134-
ConfirmationDialog,
110+
StudioBanner,
135111
},
136112
mixins: [channelExportMixin],
137113
props: {
@@ -141,11 +117,7 @@
141117
},
142118
},
143119
data: () => ({
144-
deleteDialog: false,
145-
makePublicDialog: false,
146-
makePrivateDialog: false,
147-
restoreDialog: false,
148-
softDeleteDialog: false,
120+
activeDialog: null,
149121
}),
150122
computed: {
151123
...mapGetters('channel', ['getChannel']),
@@ -163,6 +135,43 @@
163135
},
164136
};
165137
},
138+
dialogConfig() {
139+
const configs = {
140+
restore: {
141+
title: 'Restore channel',
142+
submitText: 'Restore',
143+
message: `Are you sure you want to restore ${this.name} and make it active again?`,
144+
handler: this.restoreHandler,
145+
},
146+
makePublic: {
147+
title: 'Make channel public',
148+
submitText: 'Make public',
149+
message: `All users will be able to view and import content from ${this.name}.`,
150+
handler: this.makePublicHandler,
151+
errorMessage: this.communityChannelErrorMessage,
152+
submitDisabled: this.isCommunityChannel,
153+
},
154+
makePrivate: {
155+
title: 'Make channel private',
156+
submitText: 'Make private',
157+
message: `Only users with view-only or edit permissions will be able to access ${this.name}.`,
158+
handler: this.makePrivateHandler,
159+
},
160+
permanentDelete: {
161+
title: 'Permanently delete channel',
162+
submitText: 'Delete permanently',
163+
message: `Are you sure you want to permanently delete ${this.name}? This can not be undone.`,
164+
handler: this.deleteHandler,
165+
},
166+
softDelete: {
167+
title: 'Delete channel',
168+
submitText: 'Delete',
169+
message: `Are you sure you want to delete ${this.name}?`,
170+
handler: this.softDeleteHandler,
171+
},
172+
};
173+
return configs[this.activeDialog] || {};
174+
},
166175
isCommunityChannel() {
167176
const status = this.channel.latest_community_library_submission_status;
168177
return status === CommunityLibraryStatus.APPROVED || status === CommunityLibraryStatus.LIVE;
@@ -180,6 +189,15 @@
180189
'deleteChannel',
181190
'updateChannel',
182191
]),
192+
openDialog(type) {
193+
this.activeDialog = type;
194+
},
195+
handleSubmit() {
196+
if (this.dialogConfig.handler) {
197+
this.dialogConfig.handler();
198+
}
199+
this.activeDialog = null;
200+
},
183201
async downloadPDF() {
184202
this.$store.dispatch('showSnackbarSimple', 'Generating PDF...');
185203
const channelList = await this.getAdminChannelListDetails([this.channel.id]);
@@ -191,7 +209,6 @@
191209
return this.generateChannelsCSV(channelList);
192210
},
193211
restoreHandler() {
194-
this.restoreDialog = false;
195212
this.updateChannel({
196213
id: this.channelId,
197214
deleted: false,
@@ -200,7 +217,6 @@
200217
});
201218
},
202219
softDeleteHandler() {
203-
this.softDeleteDialog = false;
204220
this.updateChannel({
205221
id: this.channelId,
206222
deleted: true,
@@ -209,14 +225,12 @@
209225
});
210226
},
211227
deleteHandler() {
212-
this.deleteDialog = false;
213228
this.$emit('deleted');
214229
return this.deleteChannel(this.channelId).then(() => {
215230
this.$store.dispatch('showSnackbarSimple', 'Channel deleted permanently');
216231
});
217232
},
218233
makePublicHandler() {
219-
this.makePublicDialog = false;
220234
this.updateChannel({
221235
id: this.channelId,
222236
isPublic: true,
@@ -225,7 +239,6 @@
225239
});
226240
},
227241
makePrivateHandler() {
228-
this.makePrivateDialog = false;
229242
this.updateChannel({
230243
id: this.channelId,
231244
isPublic: false,

0 commit comments

Comments
 (0)