Skip to content

Commit b45035b

Browse files
external-features-discovery-modal: Show origin extension of action suggestions
1 parent 5abcdca commit b45035b

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

src/components/ExternalFeaturesDiscoveryModal.vue

Lines changed: 23 additions & 3 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>
@@ -292,10 +295,20 @@ const isVisible = ref(false)
292295
*/
293296
const activeTab = ref('actions')
294297
298+
/**
299+
* Action with extension name
300+
*/
301+
type ActionWithExtensionName = ActionConfig & {
302+
/**
303+
* Name of the extension that offered the action
304+
*/
305+
extensionName: string
306+
}
307+
295308
/**
296309
* Store discovered actions from BlueOS
297310
*/
298-
const discoveredActions = ref<ActionConfig[]>([])
311+
const discoveredActions = ref<ActionWithExtensionName[]>([])
299312
300313
/**
301314
* Store discovered joystick suggestions from BlueOS
@@ -572,7 +585,14 @@ const closeModal = (): void => {
572585
*/
573586
const checkForBlueOSActions = async (): Promise<void> => {
574587
try {
575-
const actions = await getActionsFromBlueOS()
588+
const actionsFromExtensions = await getActionsFromBlueOS()
589+
590+
const actions = actionsFromExtensions.flatMap((extension) =>
591+
extension.actionConfigs.map((action) => ({
592+
extensionName: extension.extensionName,
593+
...action,
594+
}))
595+
)
576596
577597
if (actions.length > 0) {
578598
// Get all existing actions from the app
@@ -591,7 +611,7 @@ const checkForBlueOSActions = async (): Promise<void> => {
591611
const actionsToDisplay = actions.filter((action) => !existingActionNames.has(action.name))
592612
593613
if (actionsToDisplay.length > 0) {
594-
// Actions already have extension information attached from getActionsFromBlueOS
614+
// Actions now include extension names from the getActionsFromBlueOS function
595615
discoveredActions.value = actionsToDisplay
596616
}
597617
}

src/libs/blueos.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,18 @@ export const getWidgetsFromBlueOS = async (): Promise<ExternalWidgetSetupInfo[]>
172172
return widgets
173173
}
174174

175-
export const getActionsFromBlueOS = async (): Promise<ActionConfig[]> => {
175+
export type ActionsFromExtension = {
176+
/**
177+
* The name of the extension that is offering the actions
178+
*/
179+
extensionName: string
180+
/**
181+
* The action configs from the extension
182+
*/
183+
actionConfigs: ActionConfig[]
184+
}
185+
186+
export const getActionsFromBlueOS = async (): Promise<ActionsFromExtension[]> => {
176187
const vehicleStore = useMainVehicleStore()
177188

178189
// Wait until we have a global address
@@ -181,21 +192,23 @@ export const getActionsFromBlueOS = async (): Promise<ActionConfig[]> => {
181192
}
182193

183194
const services = await getServicesFromBlueOS(vehicleStore.globalAddress)
184-
const actions: ActionConfig[] = []
195+
const actionsFromExtensions: ActionsFromExtension[] = []
185196
await Promise.all(
186197
services.map(async (service) => {
187198
try {
188199
const extraJson = await getExtrasJsonFromBlueOsService(vehicleStore.globalAddress, service)
189-
if (extraJson !== null) {
190-
actions.push(...extraJson.actions)
200+
if (extraJson !== null && extraJson.actions) {
201+
const extensionName = service.metadata?.sanitized_name || 'Unknown Extension'
202+
203+
actionsFromExtensions.push({ extensionName, actionConfigs: extraJson.actions })
191204
}
192205
} catch (error) {
193206
console.error(`Could not get actions from BlueOS service ${service.metadata?.sanitized_name}. ${error}`)
194207
}
195208
})
196209
)
197210

198-
return actions
211+
return actionsFromExtensions
199212
}
200213

201214
export const getJoystickSuggestionsFromBlueOS = async (): Promise<JoystickMapSuggestionsFromExtension[]> => {

0 commit comments

Comments
 (0)