mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
Updated the posts export button to be a GhTaskButton
refs https://github.com/TryGhost/Team/issues/2935 This allows us to track the state with a loading spinner and a success/error message on completion. This is expecially important for larger sites where the download can take a long time, and users are unsure if something is happening.
This commit is contained in:
parent
3dac3cb4e2
commit
a890f0b707
@ -110,9 +110,7 @@
|
||||
Download a CSV file of all your post data for easy analysis in one place
|
||||
</p>
|
||||
</div>
|
||||
<button type="button" class="gh-btn" {{on "click" this.exportData}}>
|
||||
<span>Export</span>
|
||||
</button>
|
||||
<GhTaskButton @buttonText="Export" @successText="Exported" @task={{this.exportPostsTask}} @class="gh-btn gh-btn-icon"/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -2,6 +2,7 @@ import Component from '@glimmer/component';
|
||||
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
||||
import {action} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
|
||||
export default class Analytics extends Component {
|
||||
@service settings;
|
||||
@ -16,13 +17,15 @@ export default class Analytics extends Component {
|
||||
this.settings.emailTrackOpens = !this.settings.emailTrackOpens;
|
||||
}
|
||||
|
||||
@action
|
||||
exportData() {
|
||||
@task
|
||||
*exportPostsTask() {
|
||||
let exportUrl = ghostPaths().url.api('posts/export');
|
||||
let downloadParams = new URLSearchParams();
|
||||
downloadParams.set('limit', 'all');
|
||||
|
||||
this.utils.downloadFile(`${exportUrl}?${downloadParams.toString()}`);
|
||||
yield this.utils.fetchAndDownloadFile(`${exportUrl}?${downloadParams.toString()}`);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@action
|
||||
|
Loading…
Reference in New Issue
Block a user