Skip to content

Update this app to latest Ember and Ember Data #763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2021
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# misc
/coverage/
!.*
.eslintcache

# ember-try
/.node_modules.ember-try/
Expand Down
42 changes: 25 additions & 17 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,38 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
legacyDecorators: true,
},
},
plugins: [
'ember'
],
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
'plugin:ember/recommended',
'plugin:prettier/recommended',
],
env: {
browser: true
browser: true,
},
rules: {
'ember/no-jquery': 'off',
'no-console': 'off',
'ember/no-new-mixins': 'off'
'ember/no-new-mixins': 'off',
'ember/no-mixins': 'off',
'ember/native-classes': 'off',
'ember/require-tagless-components': 'off',
'ember/no-test-this-render': 'off',
'ember/no-classic-classes': 'off',
'ember/no-get': 'off',
'ember/no-actions-hash': 'off',
'ember/no-classic-components': 'off',
'ember/no-private-routing-service': 'off',
},
overrides: [
// node files
{
files: [
'.eslintrc.js',
'.prettierrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'testem.js',
Expand All @@ -43,20 +52,19 @@ module.exports = {
excludedFiles: ['config/deprecation-workflow.js'],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2017
ecmaVersion: 2017,
},
env: {
browser: false,
node: true
node: true,
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here

extends: ['plugin:node/recommended'],
rules: {
// this can be removed once the following is fixed
// https://github.com/mysticatea/eslint-plugin-node/issues/77
'node/no-unpublished-require': 'off'
})
}
]
'node/no-unpublished-require': 'off',
},
},
],
};
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ jobs:
if: steps.cache-dependencies.outputs.cache-hit != 'true'

- name: Test
uses: percy/[email protected]
with:
custom-command: yarn test:ember
env:
PERCY_PARALLEL_NONCE: ${{ env.PERCY_PARALLEL_NONCE }}
PERCY_PARALLEL_TOTAL: ${{ env.PERCY_PARALLEL_TOTAL }}
PERCY_TOKEN: 5ad6687f6b1ad3dec2b964f94d3d59ff3880baccf1492c0663e85c1ce79c1a52
run: yarn run percy exec -- yarn test:ember
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ terraform.tfstate.backup
/.env*
/.pnp*
/.sass-cache
/.eslintcache
/connect.lock
/coverage/
/libpeerconnection.log
Expand Down
21 changes: 21 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.eslintcache

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
singleQuote: true,
};
6 changes: 4 additions & 2 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = {
'no-implicit-this': false,
'no-curly-component-invocation': false,
'no-action': false,
quotes: false
}
quotes: false,
'no-link-to-positional-params': false,
'require-input-label': false,
},
};
16 changes: 10 additions & 6 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { pluralize } from 'ember-inflector';
import { isBlank } from '@ember/utils';

export default JSONAPIAdapter.extend({

host: ENV.API_HOST,

currentProject: '',
Expand All @@ -26,7 +25,9 @@ export default JSONAPIAdapter.extend({
}
return; // return undefined so auto determinated
},
shouldBackgroundReloadAll() { return false; },
shouldBackgroundReloadAll() {
return false;
},
shouldBackgroundReloadRecord(store, { modelName, id }) {
let key = `${modelName}-${id}`;
let hasId = this.ids[key];
Expand Down Expand Up @@ -59,14 +60,18 @@ export default JSONAPIAdapter.extend({

if (typeof revId !== 'undefined') {
let encodedRevId = encodeURIComponent(revId);
url = `json-docs/${projectName}/${version}/${pluralize(modelNameToUse)}/${encodedRevId}`;
url = `json-docs/${projectName}/${version}/${pluralize(
modelNameToUse
)}/${encodedRevId}`;
} else {
throw new Error('Documentation item not found');
}
} else if (modelName === 'missing') {
let version = this.get('projectService.version');
let revId = this.metaStore.getRevId(projectName, version, modelName, id);
url = `json-docs/${projectName}/${version}/${pluralize(modelName)}/${revId}`;
url = `json-docs/${projectName}/${version}/${pluralize(
modelName
)}/${revId}`;
} else if (modelName === 'project') {
this.currentProject = id;
url = `rev-index/${id}`;
Expand All @@ -82,6 +87,5 @@ export default JSONAPIAdapter.extend({
let response = await fetch(url);
let json = await response.json();
return json;
}

},
});
2 changes: 1 addition & 1 deletion app/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
import config from 'ember-api-docs/config/environment';

export default class App extends Application {
modulePrefix = config.modulePrefix;
Expand Down
92 changes: 55 additions & 37 deletions app/components/api-index-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,78 @@ import { computed } from '@ember/object';
import Component from '@ember/component';
import sortBy from 'lodash.sortby';

const filterDataComputedParams = 'filterData.{showInherited,showProtected,showPrivate,showDeprecated}';
const filterDataComputedParams =
'filterData.{showInherited,showProtected,showPrivate,showDeprecated}';

export default Component.extend({
classNames: ['api-index-filter'],

filteredMethods: computed('model.methods.[]', filterDataComputedParams,
function() {
filteredMethods: computed(
'model.methods.[]',
filterDataComputedParams,
function () {
return this.filterItems('methods');
}),
}
),

filteredEvents: computed('model.events.[]', filterDataComputedParams,
function() {
filteredEvents: computed(
'model.events.[]',
filterDataComputedParams,
function () {
return this.filterItems('events');
}),
}
),

filteredProperties: computed('model.properties.[]', filterDataComputedParams,
function() {
filteredProperties: computed(
'model.properties.[]',
filterDataComputedParams,
function () {
return this.filterItems('properties');
}),
}
),

filterItems(itemType) {
let items = this.getWithDefault(`model.${itemType}`, []);
let items =
this.get(`model.${itemType}`) === undefined
? []
: this.get(`model.${itemType}`);
if (!this.get('filterData.showInherited')) {
items = items.filter(item => item.inherited !== true);
items = items.filter((item) => item.inherited !== true);
}
if (!this.get('filterData.showProtected')) {
items = items.filter(item => item.access !== 'protected');
items = items.filter((item) => item.access !== 'protected');
}
if (!this.get('filterData.showPrivate')) {
items = items.filter(item => item.access !== 'private');
items = items.filter((item) => item.access !== 'private');
}
if (!this.get('filterData.showDeprecated')) {
items = items.filter(item => item.deprecated !== true);
items = items.filter((item) => item.deprecated !== true);
}

let sortedItems = sortBy(items, (item => item.name));
let sortedItems = sortBy(items, (item) => item.name);
return this.filterMultipleInheritance(sortedItems);
},

filteredData: computed('filteredMethods', 'filteredProperties', 'filteredEvents', function() {
return {
methods: this.filteredMethods,
properties: this.filteredProperties,
events: this.filteredEvents
};
}),
filteredData: computed(
'filteredMethods',
'filteredProperties',
'filteredEvents',
function () {
return {
methods: this.filteredMethods,
properties: this.filteredProperties,
events: this.filteredEvents,
};
}
),

/**
* Returns an array where duplicate methods (by name) are removed.
* The docs for the nearest inheritance are typically more helpful to users,
* so in cases of duplicates, "more local" is preferred.
* Without this, multiple entries for some methods will show up.
* @method filterMultipleInheritance
*/
* Returns an array where duplicate methods (by name) are removed.
* The docs for the nearest inheritance are typically more helpful to users,
* so in cases of duplicates, "more local" is preferred.
* Without this, multiple entries for some methods will show up.
* @method filterMultipleInheritance
*/
filterMultipleInheritance(items) {
let dedupedArray = [];
for (let i = 0; i < items.length; i++) {
Expand All @@ -67,7 +85,7 @@ export default Component.extend({
let nextItem = items[i + 1];
if (currentItem.name === nextItem.name) {
// if the method would be listed twice, find the more local documentation
let mostLocal = this.findMostLocal(currentItem, nextItem)
let mostLocal = this.findMostLocal(currentItem, nextItem);
dedupedArray.push(mostLocal);
i += 1; // skip the next item with duplicate name
} else {
Expand All @@ -78,11 +96,11 @@ export default Component.extend({
return dedupedArray;
},
/**
* Returns whichever item is most local.
* What is "most local" is determined by looking at the file path for the
* method, the file path for the class being viewed, and the parent if needed.
* @method findMostLocal
*/
* Returns whichever item is most local.
* What is "most local" is determined by looking at the file path for the
* method, the file path for the class being viewed, and the parent if needed.
* @method findMostLocal
*/
findMostLocal(currentItem, nextItem) {
let currentScope = this.get('model.file');
let parentClassScope = this.get('model.parentClass.file');
Expand All @@ -96,5 +114,5 @@ export default Component.extend({
// otherwise, the next item must be "more local"
return nextItem;
}
}
})
},
});
11 changes: 5 additions & 6 deletions app/components/api-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,29 @@ import { computed } from '@ember/object';
import Component from '@ember/component';

export default Component.extend({

sections: computed('itemData.{methods,properties,events}', function () {
return [
{
title: 'Methods',
tab: 'methods',
items: this.get('itemData.methods'),
class: 'spec-method-list',
routeSuffix: '.methods.method'
routeSuffix: '.methods.method',
},
{
title: 'Properties',
tab: 'properties',
items: this.get('itemData.properties'),
class: 'spec-property-list',
routeSuffix: '.properties.property'
routeSuffix: '.properties.property',
},
{
title: 'Events',
tab: 'events',
items: this.get('itemData.events'),
class: 'spec-event-list',
routeSuffix: '.events.event'
}
routeSuffix: '.events.event',
},
];
})
}),
});
7 changes: 5 additions & 2 deletions app/components/class-field-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export default Component.extend({
legacyModuleMappings: service(),

hasImportExample: computed('field.{name,class}', function () {
return this.legacyModuleMappings.hasFunctionMapping(this.get('field.name'), this.get('field.class'));
return this.legacyModuleMappings.hasFunctionMapping(
this.get('field.name'),
this.get('field.class')
);
}),

/**
Expand All @@ -15,5 +18,5 @@ export default Component.extend({
* @method updateAnchor
* @method fieldName String The name representing the field that was clicked.
*/
updateAnchor() {}
updateAnchor() {},
});
Loading