Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>

<KModal
:title="title"
:submitText="resubmitButtonText"
:cancelText="dismissButtonText"
data-test="resubmit-modal"
@submit="handleResubmit"
@cancel="handleDismiss"
>
<div class="resubmit-modal-content">
<p class="resubmit-modal-description">{{ description }}</p>
<p class="resubmit-modal-question">{{ question }}</p>
</div>
</KModal>

</template>


<script setup>

import { computed } from 'vue';
import { communityChannelsStrings } from 'shared/strings/communityChannelsStrings';

const props = defineProps({
channel: {
type: Object,
required: true,
validator(value) {
return value && typeof value.name === 'string' && typeof value.version === 'number';
},
},
latestSubmissionVersion: {
type: Number,
required: true,
},
});

const emit = defineEmits(['close', 'resubmit']);

const title = computed(() => communityChannelsStrings.resubmitModalTitle$());

const publishedVersion = computed(() => {
return props.latestSubmissionVersion != null
? props.latestSubmissionVersion
: props.channel.version;
});

const description = computed(() =>
communityChannelsStrings.resubmitModalBodyFirst$({
channelName: props.channel.name,
version: publishedVersion.value,
}),
);

const question = computed(() => communityChannelsStrings.resubmitModalBodySecond$());

const dismissButtonText = computed(() => communityChannelsStrings.dismissAction$());

const resubmitButtonText = computed(() => communityChannelsStrings.resubmitAction$());

function handleDismiss() {
emit('close');
}

function handleResubmit() {
emit('resubmit');
Copy link
Member

Choose a reason for hiding this comment

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

Let's also emit the 'close' event when resubmitting, so that the parent component can handle both events separately, without needing to close the modal when the resubmit event is emitted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, Thanks!

emit('close');
}

</script>
Copy link
Member

Choose a reason for hiding this comment

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

Should the resubmit CL modal be checked and triggered by this component? If so, we can show a loader here, until that check finishes, and then we can emit a showResubmitCommunityLibraryModal or something like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added! But when I tried to test it manually. The process of publishing was so fast. I could not even see the loader. LOL!

Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@

import { ref, computed, getCurrentInstance, onMounted } from 'vue';
import SidePanelModal from 'shared/views/SidePanelModal';
import { Channel } from 'shared/data/resources';
import { Channel, CommunityLibrarySubmission } from 'shared/data/resources';
import { forceServerSync } from 'shared/data/serverSync';
import { communityChannelsStrings } from 'shared/strings/communityChannelsStrings';
import { LanguagesList } from 'shared/leUtils/Languages';
import logging from 'shared/logging';

export default {
name: 'PublishSidePanel',
Expand Down Expand Up @@ -330,6 +331,27 @@

await Channel.publish(currentChannel.value.id, version_notes.value);

if (mode.value === PublishModes.LIVE) {
try {
const response = await CommunityLibrarySubmission.fetchCollection({
channel: currentChannel.value.id,
max_results: 1,
});

const submissions = response?.results || [];

if (submissions.length > 0) {
const latestSubmission = submissions[0];
emit('showResubmitCommunityLibraryModal', {
channel: { ...currentChannel.value },
latestSubmissionVersion: latestSubmission.channel_version,
});
}
} catch (error) {
logging.error(error);
}
}

emit('close');
}
} catch (error) {
Expand Down Expand Up @@ -402,7 +424,7 @@
};
},

emits: ['close'],
emits: ['close', 'showResubmitCommunityLibraryModal'],
};

</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,20 @@
<PublishSidePanel
v-if="showPublishSidePanel"
@close="showPublishSidePanel = false"
@showResubmitCommunityLibraryModal="handleShowResubmitToCommunityLibraryModal"
/>
<SubmitToCommunityLibrarySidePanel
v-if="showSubmitToCommunityLibrarySidePanel"
:channel="currentChannel"
@close="showSubmitToCommunityLibrarySidePanel = false"
/>
<ResubmitToCommunityLibraryModal
v-if="resubmitToCommunityLibraryModalData"
:channel="resubmitToCommunityLibraryModalData.channel"
:latestSubmissionVersion="resubmitToCommunityLibraryModalData.latestSubmissionVersion"
@resubmit="handleResubmitToCommunityLibrary"
@close="handleDismissResubmitToCommunityLibrary"
/>
<template v-if="isPublished">
<ChannelTokenModal
v-model="showTokenModal"
Expand Down Expand Up @@ -349,6 +357,7 @@
import { DraggableRegions, DraggableUniverses, RouteNames } from '../../constants';
import PublishSidePanel from '../../components/sidePanels/PublishSidePanel';
import SubmitToCommunityLibrarySidePanel from '../../components/sidePanels/SubmitToCommunityLibrarySidePanel';
import ResubmitToCommunityLibraryModal from '../../components/modals/ResubmitToCommunityLibraryModal';
import MainNavigationDrawer from 'shared/views/MainNavigationDrawer';
import ToolBar from 'shared/views/ToolBar';
import ChannelTokenModal from 'shared/views/channel/ChannelTokenModal';
Expand All @@ -369,6 +378,7 @@
ToolBar,
PublishSidePanel,
SubmitToCommunityLibrarySidePanel,
ResubmitToCommunityLibraryModal,
ProgressModal,
ChannelTokenModal,
SyncResourcesModal,
Expand Down Expand Up @@ -397,6 +407,7 @@
showClipboard: false,
showDeleteModal: false,
syncing: false,
resubmitToCommunityLibraryModalData: null,
};
},
computed: {
Expand Down Expand Up @@ -546,6 +557,18 @@
this.showPublishSidePanel = true;
this.trackClickEvent('Publish');
},
handleResubmitToCommunityLibrary() {
this.showSubmitToCommunityLibrarySidePanel = true;
},
handleDismissResubmitToCommunityLibrary() {
this.resubmitToCommunityLibraryModalData = null;
},
handleShowResubmitToCommunityLibraryModal(resubmitData) {
if (resubmitData?.latestSubmissionVersion == null) {
return;
}
this.resubmitToCommunityLibraryModalData = resubmitData;
},
trackClickEvent(eventLabel) {
this.$analytics.trackClick('channel_editor_toolbar', eventLabel);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,28 @@ export const communityChannelsStrings = createTranslator('CommunityChannelsStrin
message: 'I understand this will replace my earlier submission on the review queue',
context: 'Checkbox text shown when there is a pending submission to confirm replacement',
},
resubmitModalTitle: {
message: 'Resubmit channel for Community library review?',
context:
'Title of the modal shown after publishing a channel that already has Community Library submissions',
},
resubmitModalBodyFirst: {
message: '{channelName} v{version} is also published to the Community Library.',
context:
'First sentence of the body text of the modal shown after publishing a channel that already has Community Library submissions',
},
resubmitModalBodySecond: {
message:
'Would you like to resubmit this version with your changes for community library review?',
context:
'Second sentence of the body text of the modal shown after publishing a channel that already has Community Library submissions',
},
resubmitAction: {
message: 'Resubmit',
context: 'Action in the resubmit modal to open the submit to Community Library side panel',
},
dismissAction: {
message: 'Dismiss',
context: 'Action in the resubmit modal to dismiss the modal',
},
});