Skip to content

Commit 40eb5ef

Browse files
authored
Contruct the app keys url on the backend (#704)
* Contruct the app keys url on the backend
1 parent 6d6cc6e commit 40eb5ef

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

apigee_edge.module

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,7 @@ function apigee_edge_entity_view(array &$build, EntityInterface $entity, EntityV
411411
'#app' => $entity,
412412
'#attributes' => [
413413
'class' => 'items--inline',
414-
'data-app' => $entity->getName(),
415-
'data-team' => isset($team_app_name) ? $team_app_name : '',
414+
'data-app-keys-url' => $entity->toUrl('api-keys', ['absolute' => TRUE])->toString(FALSE),
416415
'data-app-container-index' => $index,
417416
],
418417
] + $defaults;

js/apigee_edge.secret.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
}
5050
else {
5151
$el.html(loader);
52-
callEndpoint($wrapper.data('team'), $wrapper.data('app'), function(data) {
52+
callEndpoint($wrapper.data('app-keys-url'), function(data) {
5353
$el.html(data[wrapperIndex][index]);
5454
});
5555
}
@@ -60,7 +60,7 @@
6060
$copy.find('button').on('click', function (event) {
6161
let index = $(this).closest(appElWrapper).find('.secret__copy button').index(this);
6262
let wrapperIndex = $wrapper.closest('fieldset').parent().find('fieldset').index($(this).closest('fieldset'));
63-
callEndpoint($wrapper.data('team'), $wrapper.data('app'), function(data) {
63+
callEndpoint($wrapper.data('app-keys-url'), function(data) {
6464
copyToClipboard(data[wrapperIndex][index]);
6565
$copy.find('.badge').fadeIn().delay(1000).fadeOut();
6666
});
@@ -99,11 +99,7 @@
9999
/**
100100
* Get credentials based on the app name.
101101
*/
102-
function callEndpoint(teamApp, app, callback) {
103-
var endpoint = drupalSettings.path.baseUrl + 'user/' + drupalSettings.currentUser + '/apps/' + app + '/api-keys';
104-
if (teamApp !== undefined && teamApp !== 0 && teamApp !== '') {
105-
endpoint = drupalSettings.path.baseUrl + 'teams/' + teamApp + '/apps/' + app + '/api-keys';
106-
}
102+
function callEndpoint(endpoint, callback) {
107103
$.get(endpoint, function(data) {
108104
callback(data);
109105
});

0 commit comments

Comments
 (0)