2023-01-16 09:34:12 +00:00
|
|
|
import React from 'react';
|
2023-08-17 09:20:31 +00:00
|
|
|
import Input from '../Input';
|
2024-05-14 08:11:11 +00:00
|
|
|
import Trash from '@/_ui/Icon/solidIcons/Trash';
|
|
|
|
|
import { ButtonSolid } from '@/_ui/AppButton/AppButton';
|
|
|
|
|
import AddRectangle from '@/_ui/Icon/bulkIcons/AddRectangle';
|
|
|
|
|
import '@/_ui/HttpHeaders/sourceEditorStyles.scss';
|
|
|
|
|
import InfoIcon from '@assets/images/icons/info.svg';
|
2023-01-16 09:34:12 +00:00
|
|
|
|
2025-02-04 13:29:19 +00:00
|
|
|
export default ({
|
|
|
|
|
options,
|
|
|
|
|
addNewKeyValuePair,
|
|
|
|
|
removeKeyValuePair,
|
|
|
|
|
keyValuePairValueChanged,
|
|
|
|
|
workspaceConstants,
|
2025-02-25 06:52:50 +00:00
|
|
|
isDisabled,
|
|
|
|
|
width,
|
2025-02-04 13:29:19 +00:00
|
|
|
}) => {
|
2024-05-14 08:11:11 +00:00
|
|
|
const darkMode = localStorage.getItem('darkMode') === 'true';
|
2025-02-25 06:52:50 +00:00
|
|
|
|
2023-01-16 09:34:12 +00:00
|
|
|
return (
|
2024-05-14 08:11:11 +00:00
|
|
|
<div className="table-content-wrapper">
|
|
|
|
|
{options.length === 0 && (
|
2025-02-25 06:52:50 +00:00
|
|
|
<div className="empty-key-value">
|
2024-05-14 08:11:11 +00:00
|
|
|
<InfoIcon style={{ width: '16px', marginRight: '5px' }} />
|
|
|
|
|
<span>There are no key value pairs added</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{options.map((option, index) => (
|
2024-07-01 10:02:24 +00:00
|
|
|
<div className="d-flex align-items-top row-container query-manager-border-color" key={index}>
|
2024-05-14 08:11:11 +00:00
|
|
|
<Input
|
|
|
|
|
type="text"
|
|
|
|
|
className="input-control"
|
|
|
|
|
onChange={(e) => keyValuePairValueChanged(e.target.value, 0, index)}
|
|
|
|
|
value={option[0]}
|
|
|
|
|
workspaceConstants={workspaceConstants}
|
2024-05-15 09:04:12 +00:00
|
|
|
placeholder="Key"
|
2024-05-14 08:11:11 +00:00
|
|
|
autoComplete="off"
|
2025-02-25 06:52:50 +00:00
|
|
|
disabled={isDisabled}
|
2024-05-14 08:11:11 +00:00
|
|
|
style={{
|
|
|
|
|
flex: 1,
|
2025-02-25 06:52:50 +00:00
|
|
|
width: width ? width : '300px',
|
2024-05-14 08:11:11 +00:00
|
|
|
borderTopRightRadius: '0',
|
|
|
|
|
borderBottomRightRadius: '0',
|
|
|
|
|
borderRight: 'none',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<Input
|
|
|
|
|
type="text"
|
|
|
|
|
value={option[1]}
|
2024-05-15 09:04:12 +00:00
|
|
|
placeholder="Value"
|
2024-05-14 08:11:11 +00:00
|
|
|
autoComplete="off"
|
|
|
|
|
className="input-control"
|
|
|
|
|
onChange={(e) => keyValuePairValueChanged(e.target.value, 1, index)}
|
|
|
|
|
workspaceConstants={workspaceConstants}
|
2025-02-25 06:52:50 +00:00
|
|
|
disabled={isDisabled}
|
2024-05-14 08:11:11 +00:00
|
|
|
style={{
|
|
|
|
|
flex: 2,
|
2025-02-25 06:52:50 +00:00
|
|
|
width: width ? width : '316px',
|
2024-05-14 08:11:11 +00:00
|
|
|
borderTopLeftRadius: '0',
|
|
|
|
|
borderBottomLeftRadius: '0',
|
|
|
|
|
borderTopRightRadius: '0',
|
|
|
|
|
borderBottomRightRadius: '0',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
className={`d-flex justify-content-center align-items-center delete-field-option bg-transparent border-0 rounded-0 border-top border-bottom border-end rounded-end ${
|
|
|
|
|
darkMode ? 'delete-field-option-dark' : ''
|
|
|
|
|
}`}
|
|
|
|
|
style={{ height: '35px' }}
|
|
|
|
|
role="button"
|
2025-02-25 06:52:50 +00:00
|
|
|
disabled={isDisabled}
|
2024-05-14 08:11:11 +00:00
|
|
|
onClick={() => removeKeyValuePair(index)}
|
|
|
|
|
>
|
|
|
|
|
<Trash fill="var(--slate9)" style={{ height: '16px' }} />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
<div className="d-flex mb-2" style={{ height: '16px' }}>
|
2024-07-01 10:02:24 +00:00
|
|
|
<ButtonSolid
|
|
|
|
|
variant="ghostBlue"
|
|
|
|
|
size="sm"
|
|
|
|
|
onClick={() => addNewKeyValuePair(options)}
|
|
|
|
|
style={{ gap: '0px', fontSize: '12px', fontWeight: '500', padding: '0px 9px' }}
|
2025-02-25 06:52:50 +00:00
|
|
|
disabled={isDisabled}
|
2024-07-01 10:02:24 +00:00
|
|
|
>
|
2024-05-14 08:11:11 +00:00
|
|
|
<AddRectangle width="15" fill="#3E63DD" opacity="1" secondaryFill="#ffffff" />
|
2025-02-25 06:52:50 +00:00
|
|
|
Add
|
2024-05-14 08:11:11 +00:00
|
|
|
</ButtonSolid>
|
|
|
|
|
</div>
|
2023-01-16 09:34:12 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|