Skip to content

Commit 0334cda

Browse files
committed
abiity to expand output node for bigger view
1 parent 55e62aa commit 0334cda

3 files changed

Lines changed: 87 additions & 4 deletions

File tree

src/components/atoms/Editor.css

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
.cm-editor {
2-
height: 100%;
3-
width: 100%;
4-
min-width: 288px;
5-
resize: both;
2+
max-width: 384px;
3+
max-height: 384px;
64
overflow: auto !important;
75
}
86
.cm-scroller {

src/components/molecules/flow/nodes/OutputNode.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ import * as React from 'react';
22
import { PropTypes } from 'prop-types';
33
import FlowNode from 'components/atoms/flow/FlowNode';
44
import { Editor } from 'components/atoms/Editor';
5+
import { ArrowsPointingOutIcon } from '@heroicons/react/24/outline';
6+
import OuputNodeExpandedModal from 'components/molecules/modals/OutputNodeExpandedModal';
7+
import Tippy from '@tippyjs/react';
8+
import 'tippy.js/dist/tippy.css';
59

610
const OutputNode = ({ id, data }) => {
11+
const [outputExpandedModal, setOutputExpandedModal] = React.useState(false);
12+
713
return (
814
<FlowNode
915
title='Output'
@@ -12,13 +18,27 @@ const OutputNode = ({ id, data }) => {
1218
handleRight={true}
1319
handleRightData={{ type: 'source' }}
1420
>
21+
{data.output ? (
22+
<button type='button' onClick={() => setOutputExpandedModal(true)}>
23+
<Tippy content='Expand' placement='top'>
24+
<ArrowsPointingOutIcon className='w-5 h-5' />
25+
</Tippy>
26+
</button>
27+
) : (
28+
<></>
29+
)}
1530
<div className='w-full text-xs text-gray-900 border border-gray-300 rounded-lg nodrag nowheel min-w-72 bg-gray-50 outline-blue-300 focus:border-blue-100 focus:ring-blue-100'>
1631
{data.output ? (
1732
<Editor name='output-text' value={JSON.stringify(data.output, null, 2)} readOnly={true} />
1833
) : (
1934
<div className='p-2'>{'Run flow to see data'}</div>
2035
)}
2136
</div>
37+
<OuputNodeExpandedModal
38+
closeFn={() => setOutputExpandedModal(false)}
39+
open={outputExpandedModal}
40+
data={data.output}
41+
/>
2242
</FlowNode>
2343
);
2444
};
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import React, { Fragment, useState } from 'react';
2+
import { PropTypes } from 'prop-types';
3+
import { Dialog, Transition, Listbox } from '@headlessui/react';
4+
import Button from 'components/atoms/common/Button';
5+
import { BUTTON_INTENT_TYPES, BUTTON_TYPES, GENAI_MODELS } from 'constants/Common';
6+
import { CheckIcon, ChevronUpDownIcon } from '@heroicons/react/20/solid';
7+
import { Square3Stack3DIcon } from '@heroicons/react/24/outline';
8+
import { generateFlowData } from '../flow/flowtestai';
9+
import { init } from '../flow';
10+
import useCanvasStore from 'stores/CanvasStore';
11+
import { toast } from 'react-toastify';
12+
import { isEqual } from 'lodash';
13+
import useCommonStore from 'stores/CommonStore';
14+
import useCollectionStore from 'stores/CollectionStore';
15+
import { promiseWithTimeout } from 'utils/common';
16+
import { Editor } from 'components/atoms/Editor';
17+
18+
const OuputNodeExpandedModal = ({ closeFn = () => null, open = false, data }) => {
19+
return (
20+
<Transition appear show={open} as={Fragment}>
21+
<Dialog as='div' className='relative z-10' onClose={closeFn}>
22+
<Transition.Child
23+
as={Fragment}
24+
enter='ease-out duration-300'
25+
enterFrom='opacity-0'
26+
enterTo='opacity-100'
27+
leave='ease-in duration-200'
28+
leaveFrom='opacity-100'
29+
leaveTo='opacity-0'
30+
>
31+
<div className='fixed inset-0 bg-black/25' />
32+
</Transition.Child>
33+
34+
<div className='fixed inset-0 overflow-y-auto'>
35+
<div className='flex items-center justify-center min-h-full p-4 text-center'>
36+
<Transition.Child
37+
as={Fragment}
38+
enter='ease-out duration-300'
39+
enterFrom='opacity-0 scale-95'
40+
enterTo='opacity-100 scale-100'
41+
leave='ease-in duration-200'
42+
leaveFrom='opacity-100 scale-100'
43+
leaveTo='opacity-0 scale-95'
44+
>
45+
<Dialog.Panel className='w-full max-w-2xl p-6 overflow-hidden text-left align-middle transition-all transform bg-white rounded shadow-xl'>
46+
<Dialog.Title as='h3' className='pb-4 text-lg font-semibold text-center border-b border-gray-300'>
47+
Ouput
48+
</Dialog.Title>
49+
<div className='mt-6'>
50+
<Editor name='output-text' value={JSON.stringify(data, null, 2)} readOnly={true} />
51+
</div>
52+
</Dialog.Panel>
53+
</Transition.Child>
54+
</div>
55+
</div>
56+
</Dialog>
57+
</Transition>
58+
);
59+
};
60+
61+
OuputNodeExpandedModal.propTypes = {
62+
closeFn: PropTypes.func.isRequired,
63+
open: PropTypes.boolean.isRequired,
64+
};
65+
export default OuputNodeExpandedModal;

0 commit comments

Comments
 (0)