2020-08-04 18:09:49 +00:00
|
|
|
export const findCommitIndex = (commits, commitShortId) => {
|
2020-12-23 21:10:24 +00:00
|
|
|
return commits.findIndex((commit) => commit.short_id === commitShortId);
|
2020-08-04 18:09:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const setCommitStatus = (commits, commitIndex, selected) => {
|
|
|
|
const tempCommits = [...commits];
|
|
|
|
tempCommits[commitIndex] = {
|
|
|
|
...tempCommits[commitIndex],
|
|
|
|
isSelected: selected,
|
|
|
|
};
|
|
|
|
return tempCommits;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const removeIfReadyToBeRemoved = (toRemoveCommits, commitShortId) => {
|
|
|
|
const tempToRemoveCommits = [...toRemoveCommits];
|
|
|
|
const isPresentInToRemove = tempToRemoveCommits.indexOf(commitShortId);
|
|
|
|
if (isPresentInToRemove !== -1) {
|
|
|
|
tempToRemoveCommits.splice(isPresentInToRemove, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tempToRemoveCommits;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const removeIfPresent = (selectedCommits, commitShortId) => {
|
|
|
|
const tempSelectedCommits = [...selectedCommits];
|
|
|
|
const selectedCommitsIndex = findCommitIndex(tempSelectedCommits, commitShortId);
|
|
|
|
if (selectedCommitsIndex !== -1) {
|
|
|
|
tempSelectedCommits.splice(selectedCommitsIndex, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tempSelectedCommits;
|
|
|
|
};
|