-
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.
Move accessService logic to share-adapter
- Loading branch information
1 parent
555c44d
commit 5655dfb
Showing
2 changed files
with
11 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
import JSONAPIAdapter from '@ember-data/adapter/json-api'; | ||
import config from 'ember-get-config'; | ||
import config from 'ember-osf-web/config/environment'; | ||
|
||
const osfUrl = config.OSF.url; | ||
|
||
export default class ShareAdapter extends JSONAPIAdapter { | ||
host = config.OSF.shareBaseUrl.replace(/\/$/, ''); // Remove trailing slash to avoid // in URLs | ||
namespace = 'api/v3'; | ||
|
||
queryRecord(store: any, type: any, query: any) { | ||
// check if we aren't serving locally, otherwise add accessService query param to card/value searches | ||
if (['index-card-search', 'index-value-search'].includes(type.modelName) && !osfUrl.includes('localhost')) { | ||
query.cardSearchFilter['accessService'] = osfUrl; | ||
} | ||
return super.queryRecord(store, type, query); | ||
} | ||
} |
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