Skip to content

Commit 3656d3d

Browse files
authored
Merge branch 'develop' into MAT-6559a
2 parents 5d19b29 + 78de90b commit 3656d3d

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

src/components/measureLanding/measureList/createVersionDialog/CreateVersionDialog.tsx

+13-22
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,20 @@ const CreatVersionDialog = ({
6767
if (!currentVersion) {
6868
return null;
6969
}
70-
const VERSION_MAP = {
71-
major: 0,
72-
minor: 1,
73-
patch: 2,
74-
};
75-
const splitVersion = currentVersion.split(".");
76-
const selectedIndex = VERSION_MAP[versionType];
77-
if (selectedIndex === 2) {
78-
// patch is a little funny
79-
const currentPatch = splitVersion[selectedIndex];
80-
let newPatch = Number(currentPatch) + 1;
81-
let newPatchString = String(newPatch);
82-
const digits = String(newPatchString).length; //now we know how many digits we have
83-
for (let i = 0; i < 3 - digits; i++) {
84-
newPatchString = "0" + newPatchString;
85-
}
86-
splitVersion[selectedIndex] = newPatchString;
87-
return splitVersion.join(".");
88-
} else {
89-
const targetValue = splitVersion[selectedIndex];
90-
splitVersion[selectedIndex] = Number(targetValue + 1);
91-
return splitVersion.join(".");
70+
const splitVersionString = currentVersion.split(".");
71+
if (versionType === "major") {
72+
splitVersionString[0] = String(parseInt(splitVersionString[0]) + 1);
73+
splitVersionString[1] = "0";
74+
splitVersionString[2] = "000";
75+
} else if (versionType === "minor") {
76+
splitVersionString[1] = String(parseInt(splitVersionString[1]) + 1);
77+
splitVersionString[2] = "000";
78+
} else if (versionType === "patch") {
79+
splitVersionString[2] = String(
80+
parseInt(splitVersionString[2]) + 1
81+
).padStart(3, "0");
9282
}
83+
return splitVersionString.join(".");
9384
};
9485

9586
useEffect(() => {

0 commit comments

Comments
 (0)