2020-08-04 14:09:49 -04:00
|
|
|
export const findCommitIndex = (commits, commitShortId) => {
|
2020-12-23 16:10:24 -05:00
|
|
|
return commits.findIndex((commit) => commit.short_id === commitShortId);
|
2020-08-04 14:09:49 -04: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;
|
|
|
|
};
|