Icu 13897 create remove tag modal (#2377)
* feat: 🎸 add action dropdown in tags table ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * feat: 🎸 add removeApiTags method to worker ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * feat: 🎸 add tag removal workflow ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * test: 💍 add tests for removing a worker tag ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * test: 💍 add tests for removing a tag ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 fix spelling issue ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 use mirage worker serializer to remove empty tag ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 update modal id to class ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 add autofocus to remove tag modal ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * feat: 🎸 update tags controller attributes ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 create normalizer to add empty object for api_tags ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 update getter signature ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 remove unneeded parens ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 remove type from Hds::Button ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 update confirmation modal class name ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * feat: 🎸 add emptyObjectIfMissing model attribute ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 PR feedback ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897 * refactor: 💡 remove default to null in toggleModal ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13897
This commit is contained in:
1 parent
723101b779
commit
f9af4f0092
16 files changed
+443
-12
No files matched your search
@@ -179,6 +179,8 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
payload = structuredClone(payload);
|
||||
// Check for and normalize missing arrays
|
||||
payload = this.normalizeMissingArrays(store, primaryModelClass, payload);
|
||||
// Check for and normalize missing objects
|
||||
payload = this.normalizeMissingObjects(store, primaryModelClass, payload);
|
||||
// Setup a new payload data structure.
|
||||
const transformedPayload = {};
|
||||
// Find the Ember-data-expected root key name.
|
||||
@@ -199,7 +201,7 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
|
||||
/**
|
||||
* Resets missing array fields to an empty array if they are annotated by
|
||||
* `normalizeToEmptyArray: true` in the associated model attribute
|
||||
* `emptyArrayIfMissing: true` in the associated model attribute
|
||||
* declaration. Our API excludes arrays when they are empty from
|
||||
* singular responses.
|
||||
*
|
||||
@@ -222,6 +224,30 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
return payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets missing object fields to an empty object if they are annotated by
|
||||
* `emptyObjectIfMissing: true` in the associated model attribute
|
||||
* declaration.
|
||||
*
|
||||
* @param {Store} store
|
||||
* @param {Model} primaryModelClass
|
||||
* @param {object} payload
|
||||
* @return {object}
|
||||
*/
|
||||
normalizeMissingObjects(store, primaryModelClass, payload) {
|
||||
const attrDefs = store
|
||||
.getSchemaDefinitionService()
|
||||
.attributesDefinitionFor({ type: primaryModelClass.modelName });
|
||||
if (attrDefs) {
|
||||
Object.keys(attrDefs).forEach((key) => {
|
||||
if (!payload[key] && attrDefs[key]?.options?.emptyObjectIfMissing) {
|
||||
payload[key] = {};
|
||||
}
|
||||
});
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrates the incoming scope JSON with additional boolean fields and
|
||||
* delegates nested attributes and secrets normalization.
|
||||
|
||||
Reference in new issue
Block a user