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: 2 additions & 0 deletions src/app/shared/mappers/addon.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class AddonMapper {
const displayName = (matchingService?.['display_name'] as string) || '';
const credentialsFormat = (matchingService?.['credentials_format'] as string) || '';
const supportedFeatures = (matchingService?.['supported_features'] as string[]) || [];
const iconUrl = (matchingService?.['icon_url'] as string) || '';

return {
type: response.type,
Expand All @@ -73,6 +74,7 @@ export class AddonMapper {
externalServiceName,
supportedFeatures,
credentialsFormat,
iconUrl,
providerName: displayName,
};
}
Expand Down
6 changes: 4 additions & 2 deletions src/app/shared/services/addons/addons.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Service: Addons', () => {
});

const request = httpMock.expectOne(
'http://addons.localhost:8000/user-references/reference-id/authorized_storage_accounts/?include=external-storage-service&fields%5Bexternal-storage-services%5D=external_service_name,credentials_format'
'http://addons.localhost:8000/user-references/reference-id/authorized_storage_accounts/?include=external-storage-service&fields%5Bexternal-storage-services%5D=external_service_name,credentials_format,icon_url'
);
expect(request.request.method).toBe('GET');
request.flush(getAddonsAuthorizedStorageData());
Expand All @@ -103,7 +103,8 @@ describe('Service: Addons', () => {
authorizedCapabilities: ['ACCESS', 'UPDATE'],
authorizedOperationNames: ['list_root_items', 'get_item_info', 'list_child_items'],
credentialsAvailable: true,
credentialsFormat: '',
credentialsFormat: 'OAUTH2',
iconUrl: 'https://osf.io/assets/images/logo.svg',
defaultRootFolder: '',
displayName: 'Google Drive',
externalServiceName: 'googledrive',
Expand Down Expand Up @@ -151,6 +152,7 @@ describe('Service: Addons', () => {
authorizedOperationNames: ['list_root_items', 'get_item_info', 'list_child_items'],
credentialsAvailable: true,
credentialsFormat: '',
iconUrl: '',
defaultRootFolder: '',
displayName: 'Google Drive',
externalServiceName: '',
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/services/addons/addons.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class AddonsService {

getAuthorizedAddons(addonType: string, referenceId: string): Observable<AuthorizedAccountModel[]> {
const params = {
[`fields[external-${addonType}-services]`]: 'external_service_name,credentials_format',
[`fields[external-${addonType}-services]`]: 'external_service_name,credentials_format,icon_url',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could also be convinced to remove this fields param entirely. Will result in us overfetching stuff from the API, but it may prevent future issues on this page

};
return this.jsonApiService
.get<
Expand Down
17 changes: 10 additions & 7 deletions src/app/shared/stores/addons/addons.state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('State: Addons', () => {
expect(loading()).toBeTruthy();

const request = httpMock.expectOne(
'http://addons.localhost:8000/user-references/reference-id/authorized_storage_accounts/?include=external-storage-service&fields%5Bexternal-storage-services%5D=external_service_name,credentials_format'
'http://addons.localhost:8000/user-references/reference-id/authorized_storage_accounts/?include=external-storage-service&fields%5Bexternal-storage-services%5D=external_service_name,credentials_format,icon_url'
);
expect(request.request.method).toBe('GET');
request.flush(getAddonsAuthorizedStorageData());
Expand All @@ -223,7 +223,7 @@ describe('State: Addons', () => {
authorizedCapabilities: ['ACCESS', 'UPDATE'],
authorizedOperationNames: ['list_root_items', 'get_item_info', 'list_child_items'],
credentialsAvailable: true,
credentialsFormat: '',
credentialsFormat: 'OAUTH2',
defaultRootFolder: '',
displayName: 'Google Drive',
externalServiceName: 'googledrive',
Expand All @@ -233,6 +233,7 @@ describe('State: Addons', () => {
providerName: '',
supportedFeatures: [],
type: 'authorized-storage-accounts',
iconUrl: 'https://osf.io/assets/images/logo.svg',
})
);

Expand All @@ -259,7 +260,7 @@ describe('State: Addons', () => {
expect(loading()).toBeTruthy();

const request = httpMock.expectOne(
'http://addons.localhost:8000/user-references/reference-id/authorized_storage_accounts/?include=external-storage-service&fields%5Bexternal-storage-services%5D=external_service_name,credentials_format'
'http://addons.localhost:8000/user-references/reference-id/authorized_storage_accounts/?include=external-storage-service&fields%5Bexternal-storage-services%5D=external_service_name,credentials_format,icon_url'
);
expect(request.request.method).toBe('GET');

Expand All @@ -268,7 +269,7 @@ describe('State: Addons', () => {
expect(result).toEqual({
data: [],
error:
'Http failure response for http://addons.localhost:8000/user-references/reference-id/authorized_storage_accounts/?include=external-storage-service&fields%5Bexternal-storage-services%5D=external_service_name,credentials_format: 500 Server Error',
'Http failure response for http://addons.localhost:8000/user-references/reference-id/authorized_storage_accounts/?include=external-storage-service&fields%5Bexternal-storage-services%5D=external_service_name,credentials_format,icon_url: 500 Server Error',
isLoading: false,
isSubmitting: false,
});
Expand Down Expand Up @@ -303,7 +304,6 @@ describe('State: Addons', () => {
authorizedCapabilities: ['ACCESS', 'UPDATE'],
authorizedOperationNames: ['list_root_items', 'get_item_info', 'list_child_items'],
credentialsAvailable: true,
credentialsFormat: '',
defaultRootFolder: '',
displayName: 'Google Drive',
externalServiceName: '',
Expand All @@ -313,6 +313,8 @@ describe('State: Addons', () => {
providerName: '',
supportedFeatures: [],
type: 'authorized-storage-accounts',
credentialsFormat: '', // No credentialsFormat in a PATCH response
iconUrl: '', // No iconUrl in a PATCH response
})
);

Expand All @@ -339,7 +341,7 @@ describe('State: Addons', () => {
expect(loading()).toBeTruthy();

let request = httpMock.expectOne(
'http://addons.localhost:8000/user-references/reference-id/authorized_storage_accounts/?include=external-storage-service&fields%5Bexternal-storage-services%5D=external_service_name,credentials_format'
'http://addons.localhost:8000/user-references/reference-id/authorized_storage_accounts/?include=external-storage-service&fields%5Bexternal-storage-services%5D=external_service_name,credentials_format,icon_url'
);
expect(request.request.method).toBe('GET');
request.flush(getAddonsAuthorizedStorageData());
Expand All @@ -358,7 +360,6 @@ describe('State: Addons', () => {
authorizedCapabilities: ['ACCESS', 'UPDATE'],
authorizedOperationNames: ['list_root_items', 'get_item_info', 'list_child_items'],
credentialsAvailable: true,
credentialsFormat: '',
defaultRootFolder: '',
displayName: 'Google Drive',
externalServiceName: '',
Expand All @@ -368,6 +369,8 @@ describe('State: Addons', () => {
providerName: '',
supportedFeatures: [],
type: 'authorized-storage-accounts',
credentialsFormat: '', // No credentialsFormat in a PATCH response
iconUrl: '', // No iconUrl in a PATCH response
})
);

Expand Down
2 changes: 2 additions & 0 deletions src/testing/data/addons/addons.authorized-storage.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ const AuthorizedStorage = {
id: '8aeb85e9-3a73-426f-a89b-5624b4b9d418',
attributes: {
external_service_name: 'googledrive',
credentials_format: 'OAUTH2',
icon_url: 'https://osf.io/assets/images/logo.svg',
},
links: {
self: 'https://addons.staging4.osf.io/v1/external-storage-services/8aeb85e9-3a73-426f-a89b-5624b4b9d418',
Expand Down