Skip to content

Commit 2294465

Browse files
external-features-discovery-modal: Show origin extension of action suggestions
1 parent 19836fd commit 2294465

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

src/components/ExternalFeaturesDiscoveryModal.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
</v-btn>
4949
<v-btn variant="text" prepend-icon="mdi-close" @click="ignoreAction(action)"> Ignore </v-btn>
5050
</div>
51+
<v-card-subtitle class="text-grey-lighten-1 text-center mt-3">
52+
from {{ action.extensionName }}
53+
</v-card-subtitle>
5154
</v-card-item>
5255
</v-card>
5356
</v-list-item>
@@ -228,7 +231,7 @@ import {
228231
getAllMavlinkMessageActionConfigs,
229232
registerMavlinkMessageActionConfig,
230233
} from '@/libs/actions/mavlink-message-actions'
231-
import { getActionsFromBlueOS, getJoystickSuggestionsFromBlueOS } from '@/libs/blueos'
234+
import { ActionWithExtensionName, getActionsFromBlueOS, getJoystickSuggestionsFromBlueOS } from '@/libs/blueos'
232235
import { allAvailableButtons } from '@/libs/joystick/protocols'
233236
import { useAppInterfaceStore } from '@/stores/appInterface'
234237
import { useControllerStore } from '@/stores/controller'
@@ -295,7 +298,7 @@ const activeTab = ref('actions')
295298
/**
296299
* Store discovered actions from BlueOS
297300
*/
298-
const discoveredActions = ref<ActionConfig[]>([])
301+
const discoveredActions = ref<ActionWithExtensionName[]>([])
299302
300303
/**
301304
* Store discovered joystick suggestions from BlueOS
@@ -601,8 +604,8 @@ const checkForBlueOSActions = async (): Promise<void> => {
601604
const actionsToDisplay = actions.filter((action) => !existingActionNames.has(action.name))
602605
603606
if (actionsToDisplay.length > 0) {
604-
// Actions already have extension information attached from getActionsFromBlueOS
605-
discoveredActions.value = actionsToDisplay
607+
// Actions now include extension names from the getActionsFromBlueOS function
608+
discoveredActions.value = actionsToDisplay as ActionWithExtensionName[]
606609
}
607610
}
608611
} catch (error) {

src/libs/blueos.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,14 @@ export const getWidgetsFromBlueOS = async (): Promise<ExternalWidgetSetupInfo[]>
161161
return widgets
162162
}
163163

164-
export const getActionsFromBlueOS = async (): Promise<ActionConfig[]> => {
164+
export type ActionWithExtensionName = ActionConfig & {
165+
/**
166+
* The name of the extension that the action belongs to
167+
*/
168+
extensionName: string
169+
}
170+
171+
export const getActionsFromBlueOS = async (): Promise<ActionWithExtensionName[]> => {
165172
const vehicleStore = useMainVehicleStore()
166173

167174
// Wait until we have a global address
@@ -170,13 +177,17 @@ export const getActionsFromBlueOS = async (): Promise<ActionConfig[]> => {
170177
}
171178

172179
const services = await getServicesFromBlueOS(vehicleStore.globalAddress)
173-
const actions: ActionConfig[] = []
180+
const actions: ActionWithExtensionName[] = []
174181
await Promise.all(
175182
services.map(async (service) => {
176183
try {
177184
const extraJson = await getExtrasJsonFromBlueOsService(vehicleStore.globalAddress, service)
178-
if (extraJson !== null) {
179-
actions.push(...extraJson.actions)
185+
if (extraJson !== null && extraJson.actions) {
186+
const extensionName = service.metadata?.sanitized_name || 'Unknown Extension'
187+
188+
extraJson.actions.forEach((action) => {
189+
actions.push({ ...action, extensionName })
190+
})
180191
}
181192
} catch (error) {
182193
console.error(`Could not get actions from BlueOS service ${service.metadata?.sanitized_name}. ${error}`)

0 commit comments

Comments
 (0)