Merge branch 'main' into filterable-store-api-addon
This commit is contained in:
63 files changed
+739
-796
No files matched your search
@@ -2,7 +2,7 @@ import RESTAdapter from '@ember-data/adapter/rest';
|
||||
import { serializeIntoHash } from '@ember-data/adapter/-private';
|
||||
/* eslint-disable-next-line ember/no-mixins */
|
||||
import AdapterBuildURLMixin from '../mixins/adapter-build-url';
|
||||
import config from 'ember-get-config';
|
||||
import { getOwner } from '@ember/application';
|
||||
import { get } from '@ember/object';
|
||||
import { InvalidError } from '@ember-data/adapter/error';
|
||||
import { dasherize } from '@ember/string';
|
||||
@@ -44,19 +44,36 @@ export default class ApplicationAdapter extends RESTAdapter.extend(
|
||||
) {
|
||||
// =attributes
|
||||
|
||||
#host;
|
||||
#namespace;
|
||||
|
||||
/**
|
||||
* Sets host to the `api.host` string in the application's config,
|
||||
* if set.
|
||||
* @type {string}
|
||||
*/
|
||||
host = get(config, 'api.host');
|
||||
get host() {
|
||||
const config = getOwner(this).resolveRegistration('config:environment');
|
||||
return this.#host || get(config, 'api.host');
|
||||
}
|
||||
set host(value) {
|
||||
// Setting this value is useful for testing purposes.
|
||||
this.#host = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets namespace to the `api.namespace` string in the application's config,
|
||||
* if set.
|
||||
* @type {string}
|
||||
*/
|
||||
namespace = get(config, 'api.namespace');
|
||||
get namespace() {
|
||||
const config = getOwner(this).resolveRegistration('config:environment');
|
||||
return this.#namespace || get(config, 'api.namespace');
|
||||
}
|
||||
set namespace(value) {
|
||||
// Setting this value is useful for testing purposes.
|
||||
this.#namespace = value;
|
||||
}
|
||||
|
||||
// =methods
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import BaseModel from '../../models/base';
|
||||
import { attr } from '@ember-data/model';
|
||||
|
||||
/**
|
||||
* A managed group is a resource that represents a collection of accounts.
|
||||
*/
|
||||
export default class GeneratedManagedGroupModel extends BaseModel {
|
||||
// =attributes
|
||||
|
||||
@attr('string', {
|
||||
description: 'Optional name for identification purposes.',
|
||||
})
|
||||
name;
|
||||
|
||||
@attr('string', {
|
||||
description: 'Optional user-set description for identification purposes.',
|
||||
})
|
||||
description;
|
||||
|
||||
@attr('date', {
|
||||
description: 'The time this resource was created',
|
||||
readOnly: true,
|
||||
})
|
||||
created_time;
|
||||
|
||||
@attr('date', {
|
||||
description: 'The time this resource was last updated.',
|
||||
readOnly: true,
|
||||
})
|
||||
updated_time;
|
||||
|
||||
@attr('number', {
|
||||
description: 'Current version number of this resource.',
|
||||
})
|
||||
version;
|
||||
|
||||
@attr('string', {
|
||||
description: 'The type of this ManagedGroup.',
|
||||
})
|
||||
type;
|
||||
|
||||
@attr('string', {
|
||||
description:
|
||||
'The ID of the Auth Method that is associated with this ManagedGroup',
|
||||
})
|
||||
auth_method_id;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import Fragment from 'ember-data-model-fragments/fragment';
|
||||
import { attr } from '@ember-data/model';
|
||||
|
||||
export default class FragmentManagedGroupAttributesModel extends Fragment {
|
||||
// =attributes (OIDC)
|
||||
|
||||
@attr('string', {
|
||||
description:
|
||||
'The boolean expression filter to use to determine membership.',
|
||||
})
|
||||
filter;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import GeneratedManagedGroupModel from '../generated/models/managed-group';
|
||||
import { attr } from '@ember-data/model';
|
||||
import { fragment } from 'ember-data-model-fragments/attributes';
|
||||
import { A } from '@ember/array';
|
||||
|
||||
export default class ManagedGroupModel extends GeneratedManagedGroupModel {
|
||||
// =attributes
|
||||
/**
|
||||
* Members is read-only under normal circumstances. But members can
|
||||
* be persisted via calls to `addMembers()` or `removeMembers()`.
|
||||
*/
|
||||
@attr({
|
||||
readOnly: true,
|
||||
defaultValue: () => A(),
|
||||
emptyArrayIfMissing: true,
|
||||
})
|
||||
member_ids;
|
||||
|
||||
@fragment('fragment-managed-group-attributes', { defaultValue: {} })
|
||||
attributes;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import JSONSerializer from '@ember-data/serializer/json';
|
||||
|
||||
export default class FragmentManagedGroupAttributesSerializer extends JSONSerializer {
|
||||
/**
|
||||
* If an attribute is annotated as readOnly in the model, don't serialize it.
|
||||
* Otherwise delegate to default attribute serializer.
|
||||
* @override
|
||||
* @method serializeAttribute
|
||||
* @param {Snapshot} snapshot
|
||||
* @param {Object} json
|
||||
* @param {String} key
|
||||
* @param {Object} attribute
|
||||
*/
|
||||
serializeAttribute(snapshot, json, key, attribute) {
|
||||
const { type, options } = attribute;
|
||||
let value = super.serializeAttribute(...arguments);
|
||||
// Convert empty string to null.
|
||||
if (type === 'string' && json[key] === '') json[key] = null;
|
||||
// Do not serialize read-only attributes.
|
||||
if (options.readOnly) delete json[key];
|
||||
// Version is sent only if it has a non-nullish value
|
||||
if (key === 'version') {
|
||||
if (json[key] === null || json[key] === undefined) delete json[key];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default class ManagedGroupSerializer extends ApplicationSerializer {}
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'api/models/fragment-managed-group-attributes';
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'api/models/managed-group';
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'api/serializers/fragment-managed-group-attributes';
|
||||
@@ -8,7 +8,7 @@ import makeBooleanFilter from './helpers/bexpr-filter';
|
||||
const isTesting = config.environment === 'test';
|
||||
|
||||
export default function () {
|
||||
initializeMockIPC(this);
|
||||
initializeMockIPC(this, config);
|
||||
|
||||
// make this `http://localhost:8080`, for example, if your API is on a different server
|
||||
// this.urlPrefix = '';
|
||||
@@ -514,6 +514,14 @@ export default function () {
|
||||
this.del('/credential-libraries/:id');
|
||||
this.patch('/credential-libraries/:id');
|
||||
|
||||
// managed-groups
|
||||
this.get(
|
||||
'/managed-groups',
|
||||
({ managedGroups }, { queryParams: { auth_method_id: authMethodId } }) => {
|
||||
return managedGroups.where({ authMethodId });
|
||||
}
|
||||
);
|
||||
|
||||
/* Uncomment the following line and the Response import above
|
||||
* Then change the response code to simulate error responses.
|
||||
* this.get('/scopes', () => new Response(505));
|
||||
|
||||
@@ -23,15 +23,18 @@ export default factory.extend({
|
||||
type: (i) => types[i % types.length],
|
||||
|
||||
/**
|
||||
* Adds accounts (with associated users) to auth method.
|
||||
* Adds accounts (with associated users) to auth method and managed groups.
|
||||
*/
|
||||
withAccountsAndUsers: trait({
|
||||
withAccountsAndUsersAndManagedGroups: trait({
|
||||
afterCreate(authMethod, server) {
|
||||
const { scope, type } = authMethod;
|
||||
|
||||
server.createList('user', 5, { scope }).map((user) => {
|
||||
const { id } = server.create('account', { scope, type, authMethod });
|
||||
user.update({ accountIds: [id] });
|
||||
});
|
||||
|
||||
server.createList('managed-group', 2, { scope, authMethod });
|
||||
},
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import factory from '../generated/factories/managed-group';
|
||||
import permissions from '../helpers/permissions';
|
||||
|
||||
export default factory.extend({
|
||||
id: (i) => `managed-groups-id-${i}`,
|
||||
|
||||
authorized_actions: () =>
|
||||
permissions.authorizedActionsFor('managed-group') || [
|
||||
'no-op',
|
||||
'read',
|
||||
'update',
|
||||
'delete',
|
||||
],
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Factory } from 'ember-cli-mirage';
|
||||
import { random, date, datatype } from 'faker';
|
||||
|
||||
/**
|
||||
* GeneratedManagedGroupFactory
|
||||
* A managed group is a resource that represents a collection of accounts.
|
||||
*/
|
||||
export default Factory.extend({
|
||||
name: () => random.words(),
|
||||
description: () => random.words(),
|
||||
created_time: () => date.recent(),
|
||||
updated_time: () => date.recent(),
|
||||
version: () => datatype.number(),
|
||||
type: 'oidc',
|
||||
attributes: function () {
|
||||
switch (this.type) {
|
||||
case 'oidc':
|
||||
return {
|
||||
filter: random.words(),
|
||||
};
|
||||
default:
|
||||
return;
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { Model, belongsTo } from 'ember-cli-mirage';
|
||||
|
||||
export default Model.extend({
|
||||
scope: belongsTo(),
|
||||
authMethod: belongsTo(),
|
||||
});
|
||||
@@ -24,13 +24,13 @@ export default function (server) {
|
||||
'auth-method',
|
||||
1,
|
||||
{ scope: globalScope },
|
||||
'withAccountsAndUsers'
|
||||
'withAccountsAndUsersAndManagedGroups'
|
||||
);
|
||||
const orgAuthMethods = server.createList(
|
||||
'auth-method',
|
||||
3,
|
||||
{ scope: orgScope },
|
||||
'withAccountsAndUsers'
|
||||
'withAccountsAndUsersAndManagedGroups'
|
||||
);
|
||||
// Assign primary auth methods per scope
|
||||
// TODO make this generic
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import config from 'ember-get-config';
|
||||
import { datatype } from 'faker';
|
||||
|
||||
const isTesting = config.environment === 'test';
|
||||
export default function initializeMockIPC(server, config) {
|
||||
const isTesting = config.environment === 'test';
|
||||
|
||||
export default function initializeMockIPC(server) {
|
||||
/**
|
||||
* We strive to make this application runnable in a regular web browser, since
|
||||
* it is a convenient environment for development and testing. But only an
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
modelName: 'managed-group',
|
||||
|
||||
_hashForModel(model) {
|
||||
const json = ApplicationSerializer.prototype._hashForModel.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
json.auth_method_id = model.authMethodId;
|
||||
return json;
|
||||
},
|
||||
});
|
||||
@@ -51,7 +51,6 @@
|
||||
"ember-copy": "^2.0.1",
|
||||
"ember-disable-prototype-extensions": "^1.1.3",
|
||||
"ember-export-application-global": "^2.0.1",
|
||||
"ember-get-config": "^0.3.0",
|
||||
"ember-load-initializers": "^2.1.2",
|
||||
"ember-maybe-import-regenerator": "^1.0.0",
|
||||
"ember-page-title": "^6.2.2",
|
||||
|
||||
@@ -6,13 +6,6 @@ const browsers = [
|
||||
'last 1 Safari versions',
|
||||
];
|
||||
|
||||
const isCI = Boolean(process.env.CI);
|
||||
const isProduction = process.env.EMBER_ENV === 'production';
|
||||
|
||||
if (isCI || isProduction) {
|
||||
browsers.push('ie 11');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
browsers,
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import config from 'ember-get-config';
|
||||
import RESTAdapter from '@ember-data/adapter/rest';
|
||||
import { InvalidError } from '@ember-data/adapter/error';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
@@ -10,6 +9,12 @@ module('Unit | Adapter | application', function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let config;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
config = this.owner.resolveRegistration('config:environment');
|
||||
});
|
||||
|
||||
test('its namespace is equal to the configured namespace', function (assert) {
|
||||
assert.expect(2);
|
||||
const adapter = this.owner.lookup('adapter:application');
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Model | fragment managed group attributes', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('fragment-managed-group-attributes', {});
|
||||
assert.ok(model);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Model | managed group', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let store = this.owner.lookup('service:store');
|
||||
let model = store.createRecord('managed-group', {});
|
||||
assert.ok(model);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module(
|
||||
'Unit | Serializer | fragment managed groups attributes',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it serializes empty string to null', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const record = store.createRecord('fragment-managed-group-attributes', {
|
||||
filter: '',
|
||||
});
|
||||
const serializedRecord = record.serialize();
|
||||
assert.deepEqual(serializedRecord, {
|
||||
filter: null,
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,161 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Serializer | Managed group', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it serializes correctly on create with no filter provided', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('managed-group');
|
||||
const record = store.createRecord('managed-group', {
|
||||
name: 'Group',
|
||||
description: 'Description',
|
||||
member_ids: ['1', '2'],
|
||||
version: 1,
|
||||
auth_method_id: '1234',
|
||||
});
|
||||
const snapshot = record._createSnapshot();
|
||||
snapshot.adapterOptions = {};
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
name: 'Group',
|
||||
description: 'Description',
|
||||
version: 1,
|
||||
auth_method_id: '1234',
|
||||
type: null,
|
||||
attributes: {
|
||||
filter: null,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('it serializes correctly on create when filter provided', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('managed-group');
|
||||
const record = store.createRecord('managed-group', {
|
||||
name: 'Group',
|
||||
description: 'Description',
|
||||
member_ids: ['1', '2'],
|
||||
version: 1,
|
||||
auth_method_id: '1234',
|
||||
type: 'oidc',
|
||||
attributes: {
|
||||
filter: 'key=value',
|
||||
},
|
||||
});
|
||||
const snapshot = record._createSnapshot();
|
||||
snapshot.adapterOptions = {};
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
name: 'Group',
|
||||
description: 'Description',
|
||||
version: 1,
|
||||
auth_method_id: '1234',
|
||||
type: 'oidc',
|
||||
attributes: {
|
||||
filter: 'key=value',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('it does not serialize version when it has null or undefined value', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('managed-group');
|
||||
store.push({
|
||||
data: {
|
||||
id: '1',
|
||||
type: 'managed-group',
|
||||
attributes: {
|
||||
name: 'Group Test',
|
||||
description: 'Description for the test',
|
||||
member_ids: ['1', '2'],
|
||||
version: undefined,
|
||||
auth_method_id: '1234',
|
||||
type: 'oidc',
|
||||
attributes: {
|
||||
filter: 'key=value',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const record = store.peekRecord('managed-group', '1');
|
||||
const snapshot = record._createSnapshot();
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
name: 'Group Test',
|
||||
description: 'Description for the test',
|
||||
auth_method_id: '1234',
|
||||
type: 'oidc',
|
||||
attributes: {
|
||||
filter: 'key=value',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('it does not serialize readOnly attributes', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('managed-group');
|
||||
const record = store.createRecord('managed-group', {
|
||||
name: 'Group',
|
||||
description: 'Description',
|
||||
version: 1,
|
||||
auth_method_id: '1234',
|
||||
member_ids: ['1', '2'],
|
||||
created_time: Date.now(),
|
||||
updated_time: Date.now(),
|
||||
});
|
||||
const snapshot = record._createSnapshot();
|
||||
snapshot.adapterOptions = {};
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
name: 'Group',
|
||||
description: 'Description',
|
||||
version: 1,
|
||||
auth_method_id: '1234',
|
||||
type: null,
|
||||
attributes: {
|
||||
filter: null,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('it serializes correctly on update', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('managed-group');
|
||||
store.push({
|
||||
data: {
|
||||
id: '1',
|
||||
type: 'managed-group',
|
||||
attributes: {
|
||||
name: 'Group Test',
|
||||
description: 'Description for the test',
|
||||
member_ids: ['1', '2'],
|
||||
version: 1,
|
||||
auth_method_id: '1234',
|
||||
type: 'oidc',
|
||||
attributes: {
|
||||
filter: 'key=value',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const record = store.peekRecord('managed-group', '1');
|
||||
const snapshot = record._createSnapshot();
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
name: 'Group Test',
|
||||
description: 'Description for the test',
|
||||
version: 1,
|
||||
auth_method_id: '1234',
|
||||
type: 'oidc',
|
||||
attributes: {
|
||||
filter: 'key=value',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -6,13 +6,6 @@ const browsers = [
|
||||
'last 1 Safari versions',
|
||||
];
|
||||
|
||||
const isCI = Boolean(process.env.CI);
|
||||
const isProduction = process.env.EMBER_ENV === 'production';
|
||||
|
||||
if (isCI || isProduction) {
|
||||
browsers.push('ie 11');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
browsers,
|
||||
};
|
||||
@@ -1,6 +1,9 @@
|
||||
import { helper } from '@ember/component/helper';
|
||||
import config from 'ember-get-config';
|
||||
import Helper from '@ember/component/helper';
|
||||
import { getOwner } from '@ember/application';
|
||||
|
||||
export default helper(function appName() {
|
||||
return config.appName;
|
||||
});
|
||||
export default class extends Helper {
|
||||
compute() {
|
||||
const config = getOwner(this).resolveRegistration('config:environment');
|
||||
return config.appName;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
import { helper } from '@ember/component/helper';
|
||||
import config from 'ember-get-config';
|
||||
import Helper from '@ember/component/helper';
|
||||
import { getOwner } from '@ember/application';
|
||||
|
||||
export default helper(function companyCopyright() {
|
||||
const currentYear = new Date().getFullYear();
|
||||
return `© ${currentYear} ${config.companyName}`;
|
||||
});
|
||||
export default class extends Helper {
|
||||
compute() {
|
||||
const config = getOwner(this).resolveRegistration('config:environment');
|
||||
const currentYear = new Date().getFullYear();
|
||||
return `© ${currentYear} ${config.companyName}`;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
import { helper } from '@ember/component/helper';
|
||||
import config from 'ember-get-config';
|
||||
import Helper from '@ember/component/helper';
|
||||
import { getOwner } from '@ember/application';
|
||||
|
||||
export default helper(function companyName() {
|
||||
return config.companyName;
|
||||
});
|
||||
export default class extends Helper {
|
||||
compute() {
|
||||
const config = getOwner(this).resolveRegistration('config:environment');
|
||||
return config.companyName;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,23 @@
|
||||
import { helper } from '@ember/component/helper';
|
||||
import Helper from '@ember/component/helper';
|
||||
import { getOwner } from '@ember/application';
|
||||
import { assert } from '@ember/debug';
|
||||
import config from 'ember-get-config';
|
||||
|
||||
export default helper(function docUrl(params /*, hash*/) {
|
||||
const baseURL = config.documentation.baseURL;
|
||||
const docKey = params[0] || '';
|
||||
const configuredPath = config.documentation.topics[docKey];
|
||||
if (docKey) {
|
||||
assert(
|
||||
`
|
||||
Documentation for "${docKey}" could not be found. Please ensure that
|
||||
this key exists under "documentation" in your app config.
|
||||
`,
|
||||
configuredPath
|
||||
);
|
||||
export default class extends Helper {
|
||||
compute(params) {
|
||||
const config = getOwner(this).resolveRegistration('config:environment');
|
||||
const baseURL = config.documentation.baseURL;
|
||||
const docKey = params[0] || '';
|
||||
const configuredPath = config.documentation.topics[docKey];
|
||||
if (docKey) {
|
||||
assert(
|
||||
`
|
||||
Documentation for "${docKey}" could not be found. Please ensure that
|
||||
this key exists under "documentation" in your app config.
|
||||
`,
|
||||
configuredPath
|
||||
);
|
||||
}
|
||||
const path = configuredPath || '';
|
||||
return `${baseURL}${path}`;
|
||||
}
|
||||
const path = configuredPath || '';
|
||||
return `${baseURL}${path}`;
|
||||
});
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
import { registerDeprecationHandler } from '@ember/debug';
|
||||
import config from 'ember-get-config';
|
||||
|
||||
const isTesting = config.environment === 'test';
|
||||
|
||||
export function initialize(/* application */) {
|
||||
export function initialize(application) {
|
||||
const config = application.resolveRegistration('config:environment');
|
||||
const isTesting = config.environment === 'test';
|
||||
if (isTesting) {
|
||||
// Disable all deprecations for now in tests.
|
||||
registerDeprecationHandler((/*message, options, next*/) => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { filterBy } from '@ember/object/computed';
|
||||
import { A } from '@ember/array';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { defer, resolve } from 'rsvp';
|
||||
import config from 'ember-get-config';
|
||||
import { getOwner } from '@ember/application';
|
||||
|
||||
/**
|
||||
* A simple service that emits Confirmation instances and
|
||||
@@ -17,13 +17,21 @@ import config from 'ember-get-config';
|
||||
export default class ConfirmationsService extends Service {
|
||||
// =attributes
|
||||
|
||||
#enabled;
|
||||
|
||||
/**
|
||||
* When the confirm service is disabled, it always returns resolving promises.
|
||||
* By default the service is enabled but it is useful to disable it for test
|
||||
* purposes.
|
||||
* @type {boolean}
|
||||
*/
|
||||
enabled = config.enableConfirmService ?? true;
|
||||
get enabled() {
|
||||
const config = getOwner(this).resolveRegistration('config:environment');
|
||||
return this.#enabled ?? config.enableConfirmService ?? true;
|
||||
}
|
||||
set enabled(value) {
|
||||
this.#enabled = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {Array}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"ember-cli-babel": "^7.26.6",
|
||||
"ember-cli-htmlbars": "^5.7.1",
|
||||
"ember-feature-flags": "^6.0.0",
|
||||
"ember-get-config": "^0.3.0",
|
||||
"ember-intl": "^5.7.0",
|
||||
"ember-loading": "^0.4.0",
|
||||
"ember-route-action-helper": "^2.0.8",
|
||||
|
||||
@@ -6,13 +6,6 @@ const browsers = [
|
||||
'last 1 Safari versions',
|
||||
];
|
||||
|
||||
const isCI = Boolean(process.env.CI);
|
||||
const isProduction = process.env.EMBER_ENV === 'production';
|
||||
|
||||
if (isCI || isProduction) {
|
||||
browsers.push('ie 11');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
browsers,
|
||||
};
|
||||
@@ -2,13 +2,13 @@ import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
import config from 'ember-get-config';
|
||||
|
||||
module('Integration | Helper | doc-url', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders a URL generated from the documentation config', async function (assert) {
|
||||
assert.expect(3);
|
||||
const config = this.owner.resolveRegistration('config:environment');
|
||||
const baseURL = config.documentation.baseURL;
|
||||
const path = config.documentation.topics.account;
|
||||
await render(hbs`{{doc-url 'account'}}`);
|
||||
@@ -19,7 +19,8 @@ module('Integration | Helper | doc-url', function (hooks) {
|
||||
|
||||
test('it throws an error if the specified documentation path cannot be found', async function (assert) {
|
||||
assert.expect(2);
|
||||
const helper = this.owner.lookup('helper:doc-url');
|
||||
const Helper = this.owner.lookup('helper:doc-url');
|
||||
const helper = new Helper(this.owner);
|
||||
assert.ok(helper.compute(['account']), 'Specified document exists.');
|
||||
assert.throws(() => {
|
||||
helper.compute(['no.such.doc']);
|
||||
|
||||
@@ -9,6 +9,7 @@ module.exports = {
|
||||
'@storybook/addon-knobs',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-docs',
|
||||
'@storybook/addon-a11y',
|
||||
],
|
||||
emberOptions: {
|
||||
polyfills: [namedBlockPolyfill],
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
<span class="rose-button-wrapper">
|
||||
{{#if @iconLeft}}
|
||||
<Rose::Icon
|
||||
@name={{@iconLeft}}
|
||||
@size="medium"
|
||||
/>
|
||||
{{/if}}
|
||||
<LinkTo
|
||||
class="rose-link-button {{if @style (concat "rose-button-" @style)}} {{if @iconOnly 'has-icon-only'}} {{if @iconLeft 'has-icon-left'}} {{if @iconRight 'has-icon-right'}}"
|
||||
@route={{@route}}
|
||||
...attributes>
|
||||
<span class="rose-button-wrapper">
|
||||
{{#if @iconLeft}}
|
||||
<Rose::Icon
|
||||
@name={{@iconLeft}}
|
||||
@size="medium"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
<span class="rose-button-body">
|
||||
{{yield}}
|
||||
<span class="rose-button-body">
|
||||
{{yield}}
|
||||
</span>
|
||||
|
||||
{{#if @iconOnly}}
|
||||
<Rose::Icon
|
||||
@name={{@iconOnly}}
|
||||
@size="medium"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
{{#if @iconRight}}
|
||||
<Rose::Icon
|
||||
@name={{@iconRight}}
|
||||
@size="medium"
|
||||
/>
|
||||
{{/if}}
|
||||
</span>
|
||||
|
||||
{{#if @iconOnly}}
|
||||
<Rose::Icon
|
||||
@name={{@iconOnly}}
|
||||
@size="medium"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
{{#if @iconRight}}
|
||||
<Rose::Icon
|
||||
@name={{@iconRight}}
|
||||
@size="medium"
|
||||
/>
|
||||
{{/if}}
|
||||
</span>
|
||||
</LinkTo>
|
||||
@@ -1,26 +0,0 @@
|
||||
import LinkComponent from '@ember/routing/link-component';
|
||||
import layout from './index';
|
||||
import { computed } from '@ember/object';
|
||||
|
||||
/**
|
||||
* An achor element based on `rose-button` component styles
|
||||
* An empty model cannot be passed in to `link-to` component when a route
|
||||
* is defined. Thus, `link-to` component is used to generate this component.
|
||||
*
|
||||
* @example
|
||||
* <Rose::LinkButton @submit={{true}} @style="primary">Save</Rose::LinkButton>
|
||||
* <Rose::LinkButton @disabled={{true}} @style="secondary">Disabled</Rose::LinkButton>
|
||||
*/
|
||||
export default LinkComponent.extend({
|
||||
layout,
|
||||
classNames: ['rose-link-button'],
|
||||
classNameBindings: [
|
||||
'linkButtonStyle',
|
||||
'iconOnly:has-icon-only',
|
||||
'iconLeft:has-icon-left',
|
||||
'iconRight:has-icon-right',
|
||||
],
|
||||
linkButtonStyle: computed(function () {
|
||||
return this.style ? `rose-button-${this.style}` : '';
|
||||
}),
|
||||
});
|
||||
@@ -38,13 +38,13 @@
|
||||
"emberx-select": "github:adopted-ember-addons/emberx-select#bc5f774"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ember-get-config": "^0.3.0",
|
||||
"@babel/core": "^7.15.5",
|
||||
"@ember/optional-features": "^2.0.0",
|
||||
"@ember/test-helpers": "^2.4.2",
|
||||
"@glimmer/component": "^1.0.4",
|
||||
"@glimmer/tracking": "^1.0.4",
|
||||
"@hashicorp/flight-icons": "^1.0.0",
|
||||
"@storybook/addon-a11y": "^6.3.12",
|
||||
"@storybook/addon-actions": "^6.3.10",
|
||||
"@storybook/addon-docs": "^6.3.8",
|
||||
"@storybook/addon-knobs": "^6.3.1",
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { registerDeprecationHandler } from '@ember/debug';
|
||||
import config from 'ember-get-config';
|
||||
|
||||
const isTesting = config.environment === 'test';
|
||||
|
||||
export function initialize(/* application */) {
|
||||
export function initialize(application) {
|
||||
const config = application.resolveRegistration('config:environment');
|
||||
const isTesting = config.environment === 'test';
|
||||
if (isTesting) {
|
||||
// Disable all deprecations for now in tests.
|
||||
registerDeprecationHandler((/*message, options, next*/) => {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
border-radius: 4px;
|
||||
margin: 0 0.5rem 0.5rem 0 !important;
|
||||
box-shadow: 0px 3px 6px rgba(var(--stark-components), var(--opacity-3));
|
||||
list-style-type: none;
|
||||
|
||||
code {
|
||||
display: block !important;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
<Rose::LinkButton @route="index" @style="primary" @iconRight="flight-icons/svg/entry-point-16">
|
||||
Content
|
||||
</Rose::LinkButton>
|
||||
|
||||
<h2>Checkbox Group</h2>
|
||||
<Rose::Form::Checkbox::Group
|
||||
@items={{this.items}}
|
||||
|
||||
@@ -6,13 +6,6 @@ const browsers = [
|
||||
'last 1 Safari versions',
|
||||
];
|
||||
|
||||
const isCI = Boolean(process.env.CI);
|
||||
const isProduction = process.env.EMBER_ENV === 'production';
|
||||
|
||||
if (isCI || isProduction) {
|
||||
browsers.push('ie 11');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
browsers,
|
||||
};
|
||||
Reference in new issue
Block a user