2023-02-02 21:15:26 +01:00
|
|
|
import { TypographyVariant } from '../../../../../helpers/constants/design-system';
|
2022-12-20 11:44:22 +01:00
|
|
|
import { mapToTemplate } from '../../../../../components/app/flask/snap-ui-renderer';
|
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) {
|
2022-12-20 11:44:22 +01:00
|
|
|
const {
|
|
|
|
snapName,
|
|
|
|
requestData: { content, title, description, textAreaContent },
|
|
|
|
} = 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,
|
|
|
|
},
|
2022-12-20 11:44:22 +01:00
|
|
|
// TODO: Replace with SnapUIRenderer when we don't need to inject the input manually.
|
|
|
|
// TODO: Remove ternary once snap_confirm has been removed.
|
|
|
|
children: content
|
|
|
|
? mapToTemplate(content)
|
|
|
|
: [
|
|
|
|
{
|
|
|
|
element: 'Typography',
|
|
|
|
key: 'title',
|
|
|
|
children: title,
|
|
|
|
props: {
|
2023-02-02 21:15:26 +01:00
|
|
|
variant: TypographyVariant.H3,
|
2022-12-20 11:44:22 +01:00
|
|
|
fontWeight: 'bold',
|
|
|
|
boxProps: {
|
|
|
|
marginBottom: 4,
|
2022-12-01 16:46:06 +01:00
|
|
|
},
|
|
|
|
},
|
2022-12-20 11:44:22 +01:00
|
|
|
},
|
|
|
|
...(description
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
element: 'Typography',
|
|
|
|
key: 'subtitle',
|
|
|
|
children: description,
|
|
|
|
props: {
|
2023-02-02 21:15:26 +01:00
|
|
|
variant: TypographyVariant.H6,
|
2022-12-20 11:44:22 +01:00
|
|
|
boxProps: {
|
|
|
|
marginBottom: 4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: []),
|
|
|
|
...(textAreaContent
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
element: 'Copyable',
|
|
|
|
key: 'snap-dialog-content-text',
|
|
|
|
props: {
|
|
|
|
text: textAreaContent,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: []),
|
|
|
|
],
|
2022-12-01 16:46:06 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
cancelText: t('reject'),
|
|
|
|
submitText: t('approveButtonText'),
|
|
|
|
onSubmit: () => actions.resolvePendingApproval(pendingApproval.id, true),
|
|
|
|
onCancel: () => actions.resolvePendingApproval(pendingApproval.id, false),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const snapConfirmation = {
|
|
|
|
getValues,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default snapConfirmation;
|