From ed9e71c4eb3968c7bdad0ee8fbda097a164040a3 Mon Sep 17 00:00:00 2001 From: James Dunkerley Date: Thu, 23 Nov 2023 09:03:34 +0000 Subject: [PATCH] Make ICON section work consistently between old and new GUI. (#8369) - Handle name mismatch in icons between old and new IDE. - Set the default icon for a few types. - If can't find and icon use the Enso logo. ![image](https://github.com/enso-org/enso/assets/4699705/43d828b4-58cf-429e-b659-b1c389953b23) --- .../src/components/GraphEditor/GraphNode.vue | 11 +++--- app/gui2/src/util/getIconName.ts | 39 ++++++++++++------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/app/gui2/src/components/GraphEditor/GraphNode.vue b/app/gui2/src/components/GraphEditor/GraphNode.vue index ef5e43f09d..d30b102a3f 100644 --- a/app/gui2/src/components/GraphEditor/GraphNode.vue +++ b/app/gui2/src/components/GraphEditor/GraphNode.vue @@ -8,7 +8,7 @@ import { injectGraphSelection } from '@/providers/graphSelection' import { useGraphStore, type Node } from '@/stores/graph' import { useApproach } from '@/util/animation' import { usePointer, useResizeObserver } from '@/util/events' -import { methodNameToIcon, typeNameToIcon } from '@/util/getIconName' +import { mapOldIconName, typeNameToIcon } from '@/util/getIconName' import type { Opt } from '@/util/opt' import { Rect } from '@/util/rect' import { Vec2 } from '@/util/vec2' @@ -124,15 +124,14 @@ const suggestionEntry = computed(() => graph.db.nodeMainSuggestion.lookup(nodeId const color = computed(() => graph.db.getNodeColorStyle(nodeId.value)) const icon = computed(() => { if (suggestionEntry.value?.iconName) { - return suggestionEntry.value.iconName + return mapOldIconName(suggestionEntry.value.iconName) } + const methodName = expressionInfo.value?.methodCall?.methodPointer.name - if (methodName != null) { - return methodNameToIcon(methodName) - } else if (outputTypeName.value != null) { + if (methodName == null && outputTypeName.value != null) { return typeNameToIcon(outputTypeName.value) } else { - return 'in_out' + return 'enso_logo' } }) diff --git a/app/gui2/src/util/getIconName.ts b/app/gui2/src/util/getIconName.ts index c6825f9347..c27c5bd498 100644 --- a/app/gui2/src/util/getIconName.ts +++ b/app/gui2/src/util/getIconName.ts @@ -1,28 +1,37 @@ import type { Icon } from '@/util/iconName' -const methodNameToIconLookup: Record = { +const oldIconNameToNewIconNameLookup: Record = { /* eslint-disable camelcase */ - read: 'text', - join: 'join3', - union: 'union', - set: 'edit', - filter: 'preparation', - add_columns: 'add_column', - add_rows: 'add_row', - remove_columns: 'remove_column', - remove_rows: 'remove_row', + dataframe_clean: 'clean_dataframe', + dataframe_map_row: 'map_row', + dataframe_map_column: 'add_column', + dataframes_join: 'join3', + dataframes_union: 'union', + sigma: 'transform4', + io: 'in_out', + date_and_time: 'time', + spatial: 'location', + predictive: 'predict', + machine_learning: 'robot', /* eslint-enable camelcase */ } -export function methodNameToIcon(methodName: string): Icon { - return methodNameToIconLookup[methodName] ?? 'in_out' +export function mapOldIconName(oldIconName: string): Icon { + const mappedName = oldIconNameToNewIconNameLookup[oldIconName] ?? oldIconName + return mappedName as Icon } const typeNameToIconLookup: Record = { - 'Standard.Base.Data.Table.Table': 'array_new', - 'Standard.Base.Data.Vector.Vector': 'array_new2', + 'Standard.Base.Data.Text.Text': 'text_input', + 'Standard.Base.Data.Numbers.Integer': 'number_input', + 'Standard.Base.Data.Numbers.Float': 'number_input', + 'Standard.Base.Data.Array.Array': 'array_new', + 'Standard.Base.Data.Vector.Vector': 'array_new', + 'Standard.Base.Data.Time.Date.Date': 'calendar', + 'Standard.Base.Data.Time.Date_Time.Date_Time': 'calendar', + 'Standard.Base.Data.Time.Time_Of_Day.Time_Of_Day': 'time', } export function typeNameToIcon(typeName: string): Icon { - return typeNameToIconLookup[typeName] ?? 'in_out' + return typeNameToIconLookup[typeName] ?? 'enso_logo' }