Skip to content

Commit

Permalink
fix up/clean up computing model names
Browse files Browse the repository at this point in the history
  • Loading branch information
felliott committed Dec 26, 2024
1 parent 0eefe84 commit b475b5d
Showing 5 changed files with 29 additions and 27 deletions.
8 changes: 4 additions & 4 deletions app/models/authorized-computing-account.ts
Original file line number Diff line number Diff line change
@@ -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> & UserReferenceModel;

@belongsTo('external-computing-service')
computingService!: AsyncBelongsTo<ExternalComputingService> & ExternalComputingService;
externalComputingService!: AsyncBelongsTo<ExternalComputingServiceModel> & ExternalComputingServiceModel;
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'authorized-computing-account': AuthorizedComputingAccount;
'authorized-computing-account': AuthorizedComputingAccountModel;
} // eslint-disable-line semi
}
8 changes: 4 additions & 4 deletions app/models/configured-computing-addon.ts
Original file line number Diff line number Diff line change
@@ -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;
externalComputingService!: AsyncBelongsTo<ExternalComputingServiceModel> & ExternalComputingServiceModel;

@belongsTo('authorized-computing-account')
baseAccount!: AsyncBelongsTo<AuthorizedComputingAccount> & AuthorizedComputingAccount;
baseAccount!: AsyncBelongsTo<AuthorizedComputingAccountModel> & AuthorizedComputingAccountModel;

@belongsTo('resource-reference', { inverse: 'configuredComputingAddons' })
authorizedResource!: AsyncBelongsTo<ResourceReferenceModel> & ResourceReferenceModel;
6 changes: 3 additions & 3 deletions app/models/user-reference.ts
Original file line number Diff line number Diff line change
@@ -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>
& AuthorizedComputingAccount[];
authorizedComputingAccounts!: AsyncHasMany<AuthorizedComputingAccountModel>
& AuthorizedComputingAccountModel[];

@hasMany('resource-reference')
configuredResources!: AsyncHasMany<ResourceReferenceModel> & ResourceReferenceModel[];
18 changes: 10 additions & 8 deletions app/packages/addons-service/provider.ts
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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<Args> {
},
[FilterTypes.CLOUD_COMPUTING]: {
modelName: 'external-computing-service',
fetchProvidersTask: taskFor(this.getCloudComputingProviders),
fetchProvidersTask: taskFor(this.getComputingAddonProviders),
list: A([]) as EmberArray<Provider>,
getAuthorizedAccountsTask: taskFor(this.getAuthorizedComputingAccounts),
authorizedAccounts: [] as AuthorizedComputingAccount[],
authorizedAccounts: [] as AuthorizedComputingAccountModel[],
authorizedServiceIds: [] as string[],
},
};
@@ -156,7 +156,7 @@ export default class UserAddonManagerComponent extends Component<Args> {
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<Args> {
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<Args> {

@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));
}

0 comments on commit b475b5d

Please sign in to comment.