Skip to content

Commit f9e3302

Browse files
authored
fix: reduce attribute-editor permutations page length to make tests pass (#4031)
1 parent 71a0376 commit f9e3302

File tree

2 files changed

+82
-36
lines changed

2 files changed

+82
-36
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
import React, { useState } from 'react';
4+
5+
import { Box, Button, Input, SpaceBetween } from '~components';
6+
import AttributeEditor from '~components/attribute-editor';
7+
8+
import ScreenshotArea from '../utils/screenshot-area';
9+
10+
export default function AttributeEditorPage() {
11+
const [items] = useState([
12+
{ key: 'example', value: 'value' },
13+
{ key: 'example 2', value: 'value 2' },
14+
]);
15+
16+
const definition = [
17+
{
18+
label: 'Key',
19+
control: ({ key = '' }) => <Input value={key} readOnly={true} />,
20+
},
21+
{
22+
label: 'Value',
23+
control: ({ value = '' }) => <Input value={value} readOnly={true} />,
24+
},
25+
];
26+
27+
return (
28+
<Box margin="xl">
29+
<h1>Attribute Editor - Additional Actions</h1>
30+
<ScreenshotArea>
31+
<SpaceBetween size="m">
32+
<AttributeEditor
33+
addButtonText={'Add Item'}
34+
hideAddButton={false}
35+
additionalActions={[
36+
<Button key="import" variant="normal">
37+
Import
38+
</Button>,
39+
<Button key="export" variant="normal">
40+
Export
41+
</Button>,
42+
<Button key="long-text" variant="normal">
43+
A very long button text to try out wrapping to a second row
44+
</Button>,
45+
]}
46+
items={items}
47+
definition={definition}
48+
removeButtonText="Remove"
49+
empty="No items"
50+
/>
51+
<AttributeEditor
52+
addButtonText={'Add Item'}
53+
hideAddButton={true}
54+
additionalActions={[
55+
<Button key="import" variant="primary">
56+
Import
57+
</Button>,
58+
<Button key="export" variant="normal">
59+
Export
60+
</Button>,
61+
<Button key="long-text" variant="normal">
62+
A very long button text to try out wrapping to a second row
63+
</Button>,
64+
]}
65+
items={items}
66+
definition={definition}
67+
removeButtonText="Remove"
68+
empty="No items"
69+
/>
70+
<AttributeEditor
71+
addButtonText={'Add Item'}
72+
hideAddButton={true}
73+
items={items}
74+
definition={definition}
75+
removeButtonText="Remove"
76+
empty="No items"
77+
/>
78+
</SpaceBetween>
79+
</ScreenshotArea>
80+
</Box>
81+
);
82+
}

pages/attribute-editor/permutations.page.tsx

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import React from 'react';
44

55
import AttributeEditor, { AttributeEditorProps } from '~components/attribute-editor';
66
import Box from '~components/box';
7-
import Button from '~components/button';
87
import Input from '~components/input';
98
import StatusIndicator from '~components/status-indicator';
109

@@ -145,41 +144,6 @@ export const permutations = createPermutations<AttributeEditorProps<Item>>([
145144
addButtonText: ['Add item'],
146145
removeButtonText: ['Remove item'],
147146
},
148-
{
149-
definition: [definition2],
150-
items: [defaultItems],
151-
addButtonText: ['Add item'],
152-
removeButtonText: ['Remove item'],
153-
additionalActions: [
154-
<Button key="test-button" variant="normal">
155-
Test Button
156-
</Button>,
157-
[
158-
<Button key="import" variant="normal">
159-
Import
160-
</Button>,
161-
<Button key="export" variant="normal">
162-
Export
163-
</Button>,
164-
<Button key="long-text" variant="normal">
165-
A very long button text to try out wrapping to a second row
166-
</Button>,
167-
],
168-
],
169-
},
170-
{
171-
definition: [definition2],
172-
items: [defaultItems],
173-
removeButtonText: ['Remove item'],
174-
hideAddButton: [true],
175-
addButtonText: ['Add item'],
176-
additionalActions: [
177-
<Button key="add-custom" variant="primary">
178-
Add custom item
179-
</Button>,
180-
undefined,
181-
],
182-
},
183147
]);
184148

185149
export default function AttributeEditorPermutations() {

0 commit comments

Comments
 (0)