Reduce cognitive complexity by extracting helper functions (S3776)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -217,55 +217,25 @@ function onNavItemBtnClick(event) {
|
||||
case "FILES":
|
||||
store.filesTag = navItemCandidate;
|
||||
break;
|
||||
case "DISCOVER":
|
||||
case "DISCOVER": {
|
||||
type = route.params.type;
|
||||
fileId = route.params.fileId;
|
||||
isCheckPage = route.name.includes("Check");
|
||||
|
||||
switch (navItemCandidate) {
|
||||
case "MAP":
|
||||
if (isCheckPage) {
|
||||
router.push({
|
||||
name: "CheckMap",
|
||||
params: { type: type, fileId: fileId },
|
||||
});
|
||||
} else {
|
||||
router.push({
|
||||
name: "Map",
|
||||
params: { type: type, fileId: fileId },
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "CONFORMANCE":
|
||||
if (isCheckPage) {
|
||||
// Beware of Swal popup, it might disturb which is the current active page
|
||||
router.push({
|
||||
name: "CheckConformance",
|
||||
params: { type: type, fileId: fileId },
|
||||
});
|
||||
} else {
|
||||
// Beware of Swal popup, it might disturb which is the current active page
|
||||
router.push({
|
||||
name: "Conformance",
|
||||
params: { type: type, fileId: fileId },
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "PERFORMANCE":
|
||||
if (isCheckPage) {
|
||||
router.push({
|
||||
name: "CheckPerformance",
|
||||
params: { type: type, fileId: fileId },
|
||||
});
|
||||
} else {
|
||||
router.push({
|
||||
name: "Performance",
|
||||
params: { type: type, fileId: fileId },
|
||||
});
|
||||
}
|
||||
break;
|
||||
const discoverRoutes = {
|
||||
MAP: "Map",
|
||||
CONFORMANCE: "Conformance",
|
||||
PERFORMANCE: "Performance",
|
||||
};
|
||||
const baseName = discoverRoutes[navItemCandidate];
|
||||
if (baseName) {
|
||||
const routeName = isCheckPage ? `Check${baseName}` : baseName;
|
||||
router.push({
|
||||
name: routeName,
|
||||
params: { type: type, fileId: fileId },
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "COMPARE":
|
||||
switch (navItemCandidate) {
|
||||
case "MAP":
|
||||
|
||||
Reference in New Issue
Block a user