Skip to content

Commit

Permalink
fixed loading other providers durong copy/move with gv enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
opaduchak committed Jan 10, 2025
1 parent 8b3930f commit f8d2efd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/models/configured-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class ConfiguredAddonModel extends Model {
@attr('array') connectedCapabilities!: ConnectedCapabilities[];
@attr('array') connectedOperationNames!: ConnectedStorageOperationNames[];
@attr('fixstring') rootFolder!: string;
@attr('fixstring') externalServiceName!: string;

@belongsTo('user-reference', { inverse: null })
accountOwner!: AsyncBelongsTo<UserReferenceModel> & UserReferenceModel;
Expand Down
15 changes: 11 additions & 4 deletions lib/osf-components/addon/components/move-file-modal/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import ProviderFile from 'ember-osf-web/packages/files/provider-file';
import CurrentUserService from 'ember-osf-web/services/current-user';
import captureException from 'ember-osf-web/utils/capture-exception';
import ConfiguredStorageAddonModel from 'ember-osf-web/models/configured-storage-addon';
import ResourceReferenceModel from 'ember-osf-web/models/resource-reference';

interface MoveFileModalArgs {
isOpen: boolean;
Expand Down Expand Up @@ -129,11 +130,16 @@ export default class MoveFileModalComponent extends Component<MoveFileModalArgs>
@task
@waitFor
async getResourceReference() {
const serviceNode = this.store.peekRecord('resource-reference', this.currentNode.id);
const serviceNode: ResourceReferenceModel = this.store.peekAll(
'resource-reference',
).find(ref => ref.resourceUri === this.currentNode.links.iri);
if (serviceNode) {
return serviceNode;
} else {
return await this.store.findRecord('resource-reference', this.currentNode.id);
const reference = await this.store.query('resource-reference', {
filter: {resource_uri: this.currentNode.links.iri},
}).first;
return reference;
}
}

Expand All @@ -154,8 +160,9 @@ export default class MoveFileModalComponent extends Component<MoveFileModalArgs>
fileList = fileList.map(
fileProviderModel => {
if(this.features.isEnabled('gravy_waffle') && fileProviderModel.name !== 'osfstorage') {
const storageAddon = configuredStorageAddonsList.toArray()
.find(configuredStorageAddon => configuredStorageAddon.name === fileProviderModel.provider);
const storageAddon = configuredStorageAddonsList.find(
addon => addon.externalServiceName === fileProviderModel.provider,
);
if (storageAddon) {
return getServiceProviderFile(this.currentUser, fileProviderModel, storageAddon!);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@
.FileName {
padding-left: 6px;
}

.ProviderIcon {
object-fit: contain;
height: 24px;
width: 70px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
{{#if (and (feature-flag 'gravy_waffle') (not (eq @item.name 'osfstorage')))}}
<img
data-test-provider-icon
local-class='ProviderIcon'
src={{@item.iconLocation}}
alt={{t 'osf-components.move_file_modal.icon_alt' provider=@item.name}}
>
{{@item.name}}
{{else}}
<img
local-class='ProviderIcon'
data-test-provider-icon
src={{concat this.assetPrefix 'assets/images/addons/icons/' @item.name '.png'}}
alt={{t 'osf-components.move_file_modal.icon_alt' provider=(t (concat 'osf-components.file-browser.storage_providers.' @item.name))}}
Expand Down

0 comments on commit f8d2efd

Please sign in to comment.