From 9571e209ec2472235912d436fc68912dab2999b5 Mon Sep 17 00:00:00 2001 From: Jared Galanis Date: Mon, 27 May 2024 06:28:18 -0400 Subject: [PATCH] refactor: remove deprecation ember-data:no-a-with-array-like --- app/components/found-manuscripts/index.js | 9 ++++----- app/components/submissions-repoid-cell/index.js | 3 +-- app/components/workflow-basics/index.js | 9 ++++----- app/components/workflow-files/index.js | 9 ++++----- app/components/workflow-grants/index.js | 3 +-- app/components/workflow-repositories/index.js | 3 +-- app/components/workflow-review/index.js | 5 ++--- app/controllers/grants/index.js | 3 +-- app/controllers/submissions/new.js | 3 +-- app/controllers/submissions/new/basics.js | 3 +-- app/deprecation-workflow.js | 1 - app/routes/grants/index.js | 3 +-- app/services/submission-handler.js | 4 ++-- app/services/workflow.js | 3 +-- 14 files changed, 24 insertions(+), 37 deletions(-) diff --git a/app/components/found-manuscripts/index.js b/app/components/found-manuscripts/index.js index 47537613..58f7467e 100644 --- a/app/components/found-manuscripts/index.js +++ b/app/components/found-manuscripts/index.js @@ -1,7 +1,6 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; -import { A } from '@ember/array'; import { task } from 'ember-concurrency-decorators'; import { action, get, set } from '@ember/object'; @@ -11,8 +10,8 @@ export default class FoundManuscriptsComponent extends Component { @service store; @service appStaticConfig; - @tracked foundManuscripts = A([]); - @tracked manuscriptsWithErrors = A([]); + @tracked foundManuscripts = []; + @tracked manuscriptsWithErrors = []; @tracked selectedManuscript = null; @tracked contactUrl; @@ -24,8 +23,8 @@ export default class FoundManuscriptsComponent extends Component { } get foundManuscriptsToDisplay() { - let prevFiles = this.args.previouslyUploadedFiles || A([]); - let newFiles = this.args.newFiles || A([]); + let prevFiles = this.args.previouslyUploadedFiles || []; + let newFiles = this.args.newFiles || []; const allFileNames = [...newFiles.toArray(), ...prevFiles.toArray()].map((file) => file.name); diff --git a/app/components/submissions-repoid-cell/index.js b/app/components/submissions-repoid-cell/index.js index 4d22189b..f7fdbe71 100644 --- a/app/components/submissions-repoid-cell/index.js +++ b/app/components/submissions-repoid-cell/index.js @@ -3,7 +3,6 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { action, get, set } from '@ember/object'; import { inject as service } from '@ember/service'; -import { A } from '@ember/array'; export default class SubmissionsRepoidCell extends Component { @service store; @@ -17,7 +16,7 @@ export default class SubmissionsRepoidCell extends Component { const publicationId = get(this, 'args.record.publication.id'); if (!publicationId) { if (!(get(this, 'isDestroyed') || get(this, 'isDestroying'))) { - set(this, 'repoCopies', A()); + set(this, 'repoCopies', []); return; } } diff --git a/app/components/workflow-basics/index.js b/app/components/workflow-basics/index.js index be05b574..ecc64821 100644 --- a/app/components/workflow-basics/index.js +++ b/app/components/workflow-basics/index.js @@ -4,7 +4,6 @@ import { tracked } from '@glimmer/tracking'; import { action, get, set } from '@ember/object'; import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; -import { A } from '@ember/array'; import { task, timeout } from 'ember-concurrency'; import { scheduleOnce } from '@ember/runloop'; import { dropTask } from 'ember-concurrency-decorators'; @@ -207,7 +206,7 @@ export default class WorkflowBasics extends Component { }); if (result.value) { - set(this, 'submission.grants', A()); + set(this, 'submission.grants', []); this.updateSubmitterModel(isProxySubmission, submitter); this.flashMessages.info('Submitter and related grants removed from submission.'); @@ -224,10 +223,10 @@ export default class WorkflowBasics extends Component { this.submission.submitterName = ''; if (isProxySubmission) { this.submission.submitter = submitter; - this.submission.preparers = A([get(this, 'currentUser.user')]); + this.submission.preparers = [this.currentUser.user]; } else { - this.submission.submitter = get(this, 'currentUser.user'); - this.submission.preparers = A(); + this.submission.submitter = this.currentUser.user; + this.submission.preparers = []; } } diff --git a/app/components/workflow-files/index.js b/app/components/workflow-files/index.js index 3964895f..51e58e95 100644 --- a/app/components/workflow-files/index.js +++ b/app/components/workflow-files/index.js @@ -2,7 +2,6 @@ import Component from '@glimmer/component'; import { action, get, set, computed } from '@ember/object'; import { inject as service } from '@ember/service'; -import { A } from '@ember/array'; import { task } from 'ember-concurrency-decorators'; import ENV from 'pass-ui/config/environment'; @@ -20,8 +19,8 @@ export default class WorkflowFiles extends Component { @computed('args.newFiles.[]', 'previouslyUploadedFiles.[]') get manuscript() { - const newFiles = get(this, 'args.newFiles') || A([]); - const prevFiles = get(this, 'args.previouslyUploadedFiles') || A([]); + const newFiles = get(this, 'args.newFiles') || []; + const prevFiles = get(this, 'args.previouslyUploadedFiles') || []; return [...prevFiles.toArray(), ...newFiles.toArray()].find((file) => file.fileRole === 'manuscript'); } @@ -31,8 +30,8 @@ export default class WorkflowFiles extends Component { */ @computed('args.newFiles.[]', 'previouslyUploadedFiles.[]') get supplementalFiles() { - const newFiles = get(this, 'args.newFiles') || A([]); - const prevFiles = get(this, 'args.previouslyUploadedFiles') || A([]); + const newFiles = get(this, 'args.newFiles') || []; + const prevFiles = get(this, 'args.previouslyUploadedFiles') || []; return [...prevFiles.toArray(), ...newFiles.toArray()].filter((file) => file.fileRole !== 'manuscript'); } diff --git a/app/components/workflow-grants/index.js b/app/components/workflow-grants/index.js index 7972fb23..62e3046e 100644 --- a/app/components/workflow-grants/index.js +++ b/app/components/workflow-grants/index.js @@ -2,7 +2,6 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { action, get, set } from '@ember/object'; -import { A } from '@ember/array'; import { inject as service } from '@ember/service'; import { task } from 'ember-concurrency'; @@ -28,7 +27,7 @@ export default class WorkflowGrants extends Component { @tracked submitterGrants = null; @tracked totalGrants = 0; /** Grants already attached to the submission on component init */ - @tracked _selectedGrants = A(); + @tracked _selectedGrants = []; @tracked preLoadedGrant = this.args.preLoadedGrant; @tracked grantColumns = [ { diff --git a/app/components/workflow-repositories/index.js b/app/components/workflow-repositories/index.js index 757e0751..c1d1e2f4 100644 --- a/app/components/workflow-repositories/index.js +++ b/app/components/workflow-repositories/index.js @@ -2,7 +2,6 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { action, get, set } from '@ember/object'; -import { A } from '@ember/array'; import { inject as service } from '@ember/service'; /** @@ -37,7 +36,7 @@ export default class WorkflowRepositories extends Component { @service submissionHandler; @service workflow; - @tracked addedRepos = A([]); + @tracked addedRepos = []; // Separate out repositories that PASS has some level of integration get requiredIntegratedRepos() { diff --git a/app/components/workflow-review/index.js b/app/components/workflow-review/index.js index 474e91f1..1932ffae 100644 --- a/app/components/workflow-review/index.js +++ b/app/components/workflow-review/index.js @@ -2,7 +2,6 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { action, get, set } from '@ember/object'; -import { A } from '@ember/array'; import { inject as service } from '@ember/service'; import { task } from 'ember-concurrency-decorators'; import { later } from '@ember/runloop'; @@ -23,12 +22,12 @@ export default class WorkflowReview extends Component { @service currentUser; @service flashMessages; - @tracked isValidated = A(); + @tracked isValidated = []; @tracked filesTemp = this.workflow.filesTemp; @tracked hasVisitedWeblink = false; get parsedFiles() { - let newArr = A(); + let newArr = []; if (this.filesTemp) { newArr.addObjects(this.filesTemp); } diff --git a/app/controllers/grants/index.js b/app/controllers/grants/index.js index 6ac29319..b1a83151 100644 --- a/app/controllers/grants/index.js +++ b/app/controllers/grants/index.js @@ -1,5 +1,4 @@ /* eslint-disable ember/classic-decorator-no-classic-methods */ -import { A } from '@ember/array'; import Controller from '@ember/controller'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; @@ -185,7 +184,7 @@ export default class GrantsIndexController extends Controller { const meta = data.meta; let results = data.map((grant) => ({ grant, - submissions: A(), + submissions: [], })); return { diff --git a/app/controllers/submissions/new.js b/app/controllers/submissions/new.js index 0ed6caaf..793c0ed6 100644 --- a/app/controllers/submissions/new.js +++ b/app/controllers/submissions/new.js @@ -1,7 +1,6 @@ /* eslint-disable ember/no-get, ember/classic-decorator-no-classic-methods */ import Controller from '@ember/controller'; import { tracked } from '@glimmer/tracking'; -import { A } from '@ember/array'; import { action, get, set } from '@ember/object'; import { inject as service } from '@ember/service'; @@ -105,7 +104,7 @@ export default class SubmissionsNew extends Controller { .then(() => { set(this, 'uploading', false); set(this, 'comment', ''); - set(this, 'workflow.filesTemp', A()); + set(this, 'workflow.filesTemp', []); this.router.transitionTo('thanks', { queryParams: { submission: get(sub, 'id') } }); }) .catch((error) => { diff --git a/app/controllers/submissions/new/basics.js b/app/controllers/submissions/new/basics.js index 74320c53..a6107c0a 100644 --- a/app/controllers/submissions/new/basics.js +++ b/app/controllers/submissions/new/basics.js @@ -2,7 +2,6 @@ import Controller, { inject as controller } from '@ember/controller'; import { tracked } from '@glimmer/tracking'; import { action, computed, get, set } from '@ember/object'; -import { A } from '@ember/array'; import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; import { task } from 'ember-concurrency-decorators'; @@ -26,7 +25,7 @@ export default class SubmissionsNewBasics extends Controller { @tracked submitterEmailError = false; get flaggedFields() { - let fields = A(); + let fields = []; if (this.titleError) fields.pushObject('title'); if (this.journalError) fields.pushObject('journal'); if (this.submitterEmailError) fields.pushObject('submitterEmail'); diff --git a/app/deprecation-workflow.js b/app/deprecation-workflow.js index 1cc5447e..6844bf95 100644 --- a/app/deprecation-workflow.js +++ b/app/deprecation-workflow.js @@ -4,6 +4,5 @@ setupDeprecationWorkflow({ workflow: [ { handler: 'silence', matchId: 'ember-data:deprecate-promise-many-array-behaviors' }, { handler: 'silence', matchId: 'ember-data:deprecate-array-like' }, - { handler: 'silence', matchId: 'ember-data:no-a-with-array-like' }, ], }); diff --git a/app/routes/grants/index.js b/app/routes/grants/index.js index 3e96efb6..01d002d2 100644 --- a/app/routes/grants/index.js +++ b/app/routes/grants/index.js @@ -1,5 +1,4 @@ import { service } from '@ember/service'; -import { A } from '@ember/array'; import CheckSessionRoute from '../check-session-route'; import { grantsIndexGrantQuery, grantsIndexSubmissionQuery } from '../../util/paginated-query'; @@ -44,7 +43,7 @@ export default class IndexRoute extends CheckSessionRoute { grants.forEach((grant) => { results.grantMap.push({ grant, - submissions: A(), + submissions: [], }); }); diff --git a/app/services/submission-handler.js b/app/services/submission-handler.js index 5d538a79..258a115a 100644 --- a/app/services/submission-handler.js +++ b/app/services/submission-handler.js @@ -1,5 +1,5 @@ /* eslint-disable ember/no-get */ -import { A, isArray } from '@ember/array'; +import { isArray } from '@ember/array'; import Service, { inject as service } from '@ember/service'; import ENV from 'pass-ui/config/environment'; import { task } from 'ember-concurrency-decorators'; @@ -22,7 +22,7 @@ export default class SubmissionHandlerService extends Service { * @returns EmberArray with repositories */ getRepositoriesFromGrants(grants) { - let result = A(); + let result = []; grants.forEach((grant) => { const directRepos = grant.get('directFunder.policy.repositories'); diff --git a/app/services/workflow.js b/app/services/workflow.js index 35f8fbf2..10710f51 100644 --- a/app/services/workflow.js +++ b/app/services/workflow.js @@ -1,5 +1,4 @@ /* eslint-disable ember/classic-decorator-no-classic-methods */ -import { A } from '@ember/array'; import Service from '@ember/service'; import { tracked } from '@glimmer/tracking'; @@ -20,7 +19,7 @@ export default class Workflow extends Service { @tracked filesTemp = []; @tracked defaultRepoLoaded = false; // you only want to load the default setting on first access, after that is should respect he user's choice. - @tracked addedGrants = A([]); + @tracked addedGrants = []; resetWorkflow() { this.setCurrentStep(0);