mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
f92c62b59a
refs https://github.com/TryGhost/Team/issues/1734 refs https://github.com/TryGhost/Team/issues/559 refs https://github.com/TryGhost/Ghost/issues/14101 - switches to newer modal patterns ready for later Ember upgrades - migrated Zapier controller to native class syntax - fixed regeneration confirmation text not being visible on Zapier screen
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {capitalize} from '@ember/string';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class RegenerateKeyModal extends Component {
|
|
@service ajax;
|
|
@service ghostPaths;
|
|
@service notifications;
|
|
@service store;
|
|
|
|
@tracked errorMessage;
|
|
|
|
@task({drop: true})
|
|
*regenerateKeyTask() {
|
|
const {integration, apiKey} = this.args.data;
|
|
const url = this.ghostPaths.url.api('/integrations/', integration.id, 'api_key', apiKey.id, 'refresh');
|
|
|
|
try {
|
|
const response = yield this.ajax.post(url, {
|
|
data: {
|
|
integrations: [{id: integration.id}]
|
|
}
|
|
});
|
|
|
|
this.store.pushPayload(response);
|
|
this.args.close(apiKey);
|
|
} catch (e) {
|
|
console.error(e); // eslint-disable-line
|
|
this.errorMessage = `There was an error regenerating the ${capitalize(apiKey.type)} API Key. Please try again`;
|
|
return;
|
|
}
|
|
}
|
|
}
|