Skip to content
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

[ENG-6774] fix computing model / service names (and some citations, too!) #2437

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
22 changes: 12 additions & 10 deletions app/guid-node/addons/index/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,18 @@
</Button>
</span>
</div>
<div
data-test-configured-addon-root-folder
local-class='configured-addon-root-folder'
>
{{#if configuredAddon.rootFolder}}
{{configuredAddon.rootFolder}}
{{else}}
{{t 'addons.list.root-folder-not-set'}}
{{/if}}
</div>
{{#if configuredAddon.hasRootFolder}}
<div
data-test-configured-addon-root-folder
local-class='configured-addon-root-folder'
>
{{#if configuredAddon.rootFolder}}
{{configuredAddon.rootFolder}}
{{else}}
{{t 'addons.list.root-folder-not-set'}}
{{/if}}
</div>
{{/if}}
<div local-class='configured-addon-connected-to'>
{{t 'addons.list.connected-to-account'}} {{configuredAddon.baseAccount.displayName}}
</div>
Expand Down
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, sorry for the inconsistent naming here!

}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'authorized-computing-account': AuthorizedComputingAccount;
'authorized-computing-account': AuthorizedComputingAccountModel;
} // eslint-disable-line semi
}
4 changes: 4 additions & 0 deletions app/models/configured-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ export default class ConfiguredAddonModel extends Model {
// To be implemented in child classes
return;
}

get hasRootFolder() {
return true;
}
}
13 changes: 9 additions & 4 deletions app/models/configured-computing-addon.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
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;

get externalServiceId() {
return (this as ConfiguredComputingAddonModel).belongsTo('externalComputingService').id();
}

get hasRootFolder() {
return false;
}

}

declare module 'ember-data/types/registries/model' {
Expand Down
12 changes: 6 additions & 6 deletions app/models/user-reference.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Model, { AsyncHasMany, attr, hasMany } from '@ember-data/model';

import AuthorizedStorageAccountModel from './authorized-storage-account';
import AuthorizedCitationAccount from './authorized-citation-account';
import AuthorizedComputingAccount from './authorized-computing-account';
import AuthorizedCitationAccountModel from './authorized-citation-account';
import AuthorizedComputingAccountModel from './authorized-computing-account';
import ResourceReferenceModel from './resource-reference';

export default class UserReferenceModel extends Model {
Expand All @@ -12,12 +12,12 @@ export default class UserReferenceModel extends Model {
authorizedStorageAccounts!: AsyncHasMany<AuthorizedStorageAccountModel> & AuthorizedStorageAccountModel[];

@hasMany('authorized-citation-account', { inverse: 'accountOwner' })
authorizedCitationAccounts!: AsyncHasMany<AuthorizedCitationAccount> &
AuthorizedCitationAccount[];
authorizedCitationAccounts!: AsyncHasMany<AuthorizedCitationAccountModel> &
AuthorizedCitationAccountModel[];

@hasMany('authorized-computing-account', { inverse: 'accountOwner' })
authorizedComputingAccounts!: AsyncHasMany<AuthorizedComputingAccount>
& AuthorizedComputingAccount[];
authorizedComputingAccounts!: AsyncHasMany<AuthorizedComputingAccountModel>
& AuthorizedComputingAccountModel[];

@hasMany('resource-reference')
configuredResources!: AsyncHasMany<ResourceReferenceModel> & ResourceReferenceModel[];
Expand Down
19 changes: 11 additions & 8 deletions app/packages/addons-service/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -33,7 +33,7 @@ export type AllProviderTypes =
export type AllAuthorizedAccountTypes =
AuthorizedStorageAccountModel |
AuthorizedCitationAccountModel |
AuthorizedComputingAccount;
AuthorizedComputingAccountModel;
export type AllConfiguredAddonTypes =
ConfiguredStorageAddonModel |
ConfiguredCitationAddonModel |
Expand Down Expand Up @@ -208,7 +208,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
Expand Down Expand Up @@ -268,8 +268,9 @@ export default class Provider {
apiBaseUrl,
initiateOauth,
externalUserId: this.currentUser.user?.id,
authorizedCapabilities: ['ACCESS', 'UPDATE'],
scopes: [],
computingService: this.provider,
externalComputingService: this.provider,
accountOwner: this.userReference,
displayName,
});
Expand Down Expand Up @@ -325,13 +326,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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { TaskInstance } from 'ember-concurrency';

import { Item, ItemType } from 'ember-osf-web/models/addon-operation-invocation';
import AuthorizedAccountModel from 'ember-osf-web/models/authorized-account';
import AuthorizedComputingAccountModel from 'ember-osf-web/models/authorized-computing-account';
import ConfiguredAddonModel from 'ember-osf-web/models/configured-addon';
import ConfiguredComputingAddonModel from 'ember-osf-web/models/configured-computing-addon';


interface Args {
Expand All @@ -23,12 +25,20 @@ export default class ConfiguredAddonEdit extends Component<Args> {
itemType: ItemType.Folder,
};

get hasRootFolder() {
return !(
this.args.authorizedAccount instanceof AuthorizedComputingAccountModel
||
this.args.configuredAddon instanceof ConfiguredComputingAddonModel
);
}

get invalidDisplayName() {
return !this.displayName || this.displayName?.trim().length === 0;
}

get disableSave() {
return !this.selectedFolder || this.invalidDisplayName || this.args.onSave.isRunning;
return this.invalidDisplayName || this.args.onSave.isRunning || (this.hasRootFolder && !this.selectedFolder);
}

get onSaveArgs() {
Expand Down
Loading
Loading