Skip to content

Commit

Permalink
widgets: Only enable cog icon for widgets that are configurable throu…
Browse files Browse the repository at this point in the history
…gh the standard system
  • Loading branch information
rafaellehmkuhl committed Jan 16, 2025
1 parent a32e794 commit addd0b9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/EditMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
/>
<div
class="icon-btn mdi mdi-cog"
:class="{ 'opacity-20 cursor-not-allowed': !isWidgetConfigurable[widget.component as WidgetType] }"
@click="store.widgetManagerVars(widget.hash).configMenuOpen = true"
/>
<div class="icon-btn mdi mdi-trash-can" @click="store.deleteWidget(widget)" />
Expand Down Expand Up @@ -360,6 +361,7 @@
<v-divider vertical class="opacity-10 mr-1" />
<div
class="icon-btn mdi mdi-cog"
:class="{ 'opacity-20 cursor-not-allowed': !isMiniWidgetConfigurable[widget.component as MiniWidgetType] }"
@click="store.miniWidgetManagerVars(widget.hash).configMenuOpen = true"
/>
<div class="icon-btn mdi mdi-trash-can" @click="store.deleteMiniWidget(widget)" />
Expand Down Expand Up @@ -429,6 +431,7 @@
<v-divider vertical class="opacity-10 mr-1" />
<div
class="icon-btn mdi mdi-cog"
:class="{ 'opacity-20 cursor-not-allowed': !isMiniWidgetConfigurable[widget.component as MiniWidgetType] }"
@click="store.miniWidgetManagerVars(widget.hash).configMenuOpen = true"
/>
<div class="icon-btn mdi mdi-trash-can" @click="store.deleteMiniWidget(widget)" />
Expand Down Expand Up @@ -664,6 +667,8 @@ import {
CustomWidgetElementType,
ExternalWidgetSetupInfo,
InternalWidgetSetupInfo,
isMiniWidgetConfigurable,
isWidgetConfigurable,
MiniWidgetType,
WidgetType,
} from '@/types/widgets'
Expand Down
35 changes: 35 additions & 0 deletions src/types/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,41 @@ export type Profile = {
name: string
}

export const isWidgetConfigurable: Record<WidgetType, boolean> = {
[WidgetType.Attitude]: true,
[WidgetType.Compass]: true,
[WidgetType.CompassHUD]: true,
[WidgetType.CustomWidgetBase]: true,
[WidgetType.DepthHUD]: true,
[WidgetType.IFrame]: true,
[WidgetType.ImageView]: true,
[WidgetType.Map]: true,
[WidgetType.MiniWidgetsBar]: false,
[WidgetType.Plotter]: true,
[WidgetType.URLVideoPlayer]: true,
[WidgetType.VideoPlayer]: true,
[WidgetType.VirtualHorizon]: false,
}

export const isMiniWidgetConfigurable: Record<MiniWidgetType, boolean> = {
[MiniWidgetType.Alerter]: false,
[MiniWidgetType.ArmerButton]: false,
[MiniWidgetType.BaseCommIndicator]: false,
[MiniWidgetType.BatteryIndicator]: true,
[MiniWidgetType.ChangeAltitudeCommander]: false,
[MiniWidgetType.Clock]: false,
[MiniWidgetType.DepthIndicator]: false,
[MiniWidgetType.MissionIdentifier]: true,
[MiniWidgetType.RelativeAltitudeIndicator]: false,
[MiniWidgetType.TakeoffLandCommander]: false,
[MiniWidgetType.VeryGenericIndicator]: true,
[MiniWidgetType.JoystickCommIndicator]: true,
[MiniWidgetType.MiniVideoRecorder]: true,
[MiniWidgetType.ModeSelector]: false,
[MiniWidgetType.SatelliteIndicator]: false,
[MiniWidgetType.ViewSelector]: false,
}

export const validateWidget = (maybeWidget: Widget): maybeWidget is Widget => {
if (maybeWidget.hash === undefined) throw new Error('Widget validation failed: property hash is missing.')

Expand Down

0 comments on commit addd0b9

Please sign in to comment.