1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-28 23:06:37 +01:00
metamask-extension/ui/pages/confirmation/templates/flask/snap-prompt/snap-prompt.js
Guillaume Roux 85f260c22d
[FLASK] Use custom UI for dialogs (#16973)
* update dialog templates to use custom UI

* add TODO comments

* Fix showDialog hook and destructuring

* Regen LavaMoat policies

* Re-add legacy snap confirmation for now

* Fix circular dependency issue

* Revert change to token-util

* Fix lint

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2022-12-20 11:44:22 +01:00

66 lines
1.8 KiB
JavaScript

import { mapToTemplate } from '../../../../../components/app/flask/snap-ui-renderer';
import { MESSAGE_TYPE } from '../../../../../../shared/constants/app';
function getValues(pendingApproval, t, actions, _history, setInputState) {
const {
snapName,
requestData: { content, placeholder },
} = pendingApproval;
return {
content: [
{
element: 'Box',
key: 'snap-dialog-content-wrapper',
props: {
marginLeft: 4,
marginRight: 4,
},
children: {
element: 'SnapDelineator',
key: 'snap-delineator',
props: {
snapName,
},
children: [
// TODO: Replace with SnapUIRenderer when we don't need to inject the input manually.
mapToTemplate(content),
{
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;