2022-12-20 11:44:22 +01:00
|
|
|
import { mapToTemplate } from '../../../../../components/app/flask/snap-ui-renderer';
|
2022-12-01 16:46:06 +01:00
|
|
|
import { MESSAGE_TYPE } from '../../../../../../shared/constants/app';
|
2023-04-03 18:04:30 +02:00
|
|
|
import { DelineatorType } from '../../../../../helpers/constants/flask';
|
2022-12-01 16:46:06 +01:00
|
|
|
|
|
|
|
function getValues(pendingApproval, t, actions, _history, setInputState) {
|
2022-12-20 11:44:22 +01:00
|
|
|
const {
|
|
|
|
snapName,
|
|
|
|
requestData: { content, placeholder },
|
|
|
|
} = pendingApproval;
|
2022-12-01 16:46:06 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
content: [
|
|
|
|
{
|
|
|
|
element: 'Box',
|
|
|
|
key: 'snap-dialog-content-wrapper',
|
|
|
|
props: {
|
|
|
|
marginLeft: 4,
|
|
|
|
marginRight: 4,
|
|
|
|
},
|
|
|
|
children: {
|
|
|
|
element: 'SnapDelineator',
|
|
|
|
key: 'snap-delineator',
|
|
|
|
props: {
|
2023-04-03 18:04:30 +02:00
|
|
|
type: DelineatorType.Content,
|
2022-12-01 16:46:06 +01:00
|
|
|
snapName,
|
|
|
|
},
|
|
|
|
children: [
|
2022-12-20 11:44:22 +01:00
|
|
|
// TODO: Replace with SnapUIRenderer when we don't need to inject the input manually.
|
|
|
|
mapToTemplate(content),
|
2022-12-01 16:46:06 +01:00
|
|
|
{
|
|
|
|
element: 'div',
|
|
|
|
key: 'snap-prompt-container',
|
|
|
|
children: {
|
|
|
|
element: 'TextField',
|
|
|
|
key: 'snap-prompt-input',
|
|
|
|
props: {
|
|
|
|
className: 'snap-prompt-input',
|
|
|
|
placeholder,
|
|
|
|
max: 300,
|
|
|
|
onChange: (event) => {
|
|
|
|
const inputValue = event.target.value ?? '';
|
|
|
|
setInputState(MESSAGE_TYPE.SNAP_DIALOG_PROMPT, inputValue);
|
|
|
|
},
|
|
|
|
theme: 'bordered',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
className: 'snap-prompt',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
cancelText: t('cancel'),
|
|
|
|
submitText: t('submit'),
|
|
|
|
onSubmit: (inputValue) =>
|
|
|
|
actions.resolvePendingApproval(pendingApproval.id, inputValue),
|
|
|
|
onCancel: () => actions.resolvePendingApproval(pendingApproval.id, null),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const snapConfirm = {
|
|
|
|
getValues,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default snapConfirm;
|