diff --git a/app/guid-node/addons/index/template.hbs b/app/guid-node/addons/index/template.hbs index 0d2f309ff5e..700882ccea8 100644 --- a/app/guid-node/addons/index/template.hbs +++ b/app/guid-node/addons/index/template.hbs @@ -169,15 +169,17 @@ > {{configuredAddon.displayName}} - + {{#if configuredAddon.currentUserIsOwner}} + + {{/if}} - {{else}} - - {{/if}} - + {{#if this.addonIsOwned}} +
+ {{#if this.addonIsConfigured}} + + {{else}} + + {{/if}} +
+ {{/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 d0ca89f0313..68a984d7316 100644 --- a/lib/osf-components/addon/components/addons-service/manager/component.ts +++ b/lib/osf-components/addon/components/addons-service/manager/component.ts @@ -22,6 +22,7 @@ import ConfiguredStorageAddonModel from 'ember-osf-web/models/configured-storage import { AccountCreationArgs} from 'ember-osf-web/models/authorized-account'; import AuthorizedStorageAccountModel from 'ember-osf-web/models/authorized-storage-account'; import ConfiguredCitationAddonModel from 'ember-osf-web/models/configured-citation-addon'; +import UserReferenceModel from 'ember-osf-web/models/user-reference'; interface FilterSpecificObject { modelName: string; @@ -58,6 +59,7 @@ export default class AddonsServiceManagerComponent extends Component { node = this.args.node; @tracked addonServiceNode?: ResourceReferenceModel; + @tracked userReference?: UserReferenceModel; possibleFilterTypes = Object.values(FilterTypes); mapper: Record = { @@ -285,7 +287,10 @@ export default class AddonsServiceManagerComponent extends Component { @task @waitFor async initialize() { - await taskFor(this.getServiceNode).perform(); + await Promise.all([ + taskFor(this.getUserReference).perform(), + taskFor(this.getServiceNode).perform(), + ]); await taskFor(this.getStorageAddonProviders).perform(); } @@ -385,7 +390,18 @@ export default class AddonsServiceManagerComponent extends Component { } return heading; } - + @task + @waitFor + async getUserReference() { + if (this.userReference){ + return; + } + const { user } = this.currentUser; + const userReferences = await this.store.query('user-reference', { + filter: {user_uri: user?.links.iri?.toString()}, + }); + this.userReference = userReferences.firstObject; + } // Service API Methods @task @@ -394,7 +410,9 @@ export default class AddonsServiceManagerComponent extends Component { const serviceProviderModels = (await this.store.findAll(providerType)).toArray(); const serviceProviders = [] as Provider[]; for (const provider of serviceProviderModels) { - serviceProviders.addObject(new Provider(provider, this.currentUser, this.node, configuredAddons)); + serviceProviders.addObject(new Provider( + provider, this.currentUser, this.node, configuredAddons, this.addonServiceNode, this.userReference, + )); } return serviceProviders; } 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 c9f9fdda43d..cf7fe0d9b4e 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 @@ -244,7 +244,14 @@ export default class UserAddonManagerComponent extends Component { const serviceStorageProviders = await taskFor(this.getExternalProviders) .perform(activeFilterObject.modelName) as ExternalStorageServiceModel[]; const list = serviceStorageProviders.sort(this.providerSorter) - .map(provider => new Provider(provider, this.currentUser)); + .map(provider => new Provider( + provider, + this.currentUser, + undefined, + undefined, + undefined, + this.userReference, + )); activeFilterObject.list = list; } @@ -255,7 +262,14 @@ export default class UserAddonManagerComponent extends Component { const cloudComputingProviders = await taskFor(this.getExternalProviders) .perform(activeFilterObject.modelName) as ExternalComputingServiceModel[]; activeFilterObject.list = cloudComputingProviders.sort(this.providerSorter) - .map(provider => new Provider(provider, this.currentUser)); + .map(provider => new Provider( + provider, + this.currentUser, + undefined, + undefined, + undefined, + this.userReference, + )); } @task @@ -265,7 +279,14 @@ export default class UserAddonManagerComponent extends Component { const serviceCloudComputingProviders = await taskFor(this.getExternalProviders) .perform(activeFilterObject.modelName) as ExternalCitationServiceModel[]; activeFilterObject.list = serviceCloudComputingProviders.sort(this.providerSorter) - .map(provider => new Provider(provider, this.currentUser)); + .map(provider => new Provider( + provider, + this.currentUser, + undefined, + undefined, + undefined, + this.userReference, + )); } @task diff --git a/tests/acceptance/guid-node/addons-test.ts b/tests/acceptance/guid-node/addons-test.ts index 95a4c88b6bc..cacb611c541 100644 --- a/tests/acceptance/guid-node/addons-test.ts +++ b/tests/acceptance/guid-node/addons-test.ts @@ -124,6 +124,7 @@ module('Acceptance | guid-node/addons', hooks => { externalStorageService: box, accountOwner: userRef, authorizedResource: nodeRef, + currentUserIsOwner: true, }); const s3AccountsDisplayNamesAndRootFolders = [{ displayName: 'My Box Account', @@ -139,6 +140,7 @@ module('Acceptance | guid-node/addons', hooks => { externalStorageService: s3, accountOwner: userRef, authorizedResource: nodeRef, + currentUserIsOwner: true, }); server.create('configured-storage-addon', { displayName: s3AccountsDisplayNamesAndRootFolders[1].displayName, @@ -147,6 +149,7 @@ module('Acceptance | guid-node/addons', hooks => { externalStorageService: s3, accountOwner: userRef, authorizedResource: nodeRef, + currentUserIsOwner: true, }); const url = `/${node.id}/addons`; diff --git a/tests/integration/components/addon-card/component-test.ts b/tests/integration/components/addon-card/component-test.ts index 952898cf284..859aa3253a9 100644 --- a/tests/integration/components/addon-card/component-test.ts +++ b/tests/integration/components/addon-card/component-test.ts @@ -38,6 +38,7 @@ module('Integration | Component | addon-card', hooks => { }, disableProjectAddon: sinon.stub(), nodeAddon: { configured: false }, + isOwned: true, }; this.manager ={ node: { id: 'testnode' }, @@ -78,6 +79,7 @@ module('Integration | Component | addon-card', hooks => { disableProjectAddon: { perform: sinon.stub() }, nodeAddon: { configured: true }, isConfigured: true, + isOwned: true, }; this.addon = addonObj; this.manager = {