import type { RouteRecordRaw } from "vue-router";

import MissionControlPage from "../pages/operations/MissionControlPage.vue";
import ApprovalsCenterPage from "../pages/operations/ApprovalsCenterPage.vue";
import RuntimeDeployTaskDetailsPage from "../pages/operations/RuntimeDeployTaskDetailsPage.vue";
import RuntimeDeployTasksPage from "../pages/operations/RuntimeDeployTasksPage.vue";
import WaitQueuePage from "../pages/operations/WaitQueuePage.vue";

import ProjectMembersPage from "../pages/ProjectMembersPage.vue";
import ProjectDetailsPage from "../pages/ProjectDetailsPage.vue";
import ProjectRepositoriesPage from "../pages/ProjectRepositoriesPage.vue";
import ProjectsPage from "../pages/ProjectsPage.vue";
import RunDetailsPage from "../pages/RunDetailsPage.vue";
import RunsPage from "../pages/RunsPage.vue";
import SystemSettingsPage from "../pages/configuration/SystemSettingsPage.vue";
import UsersPage from "../pages/UsersPage.vue";

export const routes: RouteRecordRaw[] = [
  { path: "/", alias: "/mission-control", name: "mission-control", component: MissionControlPage, meta: { section: "operations" } },
  { path: "/projects", name: "projects", component: ProjectsPage, meta: { section: "projects" } },
  { path: "/projects/:projectId", name: "project-details", component: ProjectDetailsPage, props: true, meta: { section: "projects", crumbKey: "crumb.projectDetails" } },
  {
    path: "/projects/:projectId/repositories",
    name: "project-repositories",
    component: ProjectRepositoriesPage,
    props: true,
    meta: { adminOnly: true, section: "projects", crumbKey: "crumb.projectRepositories" },
  },
  {
    path: "/projects/:projectId/members",
    name: "project-members",
    component: ProjectMembersPage,
    props: true,
    meta: { adminOnly: true, section: "projects", crumbKey: "crumb.projectMembers" },
  },
  { path: "/runs", name: "runs", component: RunsPage, meta: { section: "runs" } },
  { path: "/runs/:runId", name: "run-details", component: RunDetailsPage, props: true, meta: { section: "runs", crumbKey: "crumb.runDetails" } },

  // Operations
  { path: "/runtime-deploy/tasks", name: "runtime-deploy-tasks", component: RuntimeDeployTasksPage, meta: { section: "operations", crumbKey: "crumb.runtimeDeployTasks" } },
  { path: "/runtime-deploy/tasks/:runId", name: "runtime-deploy-task-details", component: RuntimeDeployTaskDetailsPage, props: true, meta: { section: "operations", crumbKey: "crumb.runtimeDeployTaskDetails" } },
  { path: "/wait-queue", name: "wait-queue", component: WaitQueuePage, meta: { section: "operations", crumbKey: "crumb.waitQueue" } },
  { path: "/approvals", name: "approvals", component: ApprovalsCenterPage, meta: { section: "operations", crumbKey: "crumb.approvals" } },

  // Configuration (scaffold)
  { path: "/configuration/system-settings", name: "system-settings", component: SystemSettingsPage, meta: { adminOnly: true, section: "configuration", crumbKey: "crumb.systemSettings" } },

  { path: "/users", name: "users", component: UsersPage, meta: { adminOnly: true, section: "users" } },
  { path: "/:pathMatch(.*)*", redirect: { name: "mission-control" } },
];
