-
Notifications
You must be signed in to change notification settings - Fork 254
Handle deletion of a Channel with a related Community Library Submission #5551
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
Changes from all commits
bb55d03
b34fde9
f90b60d
dec45f1
c4aa056
1aecfdf
9387a48
42aac79
f0d03a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| <template> | ||
|
|
||
| <KModal | ||
| :title="canEdit ? $tr('deleteTitle') : $tr('removeTitle')" | ||
| :submitText="canEdit ? $tr('deleteChannel') : $tr('removeBtn')" | ||
| :cancelText="$tr('cancel')" | ||
| :submitDisabled="loading" | ||
| data-test="remove-channel-modal" | ||
| @submit="handleSubmit" | ||
| @cancel="close" | ||
| > | ||
| <div | ||
| v-if="loading" | ||
| class="py-4 text-center" | ||
| > | ||
| <KCircularLoader :size="24" /> | ||
| </div> | ||
| <template v-else> | ||
| <div | ||
| v-if="canEdit && hasCommunityLibrarySubmission" | ||
| class="mb-3" | ||
| data-test="cl-warning" | ||
| > | ||
| {{ $tr('deleteChannelWithCLWarning') }} | ||
| </div> | ||
| {{ canEdit ? $tr('deletePrompt') : $tr('removePrompt') }} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, if canEdit is false, we are not deleting the channel itself, just removing the user from the list of readers. In that case, I think it wouldn't make much sense to show the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Alex, I thought my implement has matched your comment. The warning only displays when both conditions are true:
{{ $tr('deleteChannelWithCLWarning') }}
When canEdit is false: the warning doesn't render (the v-if prevents it).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yes, mb didn't notice the v-if of the |
||
| </template> | ||
| </KModal> | ||
|
|
||
| </template> | ||
|
|
||
|
|
||
| <script> | ||
|
|
||
| import { ref, onMounted } from 'vue'; | ||
| import client from 'shared/client'; | ||
| import { Channel } from 'shared/data/resources'; | ||
|
|
||
| export default { | ||
| name: 'RemoveChannelModal', | ||
| setup(props, { emit }) { | ||
| const loading = ref(false); | ||
| const hasCommunityLibrarySubmission = ref(false); | ||
|
|
||
| async function fetchCommunityLibrarySubmissionStatus() { | ||
| loading.value = true; | ||
| try { | ||
| const url = Channel.getUrlFunction('has_community_library_submission')(props.channelId); | ||
| const response = await client.get(url); | ||
| hasCommunityLibrarySubmission.value = | ||
| response.data?.has_community_library_submission ?? false; | ||
| } catch (error) { | ||
| hasCommunityLibrarySubmission.value = false; | ||
| } finally { | ||
| loading.value = false; | ||
| } | ||
| } | ||
|
|
||
| onMounted(() => { | ||
| if (props.canEdit) { | ||
| fetchCommunityLibrarySubmissionStatus(); | ||
| } | ||
| }); | ||
|
|
||
| function handleSubmit() { | ||
| emit('delete'); | ||
| } | ||
|
|
||
| function close() { | ||
| emit('close'); | ||
| } | ||
|
|
||
| return { | ||
| loading, | ||
| hasCommunityLibrarySubmission, | ||
| handleSubmit, | ||
| close, | ||
| }; | ||
| }, | ||
| props: { | ||
| channelId: { | ||
| type: String, | ||
| required: true, | ||
| }, | ||
| canEdit: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| }, | ||
| emits: ['delete', 'close'], | ||
| $trs: { | ||
| deleteTitle: 'Delete this channel', | ||
| removeTitle: 'Remove from channel list', | ||
| deleteChannel: 'Delete channel', | ||
| removeBtn: 'Remove', | ||
| cancel: 'Cancel', | ||
| deletePrompt: 'This channel will be permanently deleted. This cannot be undone.', | ||
| removePrompt: | ||
| 'You have view-only access to this channel. Confirm that you want to remove it from your list of channels.', | ||
| deleteChannelWithCLWarning: | ||
| 'This channel has been shared with the Community Library. Deleting it here will not remove it from the Community Library — it may still be approved or remain available there.', | ||
| }, | ||
| }; | ||
|
|
||
| </script> | ||
|
|
||
|
|
||
| <style lang="scss" scoped></style> | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When filtering by Community Library:
When filtering by other types:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!