Skip to content
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
2 changes: 0 additions & 2 deletions app/models/configured-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export enum ConnectedCapabilities {
}

export enum ConnectedOperationNames {
DownloadAsZip = 'download_as_zip',
CopyInto = 'copy_into',
HasRevisions = 'has_revisions',
ListRootItems = 'list_root_items',
ListChildItems = 'list_child_items',
Expand Down
2 changes: 2 additions & 0 deletions app/models/external-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export enum ExternalServiceCapabilities {
REGISTERING = 'REGISTERING',
REGISTERING_PARTIAL = 'REGISTERING_PARTIAL',
FILE_VERSIONS = 'FILE_VERSIONS',
DOWNLOAD_AS_ZIP = 'DOWNLOAD_AS_ZIP',
COPY_INTO = 'COPY_INTO',
}

export default class ExternalServiceModel extends Model {
Expand Down
1 change: 1 addition & 0 deletions app/models/external-storage-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ExternalServiceModel from './external-service';
export default class ExternalStorageServiceModel extends ExternalServiceModel {
@attr('number') maxConcurrentDownloads!: number;
@attr('number') maxUploadMb!: number;
@attr('string') wbKey!: string;
}

declare module 'ember-data/types/registries/model' {
Expand Down
20 changes: 14 additions & 6 deletions app/packages/files/service-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Permission } from 'ember-osf-web/models/osf-model';
import CurrentUserService from 'ember-osf-web/services/current-user';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';
import humanFileSize from 'ember-osf-web/utils/human-file-size';
import { ExternalServiceCapabilities } from 'ember-osf-web/models/external-service';


export enum FileSortKey {
Expand Down Expand Up @@ -50,11 +51,11 @@ export default class ServiceFile {
@tracked configuredStorageAddon: ConfiguredStorageAddonModel;
@tracked totalFileCount = 0;
@tracked waterButlerRevisions?: WaterButlerRevision[];
userCanDownloadAsZip: boolean;
@tracked userCanDownloadAsZip: boolean;
@tracked canMoveToThisProvider: boolean;
shouldShowTags = false;
shouldShowRevisions: boolean;
providerHandlesVersioning: boolean;
canMoveToThisProvider: boolean;
parallelUploadsLimit = 2;

currentUser: CurrentUserService;
Expand All @@ -71,15 +72,22 @@ export default class ServiceFile {
this.currentUser = currentUser;
this.fileModel = fileModel;
this.configuredStorageAddon = configuredStorageAddon;
this.userCanDownloadAsZip = configuredStorageAddon.connectedOperationNames
.includes(ConnectedOperationNames.DownloadAsZip);
this.userCanDownloadAsZip = false;
this.canMoveToThisProvider = false;
this.getSupportedFeatures();
this.providerHandlesVersioning = configuredStorageAddon.connectedOperationNames
.includes(ConnectedOperationNames.HasRevisions);
this.shouldShowRevisions = configuredStorageAddon.connectedOperationNames
.includes(ConnectedOperationNames.HasRevisions);
this.parallelUploadsLimit = configuredStorageAddon.concurrentUploads;
this.canMoveToThisProvider = configuredStorageAddon.connectedOperationNames
.includes(ConnectedOperationNames.CopyInto);
}

async getSupportedFeatures() {
const externalStorageService = await this.configuredStorageAddon.externalStorageService;
this.userCanDownloadAsZip = externalStorageService.get('supportedFeatures')
.includes(ExternalServiceCapabilities.DOWNLOAD_AS_ZIP);
this.canMoveToThisProvider = externalStorageService.get('supportedFeatures')
.includes(ExternalServiceCapabilities.COPY_INTO);
}

get isFile() {
Expand Down
22 changes: 15 additions & 7 deletions app/packages/files/service-provider-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import { ErrorDocument } from 'osf-api';
import ConfiguredStorageAddonModel from 'ember-osf-web/models/configured-storage-addon';
import { ConnectedOperationNames, ConnectedCapabilities } from 'ember-osf-web/models/configured-addon';
import ServiceFile from 'ember-osf-web/packages/files/service-file';
import { ExternalServiceCapabilities } from 'ember-osf-web/models/external-service';

export default class ServiceProviderFile {
@tracked fileModel: FileProviderModel;
@tracked configuredStorageAddon: ConfiguredStorageAddonModel;
@tracked totalFileCount = 0;
userCanDownloadAsZip: boolean;
@tracked userCanDownloadAsZip: boolean;
@tracked canMoveToThisProvider: boolean;
providerHandlesVersioning: boolean;
canMoveToThisProvider: boolean;
parallelUploadsLimit = 2;

currentUser: CurrentUserService;
Expand All @@ -37,13 +38,20 @@ export default class ServiceProviderFile {
this.currentUser = currentUser;
this.fileModel = fileModel;
this.configuredStorageAddon = configuredStorageAddon;
this.userCanDownloadAsZip = configuredStorageAddon.connectedOperationNames
.includes(ConnectedOperationNames.DownloadAsZip);
this.userCanDownloadAsZip = false;
this.canMoveToThisProvider = false;
this.getSupportedFeatures();
this.providerHandlesVersioning = configuredStorageAddon.connectedOperationNames
.includes(ConnectedOperationNames.HasRevisions);
this.parallelUploadsLimit = configuredStorageAddon.concurrentUploads;
this.canMoveToThisProvider = configuredStorageAddon.connectedOperationNames
.includes(ConnectedOperationNames.CopyInto);
}

async getSupportedFeatures() {
const externalStorageService = await this.configuredStorageAddon.externalStorageService;
this.userCanDownloadAsZip = externalStorageService.get('supportedFeatures')
.includes(ExternalServiceCapabilities.DOWNLOAD_AS_ZIP);
this.canMoveToThisProvider = externalStorageService.get('supportedFeatures')
.includes(ExternalServiceCapabilities.COPY_INTO);
}

get id() {
Expand Down Expand Up @@ -92,7 +100,7 @@ export default class ServiceProviderFile {
}

get name() {
return this.configuredStorageAddon.displayName;
return this.configuredStorageAddon.externalStorageService.get('wbKey');
}

get iconLocation() {
Expand Down
Loading