2023-06-19 16:23:53 +00:00
|
|
|
/**
|
2026-01-28 17:09:06 -08:00
|
|
|
* Copyright IBM Corp. 2021, 2026
|
2024-05-31 11:29:24 -07:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-06-19 16:23:53 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-03-15 15:18:02 -04:00
|
|
|
import ApplicationAdapter from './application';
|
|
|
|
|
|
|
|
|
|
export default class StorageBucketAdapter extends ApplicationAdapter {
|
|
|
|
|
/**
|
|
|
|
|
* Overrides the default `buildURL` such that on _create_, URLs for records of
|
|
|
|
|
* type `plugin` get an extra query parameter `?plugin_name`. All other
|
|
|
|
|
* request types behave as normal.
|
|
|
|
|
*
|
|
|
|
|
* @override
|
|
|
|
|
* @param {string} modelName
|
|
|
|
|
* @param {string} id
|
|
|
|
|
* @return {string} url
|
|
|
|
|
* @return {string} requestType
|
|
|
|
|
*/
|
|
|
|
|
buildURL(modelName, id, snapshot, requestType) {
|
|
|
|
|
let url = super.buildURL(...arguments);
|
2023-08-14 17:03:59 -04:00
|
|
|
let pluginName;
|
|
|
|
|
try {
|
|
|
|
|
pluginName = snapshot?.attr('plugin')?.name;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// Ignore any adapter errors here
|
|
|
|
|
}
|
2023-03-15 15:18:02 -04:00
|
|
|
if (requestType === 'createRecord' && pluginName) {
|
|
|
|
|
url = `${url}?plugin_name=${pluginName}`;
|
|
|
|
|
}
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
}
|