diff --git a/app/models/authorized-computing-account.ts b/app/models/authorized-computing-account.ts index 10bc672ef94..97c212c4419 100644 --- a/app/models/authorized-computing-account.ts +++ b/app/models/authorized-computing-account.ts @@ -1,19 +1,19 @@ import { AsyncBelongsTo, belongsTo } from '@ember-data/model'; -import ExternalComputingService from './external-computing-service'; +import ExternalComputingServiceModel from './external-computing-service'; import AuthorizedAccountModel from './authorized-account'; import UserReferenceModel from './user-reference'; -export default class AuthorizedComputingAccount extends AuthorizedAccountModel { +export default class AuthorizedComputingAccountModel extends AuthorizedAccountModel { @belongsTo('user-reference', { inverse: 'authorizedComputingAccounts' }) accountOwner!: AsyncBelongsTo & UserReferenceModel; @belongsTo('external-computing-service') - computingService!: AsyncBelongsTo & ExternalComputingService; + externalComputingService!: AsyncBelongsTo & ExternalComputingServiceModel; } declare module 'ember-data/types/registries/model' { export default interface ModelRegistry { - 'authorized-computing-account': AuthorizedComputingAccount; + 'authorized-computing-account': AuthorizedComputingAccountModel; } // eslint-disable-line semi } diff --git a/app/models/configured-computing-addon.ts b/app/models/configured-computing-addon.ts index 6009a14ba29..6c062e10fbf 100644 --- a/app/models/configured-computing-addon.ts +++ b/app/models/configured-computing-addon.ts @@ -1,16 +1,16 @@ import { AsyncBelongsTo, belongsTo } from '@ember-data/model'; import ResourceReferenceModel from 'ember-osf-web/models/resource-reference'; -import AuthorizedComputingAccount from './authorized-computing-account'; -import ExternalComputingService from './external-computing-service'; +import AuthorizedComputingAccountModel from './authorized-computing-account'; +import ExternalComputingServiceModel from './external-computing-service'; import ConfiguredAddonModel from './configured-addon'; export default class ConfiguredComputingAddonModel extends ConfiguredAddonModel { @belongsTo('external-computing-service', { inverse: null }) - externalComputingService!: AsyncBelongsTo & ExternalComputingService; + externalComputingService!: AsyncBelongsTo & ExternalComputingServiceModel; @belongsTo('authorized-computing-account') - baseAccount!: AsyncBelongsTo & AuthorizedComputingAccount; + baseAccount!: AsyncBelongsTo & AuthorizedComputingAccountModel; @belongsTo('resource-reference', { inverse: 'configuredComputingAddons' }) authorizedResource!: AsyncBelongsTo & ResourceReferenceModel; diff --git a/app/models/user-reference.ts b/app/models/user-reference.ts index cfbd69b4997..4cf3d589ee6 100644 --- a/app/models/user-reference.ts +++ b/app/models/user-reference.ts @@ -2,7 +2,7 @@ import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model'; import AuthorizedStorageAccountModel from './authorized-storage-account'; import AuthorizedCitationAccountModel from './authorized-citation-account'; -import AuthorizedComputingAccount from './authorized-computing-account'; +import AuthorizedComputingAccountModel from './authorized-computing-account'; import ResourceReferenceModel from './resource-reference'; export default class UserReferenceModel extends Model { @@ -16,8 +16,8 @@ export default class UserReferenceModel extends Model { AuthorizedCitationAccountModel[]; @hasMany('authorized-computing-account', { inverse: 'accountOwner' }) - authorizedComputingAccounts!: AsyncHasMany - & AuthorizedComputingAccount[]; + authorizedComputingAccounts!: AsyncHasMany + & AuthorizedComputingAccountModel[]; @hasMany('resource-reference') configuredResources!: AsyncHasMany & ResourceReferenceModel[]; diff --git a/app/packages/addons-service/provider.ts b/app/packages/addons-service/provider.ts index 58ba093b452..749c7e00006 100644 --- a/app/packages/addons-service/provider.ts +++ b/app/packages/addons-service/provider.ts @@ -19,7 +19,7 @@ import ConfiguredComputingAddonModel from 'ember-osf-web/models/configured-compu import { AccountCreationArgs } from 'ember-osf-web/models/authorized-account'; import AuthorizedStorageAccountModel from 'ember-osf-web/models/authorized-storage-account'; import AuthorizedCitationAccountModel from 'ember-osf-web/models/authorized-citation-account'; -import AuthorizedComputingAccount from 'ember-osf-web/models/authorized-computing-account'; +import AuthorizedComputingAccountModel from 'ember-osf-web/models/authorized-computing-account'; import ExternalStorageServiceModel from 'ember-osf-web/models/external-storage-service'; import ExternalComputingServiceModel from 'ember-osf-web/models/external-computing-service'; import ExternalCitationServiceModel from 'ember-osf-web/models/external-citation-service'; @@ -33,7 +33,7 @@ export type AllProviderTypes = export type AllAuthorizedAccountTypes = AuthorizedStorageAccountModel | AuthorizedCitationAccountModel | - AuthorizedComputingAccount; + AuthorizedComputingAccountModel; export type AllConfiguredAddonTypes = ConfiguredStorageAddonModel | ConfiguredCitationAddonModel | @@ -184,7 +184,7 @@ export default class Provider { async getAuthorizedComputingAccounts() { const authorizedComputingAccounts = await this.userReference.authorizedComputingAccounts; this.authorizedAccounts = authorizedComputingAccounts - .filterBy('computingService.id', this.provider.id).toArray(); + .filterBy('externalComputingService.id', this.provider.id).toArray(); } @task @@ -245,7 +245,7 @@ export default class Provider { initiateOauth, externalUserId: this.currentUser.user?.id, scopes: [], - computingService: this.provider, + externalComputingService: this.provider, accountOwner: this.userReference, displayName, }); @@ -301,13 +301,15 @@ export default class Provider { @task @waitFor - private async createConfiguredComputingAddon(account: AuthorizedComputingAccount) { + private async createConfiguredComputingAddon(account: AuthorizedComputingAccountModel) { const configuredComputingAddon = this.store.createRecord('configured-computing-addon', { - rootFolder: '', - computingService: this.provider, + // rootFolder: '', + externalComputingService: this.provider, accountOwner: this.userReference, - authorizedResource: this.serviceNode, + // authorizedResource: this.serviceNode, + authorizedResourceUri: this.node!.links.iri, baseAccount: account, + connectedCapabilities: ['ACCESS', 'UPDATE'], }); return await configuredComputingAddon.save(); } diff --git a/lib/osf-components/addon/components/addons-service/user-addons-manager/component.ts b/lib/osf-components/addon/components/addons-service/user-addons-manager/component.ts index 8218b87c632..bdcdfe05231 100644 --- a/lib/osf-components/addon/components/addons-service/user-addons-manager/component.ts +++ b/lib/osf-components/addon/components/addons-service/user-addons-manager/component.ts @@ -16,7 +16,7 @@ import CurrentUserService from 'ember-osf-web/services/current-user'; import AuthorizedAccountModel, { AccountCreationArgs } from 'ember-osf-web/models/authorized-account'; import AuthorizedStorageAccountModel from 'ember-osf-web/models/authorized-storage-account'; import AuthorizedCitationAccountModel from 'ember-osf-web/models/authorized-citation-account'; -import AuthorizedComputingAccount from 'ember-osf-web/models/authorized-computing-account'; +import AuthorizedComputingAccountModel from 'ember-osf-web/models/authorized-computing-account'; import UserModel from 'ember-osf-web/models/user'; import ExternalStorageServiceModel from 'ember-osf-web/models/external-storage-service'; @@ -67,10 +67,10 @@ export default class UserAddonManagerComponent extends Component { }, [FilterTypes.CLOUD_COMPUTING]: { modelName: 'external-computing-service', - fetchProvidersTask: taskFor(this.getCloudComputingProviders), + fetchProvidersTask: taskFor(this.getComputingAddonProviders), list: A([]) as EmberArray, getAuthorizedAccountsTask: taskFor(this.getAuthorizedComputingAccounts), - authorizedAccounts: [] as AuthorizedComputingAccount[], + authorizedAccounts: [] as AuthorizedComputingAccountModel[], authorizedServiceIds: [] as string[], }, }; @@ -156,7 +156,7 @@ export default class UserAddonManagerComponent extends Component { providerId = (account as AuthorizedCitationAccountModel).externalCitationService.get('id'); break; case 'authorized-computing-account': - providerId = (account as AuthorizedComputingAccount).computingService.get('id'); + providerId = (account as AuthorizedComputingAccountModel).externalComputingService.get('id'); break; default: break; @@ -226,7 +226,7 @@ export default class UserAddonManagerComponent extends Component { const mappedObject = this.filterTypeMapper[FilterTypes.CLOUD_COMPUTING]; const accounts = (await userReference.authorizedComputingAccounts).toArray(); mappedObject.authorizedAccounts = accounts; - mappedObject.authorizedServiceIds = accounts.map(account => account.computingService.get('id')); + mappedObject.authorizedServiceIds = accounts.map(account => account.externalComputingService.get('id')); notifyPropertyChange(this, 'filterTypeMapper'); } @@ -250,11 +250,11 @@ export default class UserAddonManagerComponent extends Component { @task @waitFor - async getCloudComputingProviders() { + async getComputingAddonProviders() { const activeFilterObject = this.filterTypeMapper[FilterTypes.CLOUD_COMPUTING]; - const cloudComputingProviders = await taskFor(this.getExternalProviders) + const serviceComputingProviders = await taskFor(this.getExternalProviders) .perform(activeFilterObject.modelName) as ExternalComputingServiceModel[]; - activeFilterObject.list = cloudComputingProviders.sort(this.providerSorter) + activeFilterObject.list = serviceComputingProviders.sort(this.providerSorter) .map(provider => new Provider(provider, this.currentUser)); }