Skip to content

Commit b258628

Browse files
committed
Add control for rendering lots of menu items in ActionButtons story
1 parent 2a23b92 commit b258628

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

web/packages/teleterm/src/ui/DocumentCluster/ActionButtons.story.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,26 @@ import {
4040
AccessRequestButton,
4141
} from './ActionButtons';
4242

43-
type StoryProps = { vnet: boolean };
43+
type StoryProps = {
44+
vnet: boolean;
45+
lotsOfMenuItems: boolean;
46+
};
4447

4548
const meta: Meta<StoryProps> = {
4649
title: 'Teleterm/DocumentCluster/ActionButtons',
4750
component: Buttons,
4851
argTypes: {
49-
vnet: {
52+
vnet: { control: { type: 'boolean' } },
53+
lotsOfMenuItems: {
5054
control: { type: 'boolean' },
55+
description:
56+
// TODO(ravicious): Support this prop in more places than just TCP ports.
57+
'Renders long lists of options in menus. Currently works only with ports for multi-port TCP apps.',
5158
},
5259
},
5360
args: {
5461
vnet: true,
62+
lotsOfMenuItems: false,
5563
},
5664
};
5765

@@ -66,14 +74,14 @@ export function Story(props: StoryProps) {
6674
<MockAppContextProvider appContext={appContext}>
6775
<ConnectionsContextProvider>
6876
<VnetContextProvider>
69-
<Buttons />
77+
<Buttons {...props} />
7078
</VnetContextProvider>
7179
</ConnectionsContextProvider>
7280
</MockAppContextProvider>
7381
);
7482
}
7583

76-
function Buttons() {
84+
function Buttons(props: StoryProps) {
7785
return (
7886
<Flex gap={4}>
7987
<Flex gap={3} flexDirection="column">
@@ -83,7 +91,7 @@ function Buttons() {
8391
</Box>
8492
<Box>
8593
<Text>multi-port TCP app</Text>
86-
<TcpMultiPortApp />
94+
<TcpMultiPortApp lotsOfMenuItems={props.lotsOfMenuItems} />
8795
</Box>
8896
<Box>
8997
<Text>Web app</Text>
@@ -151,17 +159,23 @@ function TcpApp() {
151159
);
152160
}
153161

154-
function TcpMultiPortApp() {
162+
function TcpMultiPortApp(props: { lotsOfMenuItems: boolean }) {
163+
let tcpPorts = [
164+
{ port: 1337, endPort: 0 },
165+
{ port: 4242, endPort: 0 },
166+
{ port: 54221, endPort: 61879 },
167+
];
168+
169+
if (props.lotsOfMenuItems) {
170+
tcpPorts = new Array(50).fill(tcpPorts).flat();
171+
}
172+
155173
return (
156174
<ConnectAppActionButton
157175
app={makeApp({
158176
uri: `${testCluster.uri}/apps/bar`,
159177
endpointUri: 'tcp://localhost',
160-
tcpPorts: [
161-
{ port: 1337, endPort: 0 },
162-
{ port: 4242, endPort: 0 },
163-
{ port: 54221, endPort: 61879 },
164-
],
178+
tcpPorts,
165179
})}
166180
/>
167181
);

0 commit comments

Comments
 (0)