-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1401 - compare directly after uploading the bundle
- Loading branch information
1 parent
1bfe59b
commit 000cb83
Showing
3 changed files
with
94 additions
and
138 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import _ from "lodash"; | ||
import httpClient from "../../common/utils/httpClient"; | ||
|
||
export const CHANGE_TYPE = { | ||
ADDED: "added", | ||
REMOVED: "removed", | ||
MODIFIED: "modified", | ||
NO_MODIFICATION: "noModification" | ||
}; | ||
|
||
const isNoModification = function(obj) { | ||
if (!_.isObject(obj)) return false; | ||
if (obj.changeType === CHANGE_TYPE.NO_MODIFICATION) return true; | ||
return _.some(obj, value => isNoModification(value)); | ||
}; | ||
|
||
const filterForms = function(data) { | ||
const filteredData = _.reduce( | ||
data, | ||
(acc, formData, formName) => { | ||
if (!isNoModification(formData) && formName !== "formMappings.json") { | ||
acc[formName] = formData; | ||
} | ||
return acc; | ||
}, | ||
{} | ||
); | ||
|
||
return _.reduce( | ||
filteredData, | ||
(acc, formData, formName) => { | ||
acc[formName] = formData; | ||
return acc; | ||
}, | ||
{} | ||
); | ||
}; | ||
|
||
class CompareMetadataService { | ||
static async compare(file) { | ||
const formData = new FormData(); | ||
formData.append("incumbentBundle", file); | ||
const response = await httpClient.post("/web/bundle/findChanges", formData); | ||
return filterForms(response.data); | ||
} | ||
} | ||
|
||
export default CompareMetadataService; |
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
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