feat: add import/export buttons for single config file
parent
a2ca88baf2
commit
b172d90b2b
|
|
@ -1,6 +1,9 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useDispatch } from 'react-redux';
|
||||||
|
import { Button } from '@strapi/design-system';
|
||||||
import RDV, { DiffMethod } from 'react-diff-viewer-continued';
|
import RDV, { DiffMethod } from 'react-diff-viewer-continued';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
|
import { getFetchClient, useNotification } from '@strapi/strapi/admin';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An issue with the diff-viewer library causes a difference in the way the library is exported.
|
* An issue with the diff-viewer library causes a difference in the way the library is exported.
|
||||||
|
|
@ -23,9 +26,15 @@ import {
|
||||||
Grid,
|
Grid,
|
||||||
Typography,
|
Typography,
|
||||||
} from '@strapi/design-system';
|
} from '@strapi/design-system';
|
||||||
|
import ConfirmModal from '../ConfirmModal';
|
||||||
|
import { exportAllConfig, importAllConfig } from '../../state/actions/Config';
|
||||||
|
|
||||||
const ConfigDiff = ({ oldValue, newValue, configName, trigger }) => {
|
const ConfigDiff = ({ oldValue, newValue, configName, trigger }) => {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const { toggleNotification } = useNotification();
|
||||||
|
const { post, get } = getFetchClient();
|
||||||
|
const commonHeadingStyle = { paddingRight: '2rem' };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal.Root>
|
<Modal.Root>
|
||||||
|
|
@ -40,11 +49,24 @@ const ConfigDiff = ({ oldValue, newValue, configName, trigger }) => {
|
||||||
</Modal.Header>
|
</Modal.Header>
|
||||||
<Modal.Body>
|
<Modal.Body>
|
||||||
<Grid.Root paddingBottom={4} style={{ textAlign: 'center' }}>
|
<Grid.Root paddingBottom={4} style={{ textAlign: 'center' }}>
|
||||||
<Grid.Item col={6}>
|
<Grid.Item col={6} style={{ justifyContent: 'center' }}>
|
||||||
<Typography variant="delta" style={{ width: '100%' }}>{formatMessage({ id: 'config-sync.ConfigDiff.SyncDirectory' })}</Typography>
|
<Typography variant="delta" style={commonHeadingStyle}>{formatMessage({ id: 'config-sync.ConfigDiff.SyncDirectory' })}
|
||||||
|
</Typography>
|
||||||
|
<ConfirmModal
|
||||||
|
type="import"
|
||||||
|
trigger={<Button title="Import config into DB for this file only">Import</Button>}
|
||||||
|
onSubmit={(force) => dispatch(importAllConfig([configName], force, toggleNotification, formatMessage, post, get))}
|
||||||
|
/>
|
||||||
</Grid.Item>
|
</Grid.Item>
|
||||||
<Grid.Item col={6}>
|
<Grid.Item col={6} style={{ justifyContent: 'center' }}>
|
||||||
<Typography variant="delta" style={{ width: '100%' }}>{formatMessage({ id: 'config-sync.ConfigDiff.Database' })}</Typography>
|
<Typography variant="delta" style={commonHeadingStyle}>
|
||||||
|
{formatMessage({ id: 'config-sync.ConfigDiff.Database' })}
|
||||||
|
</Typography>
|
||||||
|
<ConfirmModal
|
||||||
|
type="export"
|
||||||
|
trigger={<Button title="Export DB config for this file only">Export</Button>}
|
||||||
|
onSubmit={() => dispatch(exportAllConfig([configName], toggleNotification, formatMessage, post, get))}
|
||||||
|
/>
|
||||||
</Grid.Item>
|
</Grid.Item>
|
||||||
</Grid.Root>
|
</Grid.Root>
|
||||||
<Typography variant="pi">
|
<Typography variant="pi">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue