Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/routes/organizations/api-client-id.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class OrganizationsRegisterRoute extends Route {
}
@service('config-service') configService;

model() {
return {
registrationPaused: this.configService.CLIENT_ID_REGISTRATION_PAUSED,
};
}
}
3 changes: 2 additions & 1 deletion app/services/config-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import Service from '@ember/service';
import config from '../config/environment';

export default Service.extend({
API_URL: config.API_URL
API_URL: config.API_URL,
CLIENT_ID_REGISTRATION_PAUSED: config.CLIENT_ID_REGISTRATION_PAUSED
});
14 changes: 14 additions & 0 deletions app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,18 @@ $desktop-width: 1024px;
#clear-button {
background-color:$dark-grey;
color:$light-grey !important;
}

.alert-warning {
color: $black;

a {
color: $black;
text-decoration: underline;

&:hover,
&:focus {
color: $black;
}
}
}
22 changes: 18 additions & 4 deletions app/templates/organizations/api-client-id.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<div class="info-text">
<p>ROR API users are encouraged to register for a client ID and to include it in the header of API requests. Requests that include a header named client-id with a valid client ID as its value will receive a rate limit of 2,000 requests/5min. API requests that don't include a client ID will receive a rate limit of 50 requests/5min.</p>

<p>Please complete the form below to register for a ROR API client ID. Your client ID will be sent to the email address you provide.</p>
{{#unless this.model.registrationPaused}}
<p>Please complete the form below to register for a ROR API client ID. Your client ID will be sent to the email address you provide.</p>
{{/unless}}

<h2 class="h3">A few notes about ROR API client IDs:</h2>
<ul>
Expand All @@ -16,10 +18,22 @@
<li>For additional help obtaining or using a ROR API client ID contact <a href="mailto:support@ror.org">support@ror.org</a></li>
</ul>
</div>

{{#if this.model.registrationPaused}}
<BsAlert @dismissible={{false}} @type="warning">
<h2 class="alert-heading h5">Client ID registration is temporarily paused</h2>
<p>We've paused new ROR API client ID registrations while we make updates to the service. No rate limits
are currently enforced based on the presence or absence of a client ID, and none will be introduced before
registration is restored, so API usage is not affected by this pause.</p>
<p class="mb-0">
If you have questions or an urgent request, please contact <a href="mailto:support@ror.org">support@ror.org</a>.
Thanks for your patience!
</p>
</BsAlert>
{{else}}
<Organizations::ApiClientRegistrationForm />
{{/if}}
</div>
</div>
</div>
<div class="container">
<Organizations::ApiClientRegistrationForm />
</div>

1 change: 1 addition & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = function(environment) {
},

API_URL: process.env.API_URL || "https://api.ror.org/v2",
CLIENT_ID_REGISTRATION_PAUSED: true,
BASE_URL: process.env.BASE_URL || null,
SENTRY_DSN: process.env.SENTRY_DSN || null,
VERSION: pkg.version,
Expand Down
12 changes: 10 additions & 2 deletions tests/acceptance/a11y/api-client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ import a11yAudit from 'ember-a11y-testing/test-support/audit';
module('Acceptance | a11y | api-client-id', function (hooks) {
setupApplicationTest(hooks);

test('the API client registration page has no axe violations', async function (assert) {
test('the API client registration page has no axe violations when paused', async function (assert) {
this.owner.lookup('service:config-service').set('CLIENT_ID_REGISTRATION_PAUSED', true);
await visit('/api-client-id');
await a11yAudit();
assert.ok(true, 'no axe violations on /api-client-id');
assert.ok(true, 'no axe violations on /api-client-id when paused');
});

test('the API client registration page has no axe violations when registration is open', async function (assert) {
this.owner.lookup('service:config-service').set('CLIENT_ID_REGISTRATION_PAUSED', false);
await visit('/api-client-id');
await a11yAudit();
assert.ok(true, 'no axe violations on /api-client-id when registration is open');
});
});
28 changes: 28 additions & 0 deletions tests/acceptance/api-client-id-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { visit } from '@ember/test-helpers';

module('Acceptance | api-client-id', function (hooks) {
setupApplicationTest(hooks);

test('when registration is paused, the banner is shown and the form is not rendered', async function (assert) {
this.owner.lookup('service:config-service').set('CLIENT_ID_REGISTRATION_PAUSED', true);

await visit('/api-client-id');

assert.dom('.alert-warning').exists('paused banner is rendered');
assert.dom('.alert-warning').includesText('Client ID registration is temporarily paused');
assert.dom('.api-client-registration-form').doesNotExist('registration form is not rendered when paused');
assert.dom('button[type="submit"]').doesNotExist('submit button is not rendered when paused');
});

test('when registration is not paused, the form is rendered and the banner is not shown', async function (assert) {
this.owner.lookup('service:config-service').set('CLIENT_ID_REGISTRATION_PAUSED', false);

await visit('/api-client-id');

assert.dom('.alert-warning').doesNotExist('paused banner is not rendered');
assert.dom('.api-client-registration-form').exists('registration form is rendered');
assert.dom('button[type="submit"]').exists('submit button is rendered');
});
});
4 changes: 4 additions & 0 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Application from '../app';
import config from '../config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';

setApplication(Application.create(config.APP));

setup(QUnit.assert);

start();
Loading