-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENG-4681] Add mirage for v2 api (#2051)
## Purpose Make the v2 endpoints work with mirage. This includes a lot of normalization of the API but not the extra features such as extended attributes for providers nor getting the folder lists. ## Summary of Changes 1. Add mirage 2. Adjust models
- Loading branch information
1 parent
81d0846
commit f8b33f1
Showing
20 changed files
with
410 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Factory } from 'ember-cli-mirage'; | ||
import faker from 'faker'; | ||
|
||
import ExternalAccountsModel from 'ember-osf-web/models/external-accounts'; | ||
|
||
export default Factory.extend<ExternalAccountsModel>({ | ||
profileUrl: faker.internet.url, | ||
|
||
displayName() { | ||
return faker.name.findName(); | ||
}, | ||
}); | ||
|
||
declare module 'ember-cli-mirage/types/registries/model' { | ||
export default interface MirageModelRegistry { | ||
'external-account': ExternalAccountsModel; | ||
} // eslint-disable-line semi | ||
} | ||
|
||
declare module 'ember-cli-mirage/types/registries/schema' { | ||
export default interface MirageSchemaRegistry { | ||
externalAccounts: ExternalAccountsModel; | ||
} // eslint-disable-line semi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Factory } from 'ember-cli-mirage'; | ||
|
||
import NodeAddonModel from 'ember-osf-web/models/node-addon'; | ||
|
||
export default Factory.extend<NodeAddonModel>({ | ||
nodeHasAuth: false, | ||
configured: false, | ||
folderId: null, | ||
folderPath: null, | ||
}); | ||
|
||
declare module 'ember-cli-mirage/types/registries/model' { | ||
export default interface MirageModelRegistry { | ||
'node-addon': NodeAddonModel; | ||
} // eslint-disable-line semi | ||
} | ||
|
||
declare module 'ember-cli-mirage/types/registries/schema' { | ||
export default interface MirageSchemaRegistry { | ||
nodeAddons: NodeAddonModel; | ||
} // eslint-disable-line semi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Factory } from 'ember-cli-mirage'; | ||
|
||
import UserAddonModel from 'ember-osf-web/models/user-addon'; | ||
|
||
export default Factory.extend<UserAddonModel>({ | ||
userHasAuth: true, | ||
}); | ||
|
||
declare module 'ember-cli-mirage/types/registries/model' { | ||
export default interface MirageModelRegistry { | ||
'user-addon': UserAddonModel; | ||
} // eslint-disable-line semi | ||
} | ||
|
||
declare module 'ember-cli-mirage/types/registries/schema' { | ||
export default interface MirageSchemaRegistry { | ||
userAddons: UserAddonModel; | ||
} // eslint-disable-line semi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
export default [ | ||
{ | ||
id: 'box', | ||
name: 'Box', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
{ | ||
id: 'dataverse', | ||
name: 'Dataverse', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
{ | ||
id: 'dropbox', | ||
name: 'Dropbox', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
{ | ||
id: 'figshare', | ||
name: 'figshare', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
{ | ||
id: 'github', | ||
name: 'GitHub', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
{ | ||
id: 'gitlab', | ||
name: 'GitLab', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
{ | ||
id: 'mendeley', | ||
name: 'Mendeley', | ||
categories: [ | ||
'citations', | ||
], | ||
}, | ||
{ | ||
id: 'zotero', | ||
name: 'Zotero', | ||
categories: [ | ||
'citations', | ||
], | ||
}, | ||
{ | ||
id: 'owncloud', | ||
name: 'ownCloud', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
{ | ||
id: 'onedrive', | ||
name: 'OneDrive', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
{ | ||
id: 's3', | ||
name: 'Amazon S3', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
{ | ||
id: 'googledrive', | ||
name: 'Google Drive', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
{ | ||
id: 'bitbucket', | ||
name: 'Bitbucket', | ||
categories: [ | ||
'storage', | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import AddonModel from 'ember-osf-web/models/addon'; | ||
|
||
import ApplicationSerializer from './application'; | ||
|
||
export default class AddonSerializer extends ApplicationSerializer<AddonModel> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ModelInstance } from 'ember-cli-mirage'; | ||
import config from 'ember-osf-web/config/environment'; | ||
|
||
import ExternalAccountsModel from 'ember-osf-web/models/external-accounts'; | ||
|
||
import ApplicationSerializer from './application'; | ||
|
||
const { OSF: { apiUrl } } = config; | ||
|
||
export default class ExternalAccountSerializer extends ApplicationSerializer<ExternalAccountsModel> { | ||
buildNormalLinks(model: ModelInstance<ExternalAccountsModel>) { | ||
return { | ||
self: `${apiUrl}/v2/users/me/addons/${model.provider}/accounts/${model.id}`, | ||
}; | ||
} | ||
} |
Oops, something went wrong.