-
Notifications
You must be signed in to change notification settings - Fork 256
Create ChannelVersion model with token support #5589
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
e4a589d
66f50b7
31039f6
82dad0f
7743900
50f0355
64311a2
50398cf
17c9e4c
4819470
2573dcd
3339633
2a4e5ef
54867ca
4b73ac1
33e0391
e355fb1
9792dab
ca6856f
b213fd0
609e651
9c1fa51
a7c0245
458cc76
a3c2798
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 |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ const ITEMS_PER_PAGE = 3; | |
| * Reactive state for the fetched, flattened permissions and pagination | ||
| * helpers used by `SpecialPermissionsList.vue`. | ||
| */ | ||
| export function useSpecialPermissions(permissionIds) { | ||
| export function useSpecialPermissions(channelVersionId, permissionIds) { | ||
|
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. Here we don't actually need the |
||
| const permissions = ref([]); | ||
| const isLoading = ref(false); | ||
| const error = ref(null); | ||
|
|
@@ -39,20 +39,24 @@ export function useSpecialPermissions(permissionIds) { | |
| return permissions.value.slice(start, end); | ||
| }); | ||
|
|
||
| async function fetchPermissions(ids) { | ||
| if (!ids || ids.length === 0) { | ||
| permissions.value = []; | ||
| return; | ||
| } | ||
|
|
||
| async function fetchPermissions(versionId, ids) { | ||
| isLoading.value = true; | ||
| error.value = null; | ||
| permissions.value = []; | ||
|
|
||
| try { | ||
| const response = await AuditedSpecialPermissionsLicense.fetchCollection({ | ||
| by_ids: ids.join(','), | ||
| distributable: false, | ||
| }); | ||
| let response = []; | ||
| if (versionId) { | ||
| response = await AuditedSpecialPermissionsLicense.fetchCollection({ | ||
| channel_version: versionId, | ||
| distributable: false, | ||
| }); | ||
| } else if (ids && ids.length > 0) { | ||
| response = await AuditedSpecialPermissionsLicense.fetchCollection({ | ||
| by_ids: ids.join(','), | ||
| distributable: false, | ||
| }); | ||
| } | ||
|
Comment on lines
+49
to
+59
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. We can just provide support for the |
||
|
|
||
| permissions.value = response.map(permission => ({ | ||
| id: permission.id, | ||
|
|
@@ -79,18 +83,10 @@ export function useSpecialPermissions(permissionIds) { | |
| } | ||
| } | ||
|
|
||
| const resolvedPermissionIds = computed(() => { | ||
| const ids = unref(permissionIds); | ||
| if (!ids || ids.length === 0) { | ||
| return []; | ||
| } | ||
| return ids; | ||
| }); | ||
|
|
||
| watch( | ||
| resolvedPermissionIds, | ||
| ids => { | ||
| fetchPermissions(ids); | ||
| [() => unref(channelVersionId), () => unref(permissionIds)], | ||
| ([versionId, ids]) => { | ||
| fetchPermissions(versionId, ids); | ||
| }, | ||
| { immediate: true }, | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,7 +163,8 @@ | |
| <SpecialPermissionsList | ||
| v-if="licenseAuditIsFinished && specialPermissions.length > 0" | ||
| v-model="checkedSpecialPermissions" | ||
| :permissionIds="specialPermissions" | ||
| :channel-version-id="versionDetail && versionDetail.id" | ||
| :permission-ids="specialPermissions" | ||
|
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. Just a note that since right now, we don't return the
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. Also note that in the useLicenseAudit.js we are still using the getPublishedData. And this will fail because this method no longer exists in the ChannelResource. |
||
| @update:allChecked="allSpecialPermissionsChecked = $event" | ||
| /> | ||
| <div class="country-area"> | ||
|
|
@@ -417,17 +418,15 @@ | |
| const { | ||
| isLoading: publishedDataIsLoading, | ||
| isFinished: publishedDataIsFinished, | ||
| data: publishedData, | ||
| data: versionDetail, | ||
| fetchData: fetchPublishedData, | ||
| } = usePublishedData(props.channel.id); | ||
| // Use the latest version available from either channel or publishedData | ||
| // Use the latest version available from either channel or versionDetail | ||
| const displayedVersion = computed(() => { | ||
| const channelVersion = currentChannelVersion.value || 0; | ||
| if (publishedData.value && Object.keys(publishedData.value).length > 0) { | ||
| const publishedVersions = Object.keys(publishedData.value).map(v => parseInt(v, 10)); | ||
| const maxPublishedVersion = Math.max(...publishedVersions); | ||
| return Math.max(channelVersion, maxPublishedVersion); | ||
| if (versionDetail.value && versionDetail.value.version) { | ||
| return Math.max(channelVersion, versionDetail.value.version); | ||
| } | ||
| return channelVersion; | ||
| }); | ||
|
|
@@ -465,11 +464,6 @@ | |
| return conditions.every(condition => condition); | ||
| }); | ||
| const latestPublishedData = computed(() => { | ||
| if (!publishedData.value || !displayedVersion.value) return undefined; | ||
| return publishedData.value[displayedVersion.value]; | ||
| }); | ||
| // Watch for when publishing completes - fetch publishedData to get the new version's data | ||
| watch(isPublishing, async (newIsPublishing, oldIsPublishing) => { | ||
| if (oldIsPublishing === true && newIsPublishing === false) { | ||
|
|
@@ -488,11 +482,7 @@ | |
| }); | ||
| const detectedLanguages = computed(() => { | ||
| // We need to filter out null values due to a backend bug | ||
| // causing null values to sometimes be included in the list | ||
| const languageCodes = latestPublishedData.value?.included_languages.filter( | ||
| code => code !== null, | ||
| ); | ||
| const languageCodes = versionDetail.value?.included_languages; | ||
| // We distinguish here between "not loaded yet" (undefined) | ||
| // and "loaded and none present" (null). This distinction is | ||
|
|
@@ -502,7 +492,7 @@ | |
| if (!languageCodes) return undefined; | ||
| if (languageCodes.length === 0) return null; | ||
| return languageCodes.map(code => LanguagesMap.get(code).readable_name).join(', '); | ||
| return languageCodes.map(code => LanguagesMap.get(code)?.readable_name || code).join(', '); | ||
|
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. Were there some invalid languages or languages whose readable_name was undefined? |
||
| }); | ||
| function categoryIdToName(categoryId) { | ||
|
|
@@ -515,10 +505,10 @@ | |
| // not used in the UI and is mostly intended to convey the | ||
| // state more accurately to the developer in case of debugging. | ||
| // UI code should rely on XXXIsLoading and XXXIsFinished instead. | ||
| if (!latestPublishedData.value?.included_categories) return undefined; | ||
| if (latestPublishedData.value.included_categories.length === 0) return null; | ||
| if (!versionDetail.value?.included_categories) return undefined; | ||
| if (versionDetail.value.included_categories.length === 0) return null; | ||
| return latestPublishedData.value.included_categories | ||
| return versionDetail.value.included_categories | ||
| .map(categoryId => categoryIdToName(categoryId)) | ||
| .join(', '); | ||
| }); | ||
|
|
@@ -544,7 +534,7 @@ | |
| description: description.value, | ||
| channel: props.channel.id, | ||
| countries: countries.value.map(country => countriesUtil.getAlpha2Code(country, 'en')), | ||
| categories: latestPublishedData.value.included_categories, | ||
| categories: versionDetail.value.included_categories, | ||
| }) | ||
| .then(() => { | ||
| showSnackbar({ text: submittedSnackbar$() }); | ||
|
|
||
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.
Just noting that we should also update this here to use the new info (since this would directly return the
latestPublishedDataobject).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.
Fixed, Thanks!