diff --git a/app/assets/javascripts/admin/adapters/web-hook-event.js.es6 b/app/assets/javascripts/admin/adapters/web-hook-event.js.es6 new file mode 100644 index 00000000000..122070ce3e4 --- /dev/null +++ b/app/assets/javascripts/admin/adapters/web-hook-event.js.es6 @@ -0,0 +1,7 @@ +import RESTAdapter from 'discourse/adapters/rest'; + +export default RESTAdapter.extend({ + basePath() { + return '/admin/api/'; + } +}); diff --git a/app/assets/javascripts/admin/adapters/web-hook.js.es6 b/app/assets/javascripts/admin/adapters/web-hook.js.es6 new file mode 100644 index 00000000000..122070ce3e4 --- /dev/null +++ b/app/assets/javascripts/admin/adapters/web-hook.js.es6 @@ -0,0 +1,7 @@ +import RESTAdapter from 'discourse/adapters/rest'; + +export default RESTAdapter.extend({ + basePath() { + return '/admin/api/'; + } +}); diff --git a/app/assets/javascripts/admin/components/admin-web-hook-event.js.es6 b/app/assets/javascripts/admin/components/admin-web-hook-event.js.es6 index b03c9a5f8ef..264e827da61 100644 --- a/app/assets/javascripts/admin/components/admin-web-hook-event.js.es6 +++ b/app/assets/javascripts/admin/components/admin-web-hook-event.js.es6 @@ -33,7 +33,7 @@ export default Ember.Component.extend({ redeliver() { return bootbox.confirm(I18n.t('admin.web_hooks.events.redeliver_confirm'), I18n.t('no_value'), I18n.t('yes_value'), result => { if (result) { - ajax(`/admin/web_hooks/${this.get('model.web_hook_id')}/events/${this.get('model.id')}/redeliver`, { type: 'POST' }).then(json => { + ajax(`/admin/api/web_hooks/${this.get('model.web_hook_id')}/events/${this.get('model.id')}/redeliver`, { type: 'POST' }).then(json => { this.set('model', json.web_hook_event); }).catch(popupAjaxError); } diff --git a/app/assets/javascripts/admin/controllers/admin-api.js.es6 b/app/assets/javascripts/admin/controllers/admin-api-keys.js.es6 similarity index 100% rename from app/assets/javascripts/admin/controllers/admin-api.js.es6 rename to app/assets/javascripts/admin/controllers/admin-api-keys.js.es6 diff --git a/app/assets/javascripts/admin/controllers/admin-web-hooks-show-events.js.es6 b/app/assets/javascripts/admin/controllers/admin-web-hooks-show-events.js.es6 index d91469d33df..6ef4411702e 100644 --- a/app/assets/javascripts/admin/controllers/admin-web-hooks-show-events.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-web-hooks-show-events.js.es6 @@ -41,7 +41,7 @@ export default Ember.Controller.extend({ ping() { this.set('pingDisabled', true); - ajax(`/admin/web_hooks/${this.get('model.extras.web_hook_id')}/ping`, { + ajax(`/admin/api/web_hooks/${this.get('model.extras.web_hook_id')}/ping`, { type: 'POST' }).catch(error => { this.set('pingDisabled', false); @@ -52,7 +52,7 @@ export default Ember.Controller.extend({ showInserted() { const webHookId = this.get('model.extras.web_hook_id'); - ajax(`/admin/web_hooks/${webHookId}/events/bulk`, { + ajax(`/admin/api/web_hooks/${webHookId}/events/bulk`, { type: 'GET', data: { ids: this.get('incomingEventIds') } }).then(data => { diff --git a/app/assets/javascripts/admin/models/api-key.js.es6 b/app/assets/javascripts/admin/models/api-key.js.es6 index aa05ce8341c..2a7cf867783 100644 --- a/app/assets/javascripts/admin/models/api-key.js.es6 +++ b/app/assets/javascripts/admin/models/api-key.js.es6 @@ -52,7 +52,7 @@ ApiKey.reopenClass({ @returns {Promise} a promise that resolves to the array of `ApiKey` instances **/ find: function() { - return ajax("/admin/api").then(function(keys) { + return ajax("/admin/api/keys").then(function(keys) { return keys.map(function (key) { return ApiKey.create(key); }); diff --git a/app/assets/javascripts/admin/routes/admin-api-index.js.es6 b/app/assets/javascripts/admin/routes/admin-api-index.js.es6 new file mode 100644 index 00000000000..f41f6bb7948 --- /dev/null +++ b/app/assets/javascripts/admin/routes/admin-api-index.js.es6 @@ -0,0 +1,5 @@ +export default Ember.Route.extend({ + beforeModel() { + this.transitionTo('adminApiKeys'); + } +}); diff --git a/app/assets/javascripts/admin/routes/admin-api.js.es6 b/app/assets/javascripts/admin/routes/admin-api-keys.js.es6 similarity index 100% rename from app/assets/javascripts/admin/routes/admin-api.js.es6 rename to app/assets/javascripts/admin/routes/admin-api-keys.js.es6 diff --git a/app/assets/javascripts/admin/routes/admin-route-map.js.es6 b/app/assets/javascripts/admin/routes/admin-route-map.js.es6 index df27e2c07be..69b51e5cabb 100644 --- a/app/assets/javascripts/admin/routes/admin-route-map.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-route-map.js.es6 @@ -35,10 +35,14 @@ export default { this.route('edit', { path: '/:id' }); }); }); - this.route('api'); - this.resource('adminWebHooks', { path: '/web_hooks' }, function() { - this.route('show', { path: '/:web_hook_id' }); - this.route('showEvents', { path: '/:web_hook_id/events' }); + + this.resource('adminApi', { path: '/api' }, function() { + this.resource('adminApiKeys', { path: '/keys' }); + + this.resource('adminWebHooks', { path: '/web_hooks' }, function() { + this.route('show', { path: '/:web_hook_id' }); + this.route('showEvents', { path: '/:web_hook_id/events' }); + }); }); this.resource('admin.backups', { path: '/backups' }, function() { diff --git a/app/assets/javascripts/admin/routes/admin-web-hooks-show-events.js.es6 b/app/assets/javascripts/admin/routes/admin-web-hooks-show-events.js.es6 index 89841d5a7ba..c9700db463c 100644 --- a/app/assets/javascripts/admin/routes/admin-web-hooks-show-events.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-web-hooks-show-events.js.es6 @@ -13,6 +13,6 @@ export default Discourse.Route.extend({ }, renderTemplate() { - this.render('admin/templates/web-hooks-show-events', { into: 'admin' }); + this.render('admin/templates/web-hooks-show-events', { into: 'adminApi' }); } }); diff --git a/app/assets/javascripts/admin/routes/admin-web-hooks-show.js.es6 b/app/assets/javascripts/admin/routes/admin-web-hooks-show.js.es6 index 533d7c09fe0..51b7d55d47c 100644 --- a/app/assets/javascripts/admin/routes/admin-web-hooks-show.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-web-hooks-show.js.es6 @@ -21,6 +21,6 @@ export default Discourse.Route.extend({ }, renderTemplate() { - this.render('admin/templates/web-hooks-show', { into: 'admin' }); + this.render('admin/templates/web-hooks-show', { into: 'adminApi' }); } }); diff --git a/app/assets/javascripts/admin/templates/admin.hbs b/app/assets/javascripts/admin/templates/admin.hbs index 05076b7408e..e29125aec3d 100644 --- a/app/assets/javascripts/admin/templates/admin.hbs +++ b/app/assets/javascripts/admin/templates/admin.hbs @@ -19,8 +19,7 @@ {{nav-item route='adminLogs' label='admin.logs.title'}} {{#if currentUser.admin}} {{nav-item route='adminCustomize' label='admin.customize.title'}} - {{nav-item route='admin.api' label='admin.api.title'}} - {{nav-item route='adminWebHooks' label='admin.web_hooks.title'}} + {{nav-item route='adminApi' label='admin.api.title'}} {{nav-item route='admin.backups' label='admin.backups.title'}} {{/if}} {{nav-item route='adminPlugins' label='admin.plugins.title'}} diff --git a/app/assets/javascripts/admin/templates/api-keys.hbs b/app/assets/javascripts/admin/templates/api-keys.hbs new file mode 100644 index 00000000000..4123e576389 --- /dev/null +++ b/app/assets/javascripts/admin/templates/api-keys.hbs @@ -0,0 +1,34 @@ +{{#if model}} +
{{i18n 'admin.api.key'}} | +{{i18n 'admin.api.user'}} | ++ |
---|---|---|
{{k.key}} | ++ {{#if k.user}} + {{#link-to 'adminUser' k.user}} + {{avatar k.user imageSize="small"}} + {{/link-to}} + {{else}} + {{i18n 'admin.api.all_users'}} + {{/if}} + | ++ {{d-button action="regenerateKey" actionParam=k icon="undo" label='admin.api.regenerate'}} + {{d-button action="revokeKey" actionParam=k icon="times" label='admin.api.revoke'}} + | +
{{i18n 'admin.api.none'}}
+{{/if}} + +{{#unless hasMasterKey}} + +{{/unless }} + diff --git a/app/assets/javascripts/admin/templates/api.hbs b/app/assets/javascripts/admin/templates/api.hbs index 0f2e65b89c3..f3407fe0ccf 100644 --- a/app/assets/javascripts/admin/templates/api.hbs +++ b/app/assets/javascripts/admin/templates/api.hbs @@ -1,33 +1,10 @@ -{{#if model}} -{{i18n 'admin.api.key'}} | -{{i18n 'admin.api.user'}} | -- |
---|---|---|
{{k.key}} | -- {{#if k.user}} - {{#link-to 'adminUser' k.user}} - {{avatar k.user imageSize="small"}} - {{/link-to}} - {{else}} - {{i18n 'admin.api.all_users'}} - {{/if}} - | -- - - | -
{{i18n 'admin.api.none'}}
-{{/if}} +