2023-06-19 16:23:53 +00:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
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);
|
|
|
|
|
const pluginName = snapshot?.attr('plugin')?.name;
|
|
|
|
|
if (requestType === 'createRecord' && pluginName) {
|
|
|
|
|
url = `${url}?plugin_name=${pluginName}`;
|
|
|
|
|
}
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
}
|