-
Notifications
You must be signed in to change notification settings - Fork 295
Show draft tokens in Studio #5729
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
base: unstable
Are you sure you want to change the base?
Changes from all commits
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,70 @@ | ||
| <template> | ||
|
|
||
| <KModal :title="previewYourDraftTitle$()"> | ||
| <template #default> | ||
| <div> | ||
| <strong>{{ draftTokenLabel$() }}</strong> | ||
| <StudioCopyToken | ||
| :token="channel.draft_token" | ||
| :showLabel="false" | ||
| /> | ||
| <p class="mt-16">{{ channelTokenDescription$() }}</p> | ||
| </div> | ||
| </template> | ||
| <template #actions> | ||
| <KButton | ||
| :text="dismissAction$()" | ||
| @click="handleDismiss" | ||
| /> | ||
| </template> | ||
| </KModal> | ||
|
|
||
| </template> | ||
|
|
||
|
|
||
| <script setup> | ||
|
|
||
| import { onMounted } from 'vue'; | ||
| import StudioCopyToken from 'shared/views/StudioCopyToken'; | ||
| import { communityChannelsStrings } from 'shared/strings/communityChannelsStrings'; | ||
| import { commonStrings } from 'shared/strings/commonStrings'; | ||
| import logging from 'shared/logging'; | ||
|
|
||
| const props = defineProps({ | ||
| channel: { | ||
| type: Object, | ||
| required: true, | ||
| }, | ||
| }); | ||
|
|
||
| const emit = defineEmits(['close']); | ||
|
|
||
| const { dismissAction$ } = commonStrings; | ||
| const { previewYourDraftTitle$, draftTokenLabel$, channelTokenDescription$ } = | ||
| communityChannelsStrings; | ||
|
|
||
| function handleDismiss() { | ||
| emit('close'); | ||
| } | ||
|
|
||
| onMounted(() => { | ||
| if (!props.channel.draft_token) { | ||
| // If there is no draft token, we can't preview the draft, so we just close the modal | ||
| logging.error( | ||
| 'Attempted to open PreviewDraftChannelModal without a draft token. Closing modal.', | ||
| { channelId: props.channel.id }, | ||
| ); | ||
| handleDismiss(); | ||
| } | ||
| }); | ||
|
|
||
| </script> | ||
|
|
||
|
|
||
| <style lang="scss" scoped> | ||
|
|
||
| .mt-16 { | ||
| margin-top: 16px; | ||
| } | ||
|
|
||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -192,6 +192,12 @@ | |
| </VListTileTitle> | ||
| </VListTile> | ||
| </template> | ||
| <VListTile | ||
| v-if="currentChannel && currentChannel.draft_token" | ||
|
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. suggestion: This menu item is only gated by
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. This is okay, yes. We will only hide the draft option radio button for users who do not have the |
||
| @click="showPreviewDraftModal = true" | ||
| > | ||
| <VListTileTitle>{{ getDraftTokenAction$() }}</VListTileTitle> | ||
| </VListTile> | ||
| <VListTile | ||
| v-if="isPublished" | ||
| @click="showTokenModal = true" | ||
|
|
@@ -277,6 +283,11 @@ | |
| @delete="handleDelete" | ||
| @close="showDeleteModal = false" | ||
| /> | ||
| <PreviewDraftChannelModal | ||
| v-if="showPreviewDraftModal && currentChannel" | ||
| :channel="currentChannel" | ||
| @close="showPreviewDraftModal = false" | ||
| /> | ||
| <VSpeedDial | ||
| v-if="showClipboardSpeedDial" | ||
| v-model="showClipboard" | ||
|
|
@@ -340,6 +351,7 @@ | |
| <script> | ||
|
|
||
| import { mapActions, mapGetters, mapState } from 'vuex'; | ||
| import PreviewDraftChannelModal from '../../components/modals/PreviewDraftChannelModal.vue'; | ||
| import Clipboard from '../../components/Clipboard'; | ||
| import SyncResourcesModal from '../sync/SyncResourcesModal'; | ||
| import ProgressModal from '../progress/ProgressModal'; | ||
|
|
@@ -361,6 +373,8 @@ | |
| import DraggableRegion from 'shared/views/draggable/DraggableRegion'; | ||
| import { DropEffect } from 'shared/mixins/draggable/constants'; | ||
| import DraggablePlaceholder from 'shared/views/draggable/DraggablePlaceholder'; | ||
| import { communityChannelsStrings } from 'shared/strings/communityChannelsStrings'; | ||
| import { commonStrings } from 'shared/strings/commonStrings'; | ||
|
|
||
| export default { | ||
| name: 'TreeViewBase', | ||
|
|
@@ -381,8 +395,15 @@ | |
| DraggablePlaceholder, | ||
| SavingIndicator, | ||
| QuickEditModal, | ||
| PreviewDraftChannelModal, | ||
| }, | ||
| mixins: [titleMixin], | ||
| setup() { | ||
| const { getDraftTokenAction$ } = communityChannelsStrings; | ||
| return { | ||
| getDraftTokenAction$, | ||
| }; | ||
| }, | ||
| props: { | ||
| loading: { | ||
| type: Boolean, | ||
|
|
@@ -398,6 +419,7 @@ | |
| showSyncModal: false, | ||
| showClipboard: false, | ||
| showDeleteModal: false, | ||
| showPreviewDraftModal: false, | ||
| syncing: false, | ||
| resubmitToCommunityLibraryModalData: null, | ||
| }; | ||
|
|
@@ -533,6 +555,22 @@ | |
| }, | ||
| immediate: true, | ||
| }, | ||
| isDraftPublishing(newVal, oldVal) { | ||
| if (!newVal && oldVal) { | ||
| const { draftPublishedNotice$ } = communityChannelsStrings; | ||
| const { previewAction$ } = commonStrings; | ||
| const snackbarData = { | ||
| text: draftPublishedNotice$(), | ||
| }; | ||
| if (this.currentChannel.draft_token) { | ||
| snackbarData.actionText = previewAction$(); | ||
| snackbarData.actionCallback = () => { | ||
| this.showPreviewDraftModal = true; | ||
| }; | ||
| } | ||
| this.$store.dispatch('showSnackbar', snackbarData); | ||
| } | ||
| }, | ||
| }, | ||
| methods: { | ||
| ...mapActions('channel', ['deleteChannel']), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1388,6 +1388,12 @@ def get_resource_count(self): | |
| def get_human_token(self): | ||
| return self.secret_tokens.get(is_primary=True) | ||
|
|
||
| def get_draft_token(self): | ||
| draft_version = self.channel_versions.filter(version=None).first() | ||
| if not draft_version: | ||
| return None | ||
| return draft_version.secret_token | ||
|
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. suggestion (UNADDRESSED from prior review): |
||
|
|
||
| def get_channel_id_token(self): | ||
| return self.secret_tokens.get(token=self.id) | ||
|
|
||
|
|
||
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.
praise: Clean feature-flag gating of the draft publish mode. The dynamic
component :ispattern to switch betweenKRadioButtonGroupanddivis a nice way to preserve the live-publish UI for non-flagged users.