Repository Public
1import Foundation2import MCCCore3import SwiftUI45/// Sections of the main window's sidebar.6enum SidebarItem: String, CaseIterable, Identifiable, Codable, Sendable {7 case overview, nodes, services, models, jobs, network, storage, alerts, maintenance, activity, audit, settings89 var id: String { rawValue }10 var title: String { Localization.shared.string("nav." + rawValue) }1112 var symbol: String {13 switch self {14 case .overview: "gauge.with.dots.needle.67percent"15 case .nodes: "desktopcomputer"16 case .services: "gearshape.2"17 case .models: "brain"18 case .jobs: "list.bullet.rectangle"19 case .network: "point.3.connected.trianglepath.dotted"20 case .storage: "internaldrive"21 case .alerts: "bell"22 case .maintenance: "calendar.badge.clock"23 case .activity: "clock.arrow.circlepath"24 case .audit: "checkmark.shield"25 case .settings: "gearshape"26 }27 }2829 /// ⌘1 … ⌘9, ⌘0 for the tenth; Audit and Settings use ⌥⌘A and ⌘, (standard).30 var shortcut: KeyEquivalent? {31 switch self {32 case .overview: "1"33 case .nodes: "2"34 case .services: "3"35 case .models: "4"36 case .jobs: "5"37 case .network: "6"38 case .storage: "7"39 case .alerts: "8"40 case .maintenance: "9"41 case .activity: "0"42 case .audit, .settings: nil43 }44 }4546 /// The permission without which the section cannot show anything (the server enforces; this only hides).47 var permission: String? {48 switch self {49 case .overview: "cluster.read"50 case .nodes: "nodes.read"51 case .services: "services.read"52 case .models: "models.read"53 case .jobs: "jobs.read"54 case .network: "cluster.read"55 case .storage: "cluster.read"56 case .alerts: "alerts.read"57 case .maintenance: "maintenance.read"58 case .activity: "cluster.read"59 case .audit: "audit.read"60 case .settings: nil61 }62 }6364 enum Group: String, CaseIterable { case observe, operate, govern }65 var group: Group {66 switch self {67 case .overview, .nodes, .services, .models, .network, .storage: .observe68 case .jobs, .alerts, .maintenance, .activity: .operate69 case .audit, .settings: .govern70 }71 }72}7374// Values of the secondary windows (`WindowGroup(for:)`): Codable so that macOS restores them at relaunch.7576struct NodeRef: Hashable, Codable, Sendable { var id: String }77struct ActionRef: Hashable, Codable, Sendable { var id: String }78struct CompareRef: Hashable, Codable, Sendable { var nodeIDs: [String] }79struct LogsRef: Hashable, Codable, Sendable {80 var serviceID: String81 var serviceName: String82 var nodeAlias: String83}8485/// Something to bring into view from outside a window (menu bar, notification, deep link, search result).86enum FocusTarget: Hashable, Sendable {87 case alert(String)88 case incident(String)89 case service(String)90 case job(String)91 case model(String)92 case maintenanceWindow(String)93 case maintenanceNote(String)94}9596/// What the user wants to do to a target; presented as the action request sheet.97struct ActionIntent: Identifiable, Hashable, Sendable {98 var typeName: String99 var targetKind: API.ActionTargetKind100 var targetID: String101 var targetLabel: String102 var presetParams: [String: JSONValue] = [:]103 /// The window that asked ("main", or the identity of a secondary window): the form opens where the user is.104 var host: String = ActionHost.main105 var id: String { "\(typeName)|\(targetID)|\(host)" }106}107108enum ActionHost {109 static let main = "main"110}111112extension EnvironmentValues {113 /// Which window presents the action request sheet for actions requested from this part of the hierarchy.114 @Entry var actionHost: String = ActionHost.main115}116