|
10 | 10 | <div class="main"> |
11 | 11 | <template v-if="!drivesLoading"> |
12 | 12 | <div class="modal-message"> |
| 13 | + <p> |
| 14 | + {{ $tr('exportPromptPrefix', { numChannels: allChannels.length }) }} |
| 15 | + ({{ exportContentSize }}) |
| 16 | + </p> |
13 | 17 | <drive-list |
14 | 18 | :value="selectedDrive" |
15 | 19 | :drives="wizardState.driveList" |
|
53 | 57 | import kButton from 'kolibri.coreVue.components.kButton'; |
54 | 58 | import loadingSpinner from 'kolibri.coreVue.components.loadingSpinner'; |
55 | 59 | import driveList from './wizards/drive-list'; |
| 60 | + import sumBy from 'lodash/sumBy'; |
| 61 | +
|
56 | 62 | export default { |
57 | 63 | name: 'wizardExport', |
58 | 64 | $trs: { |
59 | | - title: 'Export to a Local Drive', |
60 | | - available: 'Available Storage:', |
61 | | - notWritable: 'Not writable', |
| 65 | + available: 'available', |
62 | 66 | cancel: 'Cancel', |
63 | 67 | export: 'Export', |
| 68 | + exportPromptPrefix: 'You are about to export {numChannels, number} {numChannels, plural, one {channel} other {channels}}', |
| 69 | + notWritable: 'Not writable', |
64 | 70 | refresh: 'Refresh', |
| 71 | + title: 'Export to where?', |
| 72 | + waitForTotalSize: 'Calculating total size...', |
65 | 73 | }, |
66 | 74 | components: { |
67 | 75 | coreModal, |
|
77 | 85 | canSubmit() { |
78 | 86 | return !this.drivesLoading && !this.wizardState.busy && this.selectedDrive !== ''; |
79 | 87 | }, |
| 88 | + exportContentSize() { |
| 89 | + const allChannelsHaveStats = this.allChannels.length === Object.keys(this.channelsWithStats).length; |
| 90 | + if (allChannelsHaveStats) { |
| 91 | + const totalSize = sumBy(Object.values(this.channelsWithStats), 'totalFileSizeInBytes'); |
| 92 | + return bytesForHumans(totalSize); |
| 93 | + } |
| 94 | + return this.$tr('waitForTotalSize'); |
| 95 | + }, |
80 | 96 | }, |
81 | 97 | methods: { |
82 | 98 | formatEnabledMsg(drive) { |
83 | | - return `${this.$tr('available')} ${bytesForHumans(drive.freespace)}`; |
| 99 | + return `${bytesForHumans(drive.freespace)} ${this.$tr('available')}`; |
84 | 100 | }, |
85 | 101 | driveIsEnabled(drive) { |
86 | 102 | return drive.writable; |
|
100 | 116 | }, |
101 | 117 | }, |
102 | 118 | vuex: { |
103 | | - getters: { wizardState: state => state.pageState.wizardState }, |
| 119 | + getters: { |
| 120 | + allChannels: (state) => state.core.channels.list, |
| 121 | + channelsWithStats: state => state.pageState.channelFileSummaries, |
| 122 | + wizardState: state => state.pageState.wizardState, |
| 123 | + }, |
104 | 124 | actions: { |
105 | 125 | transitionWizardPage: manageContentActions.transitionWizardPage, |
106 | 126 | updateWizardLocalDriveList: actions.updateWizardLocalDriveList, |
|
0 commit comments