groups: reduce metadata updates, removal
@@ -6,6 +6,8 @@ export class MetadataReducer {
if (data) {
this.associations(data, state);
this.add(data, state);
+ this.update(data, state);
+ this.remove(data, state);
}
}
@@ -38,4 +40,31 @@ export class MetadataReducer {
state.associations = metadata;
}
}
+ update(json, state) {
+ let data = _.get(json, 'update-metadata', false);
+ if (data) {
+ let metadata = state.associations;
+ if (!(data["group-path"] in metadata)) {
+ metadata[data["group-path"]] = {};
+ }
+ metadata[data["group-path"]][
+ `${data["group-path"]}/${data["app-name"]}${data["app-path"]}`
+ ] = data;
+
+ state.associations = metadata;
+ }
+ }
+
+ remove(json, state) {
+ let data = _.get(json, 'remove', false);
+ if (data) {
+ let metadata = state.associations;
+ if (data['group-path'] in metadata) {
+ let path =
+ `${data['group-path']}/${data['app-name']}${data['app-path']}`
+ delete metadata[data["group-path"]][path];
+ state.associations = metadata;
+ }
+ }
+ }
}
