mirror of
https://github.com/enso-org/enso.git
synced 2024-11-26 08:52:58 +03:00
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)
This commit is contained in:
parent
1cf5ea96d6
commit
ed9e71c4eb
@ -8,7 +8,7 @@ import { injectGraphSelection } from '@/providers/graphSelection'
|
|||||||
import { useGraphStore, type Node } from '@/stores/graph'
|
import { useGraphStore, type Node } from '@/stores/graph'
|
||||||
import { useApproach } from '@/util/animation'
|
import { useApproach } from '@/util/animation'
|
||||||
import { usePointer, useResizeObserver } from '@/util/events'
|
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 type { Opt } from '@/util/opt'
|
||||||
import { Rect } from '@/util/rect'
|
import { Rect } from '@/util/rect'
|
||||||
import { Vec2 } from '@/util/vec2'
|
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 color = computed(() => graph.db.getNodeColorStyle(nodeId.value))
|
||||||
const icon = computed(() => {
|
const icon = computed(() => {
|
||||||
if (suggestionEntry.value?.iconName) {
|
if (suggestionEntry.value?.iconName) {
|
||||||
return suggestionEntry.value.iconName
|
return mapOldIconName(suggestionEntry.value.iconName)
|
||||||
}
|
}
|
||||||
|
|
||||||
const methodName = expressionInfo.value?.methodCall?.methodPointer.name
|
const methodName = expressionInfo.value?.methodCall?.methodPointer.name
|
||||||
if (methodName != null) {
|
if (methodName == null && outputTypeName.value != null) {
|
||||||
return methodNameToIcon(methodName)
|
|
||||||
} else if (outputTypeName.value != null) {
|
|
||||||
return typeNameToIcon(outputTypeName.value)
|
return typeNameToIcon(outputTypeName.value)
|
||||||
} else {
|
} else {
|
||||||
return 'in_out'
|
return 'enso_logo'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,28 +1,37 @@
|
|||||||
import type { Icon } from '@/util/iconName'
|
import type { Icon } from '@/util/iconName'
|
||||||
|
|
||||||
const methodNameToIconLookup: Record<string, Icon> = {
|
const oldIconNameToNewIconNameLookup: Record<string, string> = {
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
read: 'text',
|
dataframe_clean: 'clean_dataframe',
|
||||||
join: 'join3',
|
dataframe_map_row: 'map_row',
|
||||||
union: 'union',
|
dataframe_map_column: 'add_column',
|
||||||
set: 'edit',
|
dataframes_join: 'join3',
|
||||||
filter: 'preparation',
|
dataframes_union: 'union',
|
||||||
add_columns: 'add_column',
|
sigma: 'transform4',
|
||||||
add_rows: 'add_row',
|
io: 'in_out',
|
||||||
remove_columns: 'remove_column',
|
date_and_time: 'time',
|
||||||
remove_rows: 'remove_row',
|
spatial: 'location',
|
||||||
|
predictive: 'predict',
|
||||||
|
machine_learning: 'robot',
|
||||||
/* eslint-enable camelcase */
|
/* eslint-enable camelcase */
|
||||||
}
|
}
|
||||||
|
|
||||||
export function methodNameToIcon(methodName: string): Icon {
|
export function mapOldIconName(oldIconName: string): Icon {
|
||||||
return methodNameToIconLookup[methodName] ?? 'in_out'
|
const mappedName = oldIconNameToNewIconNameLookup[oldIconName] ?? oldIconName
|
||||||
|
return mappedName as Icon
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeNameToIconLookup: Record<string, Icon> = {
|
const typeNameToIconLookup: Record<string, Icon> = {
|
||||||
'Standard.Base.Data.Table.Table': 'array_new',
|
'Standard.Base.Data.Text.Text': 'text_input',
|
||||||
'Standard.Base.Data.Vector.Vector': 'array_new2',
|
'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 {
|
export function typeNameToIcon(typeName: string): Icon {
|
||||||
return typeNameToIconLookup[typeName] ?? 'in_out'
|
return typeNameToIconLookup[typeName] ?? 'enso_logo'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user