diff --git a/app/guid-node/addons/index/template.hbs b/app/guid-node/addons/index/template.hbs index 700882ccea..65dd67e301 100644 --- a/app/guid-node/addons/index/template.hbs +++ b/app/guid-node/addons/index/template.hbs @@ -194,16 +194,18 @@ -
- {{#if configuredAddon.rootFolder}} - {{configuredAddon.rootFolder}} - {{else}} - {{t 'addons.list.root-folder-not-set'}} - {{/if}} -
+ {{#if configuredAddon.hasRootFolder}} +
+ {{#if configuredAddon.rootFolder}} + {{configuredAddon.rootFolder}} + {{else}} + {{t 'addons.list.root-folder-not-set'}} + {{/if}} +
+ {{/if}}
{{t 'addons.list.connected-to-account'}} {{configuredAddon.baseAccount.displayName}}
diff --git a/app/models/authorized-computing-account.ts b/app/models/authorized-computing-account.ts index 10bc672ef9..97c212c441 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-addon.ts b/app/models/configured-addon.ts index 176f620d7e..990bc3082d 100644 --- a/app/models/configured-addon.ts +++ b/app/models/configured-addon.ts @@ -37,4 +37,8 @@ export default class ConfiguredAddonModel extends Model { // To be implemented in child classes return; } + + get hasRootFolder() { + return true; + } } diff --git a/app/models/configured-computing-addon.ts b/app/models/configured-computing-addon.ts index 6009a14ba2..30c8b116fc 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; @@ -18,6 +18,11 @@ export default class ConfiguredComputingAddonModel extends ConfiguredAddonModel get externalServiceId() { return (this as ConfiguredComputingAddonModel).belongsTo('externalComputingService').id(); } + + get hasRootFolder() { + return false; + } + } declare module 'ember-data/types/registries/model' { diff --git a/app/models/user-reference.ts b/app/models/user-reference.ts index d4c8a546b2..4cf3d589ee 100644 --- a/app/models/user-reference.ts +++ b/app/models/user-reference.ts @@ -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 { @@ -12,12 +12,12 @@ export default class UserReferenceModel extends Model { authorizedStorageAccounts!: AsyncHasMany & AuthorizedStorageAccountModel[]; @hasMany('authorized-citation-account', { inverse: 'accountOwner' }) - authorizedCitationAccounts!: AsyncHasMany & - AuthorizedCitationAccount[]; + authorizedCitationAccounts!: AsyncHasMany & + 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 f3dd9c40ea..d9088459b3 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 | @@ -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 @@ -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, }); @@ -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(); } diff --git a/lib/osf-components/addon/components/addons-service/configured-addon-edit/component.ts b/lib/osf-components/addon/components/addons-service/configured-addon-edit/component.ts index ebf9a7a0f6..a05043e0ee 100644 --- a/lib/osf-components/addon/components/addons-service/configured-addon-edit/component.ts +++ b/lib/osf-components/addon/components/addons-service/configured-addon-edit/component.ts @@ -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 { @@ -23,12 +25,20 @@ export default class ConfiguredAddonEdit extends Component { 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() { diff --git a/lib/osf-components/addon/components/addons-service/configured-addon-edit/template.hbs b/lib/osf-components/addon/components/addons-service/configured-addon-edit/template.hbs index 9a0f280226..15313e433a 100644 --- a/lib/osf-components/addon/components/addons-service/configured-addon-edit/template.hbs +++ b/lib/osf-components/addon/components/addons-service/configured-addon-edit/template.hbs @@ -21,129 +21,131 @@ {{/if}} - -
- - {{#each fileManager.currentPath as |pathItem|}} + {{#if this.hasRootFolder }} + +
- {{/each}} -
- - - - - - - - - {{#if fileManager.isLoading}} - - {{else if fileManager.isError}} + {{#each fileManager.currentPath as |pathItem|}} + + {{/each}} + +
{{t 'addons.configure.table-headings.folder-name'}}{{t 'addons.configure.table-headings.select'}}
+ - + + - {{else}} - {{#each fileManager.currentItems as |folder|}} + + + {{#if fileManager.isLoading}} + + {{else if fileManager.isError}} - + + {{else}} + {{#each fileManager.currentItems as |folder|}} + + - + + {{else}} + + + + {{/each}} + {{#if fileManager.hasMore}} + + - - {{else}} - - - - {{/each}} - {{#if fileManager.hasMore}} - - - + {{t 'general.load_more'}} + + + + {{/if}} {{/if}} - {{/if}} - -
{{t 'addons.configure.error-loading-items'}}{{t 'addons.configure.table-headings.folder-name'}}{{t 'addons.configure.table-headings.select'}}
- {{#if folder.mayContainRootCandidates}} - {{t 'addons.configure.error-loading-items'}}
+ {{#if folder.mayContainRootCandidates}} + + {{else}} {{folder.itemName}} - - {{else}} - - - {{folder.itemName}} - - {{/if}} - - {{#if folder.canBeRoot}} - + + {{#if folder.canBeRoot}} + + {{/if}} +
{{t 'addons.configure.no-folders'}}
+
{{t 'addons.configure.no-folders'}}
- -
-
- - -
-
+ + + + {{/if}} +
+ + +
diff --git a/lib/osf-components/addon/components/addons-service/manager/component.ts b/lib/osf-components/addon/components/addons-service/manager/component.ts index 68a984d731..a131350599 100644 --- a/lib/osf-components/addon/components/addons-service/manager/component.ts +++ b/lib/osf-components/addon/components/addons-service/manager/component.ts @@ -77,7 +77,7 @@ export default class AddonsServiceManagerComponent extends Component { }, [FilterTypes.CLOUD_COMPUTING]: { modelName: 'external-computing-service', - task: taskFor(this.getCloudComputingProviders), + task: taskFor(this.getComputingAddonProviders), list: A([]), configuredAddons: A([]), }, @@ -323,7 +323,7 @@ export default class AddonsServiceManagerComponent extends Component { @task @waitFor - async getCloudComputingProviders() { + async getComputingAddonProviders() { const activeFilterObject = this.filterTypeMapper[FilterTypes.CLOUD_COMPUTING]; if (this.addonServiceNode) { @@ -331,10 +331,10 @@ export default class AddonsServiceManagerComponent extends Component { activeFilterObject.configuredAddons = A(configuredAddons.toArray()); } - const cloudComputingProviders: Provider[] = + const serviceComputingProviders: Provider[] = await taskFor(this.getExternalProviders) .perform(activeFilterObject.modelName, activeFilterObject.configuredAddons); - activeFilterObject.list = cloudComputingProviders.sort(this.providerSorter); + activeFilterObject.list = serviceComputingProviders.sort(this.providerSorter); } @task @@ -347,10 +347,10 @@ export default class AddonsServiceManagerComponent extends Component { activeFilterObject.configuredAddons = A(configuredAddons.toArray()); } - const serviceCloudComputingProviders: Provider[] = + const serviceCitationProviders: Provider[] = await taskFor(this.getExternalProviders) .perform(activeFilterObject.modelName, activeFilterObject.configuredAddons); - activeFilterObject.list = serviceCloudComputingProviders.sort(this.providerSorter); + activeFilterObject.list = serviceCitationProviders.sort(this.providerSorter); } providerSorter(a: Provider, b: Provider) { 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 cf7fe0d9b4..cd5624dbbd 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'); } @@ -257,11 +257,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, @@ -276,9 +276,9 @@ export default class UserAddonManagerComponent extends Component { @waitFor async getCitationAddonProviders() { const activeFilterObject = this.filterTypeMapper[FilterTypes.CITATION_MANAGER]; - const serviceCloudComputingProviders = await taskFor(this.getExternalProviders) + const serviceCitationProviders = await taskFor(this.getExternalProviders) .perform(activeFilterObject.modelName) as ExternalCitationServiceModel[]; - activeFilterObject.list = serviceCloudComputingProviders.sort(this.providerSorter) + activeFilterObject.list = serviceCitationProviders.sort(this.providerSorter) .map(provider => new Provider( provider, this.currentUser, diff --git a/translations/en-us.yml b/translations/en-us.yml index b37bfb2bb3..adb1e4bf00 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -2350,7 +2350,7 @@ routes: institution: Institution email: Email osf-components: - addons-srvice: + addons-service: file-manager: get-item-error: 'Error fetching item' get-items-error: 'Error fetching items'