forked from TryGhost/Admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added integration details to Zapier integration screen behind dev flag
no issue - the new version of our Zapier App uses API Key auth so we need to expose the details on the Zapier integration screen - extracted `copyTextToClipboard` into a util function - added `integrationModelHook` method to `settings.integrations` controller to remove duplication in the `settings.integration` and `settings.integration.zapier` routes - fixed missing "Zapier" title token
- Loading branch information
1 parent
a5bfd36
commit c1c49fd
Showing
7 changed files
with
134 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,42 @@ | ||
/* eslint-disable ghost/ember/alias-model-in-controller */ | ||
import Controller from '@ember/controller'; | ||
import config from 'ghost-admin/config/environment'; | ||
import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard'; | ||
import {alias} from '@ember/object/computed'; | ||
import {computed} from '@ember/object'; | ||
import {inject as service} from '@ember/service'; | ||
import {task, timeout} from 'ember-concurrency'; | ||
|
||
export default Controller.extend({ | ||
config: service(), | ||
ghostPaths: service(), | ||
|
||
isTesting: undefined, | ||
|
||
init() { | ||
this._super(...arguments); | ||
if (this.isTesting === undefined) { | ||
this.isTesting = config.environment === 'test'; | ||
} | ||
} | ||
}, | ||
|
||
integration: alias('model'), | ||
|
||
apiUrl: computed(function () { | ||
let origin = window.location.origin; | ||
let subdir = this.ghostPaths.subdir; | ||
let url = this.ghostPaths.url.join(origin, subdir); | ||
|
||
return url.replace(/\/$/, ''); | ||
}), | ||
|
||
copyAdminKey: task(function* () { | ||
copyTextToClipboard(this.integration.adminKey.secret); | ||
yield timeout(3000); | ||
}), | ||
|
||
copyApiUrl: task(function* () { | ||
copyTextToClipboard(this.apiUrl); | ||
yield timeout(3000); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default function copyTextToClipboard(text) { | ||
let textarea = document.createElement('textarea'); | ||
textarea.value = text; | ||
textarea.setAttribute('readonly', ''); | ||
textarea.style.position = 'absolute'; | ||
textarea.style.left = '-9999px'; | ||
document.body.appendChild(textarea); | ||
textarea.select(); | ||
document.execCommand('copy'); | ||
document.body.removeChild(textarea); | ||
} |