mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 18:34:03 +03:00
Use labels from the engine if they are available (#9290)
Fix small regression on develop for dropdown labels. <img width="645" alt="Screenshot 2024-03-05 at 7 09 22 PM" src="https://github.com/enso-org/enso/assets/6566674/caec9cbc-ef8d-4ac2-8ec1-cf2de909f2d4">
This commit is contained in:
parent
8e1bb16afd
commit
793fb8f48e
@ -100,8 +100,8 @@ test('Selection widgets in Data.read node', async ({ page }) => {
|
||||
const pathArg = argumentNames.filter({ has: page.getByText('path') })
|
||||
await pathArg.click()
|
||||
await expect(page.locator('.dropdownContainer')).toBeVisible()
|
||||
await dropDown.expectVisibleWithOptions(page, ['"File 1"', '"File 2"'])
|
||||
await dropDown.clickOption(page, '"File 2"')
|
||||
await dropDown.expectVisibleWithOptions(page, ['File 1', 'File 2'])
|
||||
await dropDown.clickOption(page, 'File 2')
|
||||
await expect(pathArg.locator('.WidgetText > input')).toHaveValue('File 2')
|
||||
|
||||
// Change value on `path` (dynamic config)
|
||||
@ -114,8 +114,8 @@ test('Selection widgets in Data.read node', async ({ page }) => {
|
||||
notAppliedArguments: [1],
|
||||
})
|
||||
await page.getByText('path').click()
|
||||
await dropDown.expectVisibleWithOptions(page, ['"File 1"', '"File 2"'])
|
||||
await dropDown.clickOption(page, '"File 1"')
|
||||
await dropDown.expectVisibleWithOptions(page, ['File 1', 'File 2'])
|
||||
await dropDown.clickOption(page, 'File 1')
|
||||
await expect(pathArg.locator('.WidgetText > input')).toHaveValue('File 1')
|
||||
})
|
||||
|
||||
@ -193,8 +193,8 @@ test('Managing aggregates in `aggregate` node', async ({ page }) => {
|
||||
// Set column
|
||||
const columnArg = firstItem.locator('.WidgetSelection').first()
|
||||
await columnArg.click()
|
||||
await dropDown.expectVisibleWithOptions(page, ['"column 1"', '"column 2"'])
|
||||
await dropDown.clickOption(page, '"column 1"')
|
||||
await dropDown.expectVisibleWithOptions(page, ['column 1', 'column 2'])
|
||||
await dropDown.clickOption(page, 'column 1')
|
||||
await expect(columnsArg.locator('.WidgetToken')).toContainText([
|
||||
'Aggregate_Column',
|
||||
'.',
|
||||
@ -232,8 +232,8 @@ test('Managing aggregates in `aggregate` node', async ({ page }) => {
|
||||
const secondItem = columnsArg.locator('.item > .WidgetPort > .WidgetSelection').nth(1)
|
||||
const secondColumnArg = secondItem.locator('.WidgetSelection').first()
|
||||
await secondColumnArg.click()
|
||||
await dropDown.expectVisibleWithOptions(page, ['"column 1"', '"column 2"'])
|
||||
await dropDown.clickOption(page, '"column 2"')
|
||||
await dropDown.expectVisibleWithOptions(page, ['column 1', 'column 2'])
|
||||
await dropDown.clickOption(page, 'column 2')
|
||||
await expect(secondItem.locator('.WidgetToken')).toContainText([
|
||||
'Aggregate_Column',
|
||||
'.',
|
||||
|
@ -19,6 +19,7 @@ import { Ast } from '@/util/ast'
|
||||
import { targetIsOutside } from '@/util/autoBlur'
|
||||
import { ArgumentInfoKey } from '@/util/callTree'
|
||||
import { arrayEquals } from '@/util/data/array'
|
||||
import type { Opt } from '@/util/data/opt'
|
||||
import { qnLastSegment, tryQualifiedName } from '@/util/qualifiedName'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
@ -36,13 +37,13 @@ interface Tag {
|
||||
parameters?: ArgumentWidgetConfiguration[]
|
||||
}
|
||||
|
||||
function tagFromExpression(expression: string): Tag {
|
||||
function tagFromExpression(expression: string, label?: Opt<string>): Tag {
|
||||
const qn = tryQualifiedName(expression)
|
||||
if (!qn.ok) return { expression }
|
||||
if (!qn.ok) return { expression, ...(label ? { label } : {}) }
|
||||
const entry = suggestions.entries.getEntryByQualifiedName(qn.value)
|
||||
if (entry) return tagFromEntry(entry)
|
||||
return {
|
||||
label: qnLastSegment(qn.value),
|
||||
label: label ?? qnLastSegment(qn.value),
|
||||
expression: qn.value,
|
||||
}
|
||||
}
|
||||
@ -61,14 +62,14 @@ function tagFromEntry(entry: SuggestionEntry): Tag {
|
||||
const staticTags = computed<Tag[]>(() => {
|
||||
const tags = props.input[ArgumentInfoKey]?.info?.tagValues
|
||||
if (tags == null) return []
|
||||
return tags.map(tagFromExpression)
|
||||
return tags.map((t) => tagFromExpression(t))
|
||||
})
|
||||
|
||||
const dynamicTags = computed<Tag[]>(() => {
|
||||
const config = props.input.dynamicConfig
|
||||
if (config?.kind !== 'Single_Choice') return []
|
||||
return config.values.map((value) => ({
|
||||
...tagFromExpression(value.value),
|
||||
...tagFromExpression(value.value, value.label),
|
||||
parameters: value.parameters,
|
||||
}))
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user