Skip to content

Commit 4f0cecc

Browse files
authored
Merge pull request #147 from pluginpal/feature/beta-fixes
Feature/beta fixes
2 parents da2f064 + d41f292 commit 4f0cecc

File tree

16 files changed

+569
-843
lines changed

16 files changed

+569
-843
lines changed

.github/workflows/tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ jobs:
4141
node-version: ${{ matrix.node }}
4242
cache: 'yarn'
4343
- name: Install dependencies plugin
44-
run: yarn --no-lockfile --unsafe-perm --production
44+
run: yarn --no-lockfile --unsafe-perm
45+
- name: Push the package to yalc
46+
run: yarn build
47+
- name: Add yalc package to the playground
48+
run: yarn playground:yalc-add
4549
- name: Install dependencies playground
46-
run: yarn playground:install --unsafe-perm
50+
run: cd playground && yarn install --unsafe-perm
4751
- name: Build playground
4852
run: yarn playground:build
4953
- name: Run test

CONTRIBUTING.md

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,55 @@ We want this community to be friendly and respectful to each other. Please follo
44

55
## Development Workflow
66

7-
To get started with the project, make sure you have a local instance of Strapi running.
8-
See the [Strapi docs](https://github.com/strapi/strapi#getting-started) on how to setup a Strapi project.
7+
This plugin provides a local development instance of Strapi to develop it's features. We call this instance `playground` and it can be found in the playground folder in the root of the project. For that reason it is not needed to have your own Strapi instance running to work on this plugin. Just clone the repo and you're ready to go!
98

10-
#### 1. Fork the [repository](https://github.com/boazpoolman/strapi-plugin-config-sync)
9+
#### 1. Fork the [repository](https://github.com/pluginpal/strapi-plugin-config-sync)
1110

12-
[Go to the repository](https://github.com/boazpoolman/strapi-plugin-config-sync) and fork it to your own GitHub account.
11+
[Go to the repository](https://github.com/pluginpal/strapi-plugin-config-sync) and fork it to your own GitHub account.
1312

14-
#### 2. Clone from your repository into the plugins folder
13+
#### 2. Clone the forked repository
1514

1615
```bash
17-
cd YOUR_STRAPI_PROJECT/src/plugins
18-
git clone [email protected]:YOUR_USERNAME/strapi-plugin-config-sync.git config-sync
16+
git clone [email protected]:YOUR_USERNAME/strapi-plugin-config-sync.git
1917
```
2018

2119
#### 3. Install the dependencies
2220

23-
Go to the plugin and install it's dependencies.
21+
Go to the folder and install the dependencies
2422

2523
```bash
26-
cd YOUR_STRAPI_PROJECT/src/plugins/config-sync/ && yarn plugin:install
24+
cd strapi-plugin-config-sync && yarn install
2725
```
2826

29-
#### 4. Enable the plugin
27+
#### 4. Install the playground dependencies
3028

31-
Add the following lines to the `config/plugins.js` file in your Strapi project.
29+
Run this in the root of the repository
3230

33-
```
34-
const path = require('path');
35-
// ...
36-
{
37-
'config-sync': {
38-
enabled: true,
39-
resolve: path.resolve(__dirname, '../src/plugins/config-sync'),
40-
},
41-
}
31+
```bash
32+
yarn playground:install
4233
```
4334

44-
#### 5. Rebuild your Strapi project
35+
#### 5. Run the compiler of the plugin
4536

46-
Rebuild your strapi project to build the admin part of the plugin.
37+
We use `yalc` to publish the package to a local registry. Run the following command o watch for changes and push to `yalc` every time a change is made:
4738

4839
```bash
49-
cd YOUR_STRAPI_PROJECT && yarn build
40+
yarn develop
5041
```
5142

52-
#### 6. Running the administration panel in development mode
43+
#### 6. Start the playground instance
5344

54-
**Start the administration panel server for development**
45+
Leave the watcher running, open up a new terminal window and browse back to the root of the plugin repo. Run the following command:
5546

5647
```bash
57-
cd YOUR_STRAPI_PROJECT && yarn develop --watch-admin
48+
yarn playground:develop
5849
```
5950

60-
The administration panel will be available at http://localhost:8080/admin
51+
This will start the playground instance that will have the plugin installed from the `yalc` registry. Browse to http://localhost:1337 and create a test admin user to log in to the playground.
52+
53+
#### 7. Start your contribution!
54+
55+
You can now start working on your contribution. If you had trouble setting up this testing environment please feel free to report an issue on Github.
6156

6257
### Commit message convention
6358

@@ -82,12 +77,10 @@ The `package.json` file contains various scripts for common tasks:
8277

8378
- `yarn eslint`: lint files with ESLint.
8479
- `yarn eslint:fix`: auto-fix ESLint issues.
85-
- `yarn test:unit`: run unit tests with Jest.
80+
- `yarn test:integration`: run integration tests with Jest.
8681

8782
### Sending a pull request
8883

89-
> **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
90-
9184
When you're sending a pull request:
9285

9386
- Prefer small pull requests focused on one change.

admin/src/components/ActionButtons/index.jsx

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React, { useState } from 'react';
1+
import React from 'react';
22
import styled from 'styled-components';
33
import { useDispatch, useSelector } from 'react-redux';
44
import { isEmpty } from 'lodash';
5-
import { Button } from '@strapi/design-system';
5+
import { Button, Typography } from '@strapi/design-system';
66
import { Map } from 'immutable';
77
import { getFetchClient, useNotification } from '@strapi/strapi/admin';
88
import { useIntl } from 'react-intl';
@@ -14,38 +14,32 @@ const ActionButtons = () => {
1414
const { post, get } = getFetchClient();
1515
const dispatch = useDispatch();
1616
const { toggleNotification } = useNotification();
17-
const [modalIsOpen, setModalIsOpen] = useState(false);
18-
const [actionType, setActionType] = useState('');
1917
const partialDiff = useSelector((state) => state.getIn(['config', 'partialDiff'], Map({}))).toJS();
2018
const { formatMessage } = useIntl();
2119

22-
const closeModal = () => {
23-
setActionType('');
24-
setModalIsOpen(false);
25-
};
26-
27-
const openModal = (type) => {
28-
setActionType(type);
29-
setModalIsOpen(true);
30-
};
31-
3220
return (
3321
<ActionButtonsStyling>
34-
<Button disabled={isEmpty(partialDiff)} onClick={() => openModal('import')}>
35-
{formatMessage({ id: 'config-sync.Buttons.Import' })}
36-
</Button>
37-
<Button disabled={isEmpty(partialDiff)} onClick={() => openModal('export')}>
38-
{formatMessage({ id: 'config-sync.Buttons.Export' })}
39-
</Button>
40-
{!isEmpty(partialDiff) && (
41-
<h4 style={{ display: 'inline' }}>{Object.keys(partialDiff).length} {Object.keys(partialDiff).length === 1 ? "config change" : "config changes"}</h4>
42-
)}
4322
<ConfirmModal
44-
isOpen={modalIsOpen}
45-
onClose={closeModal}
46-
type={actionType}
47-
onSubmit={(force) => actionType === 'import' ? dispatch(importAllConfig(partialDiff, force, toggleNotification, formatMessage, post, get)) : dispatch(exportAllConfig(partialDiff, toggleNotification, formatMessage, post, get))}
23+
type="import"
24+
trigger={(
25+
<Button disabled={isEmpty(partialDiff)}>
26+
{formatMessage({ id: 'config-sync.Buttons.Import' })}
27+
</Button>
28+
)}
29+
onSubmit={(force) => dispatch(importAllConfig(partialDiff, force, toggleNotification, formatMessage, post, get))}
4830
/>
31+
<ConfirmModal
32+
type="export"
33+
trigger={(
34+
<Button disabled={isEmpty(partialDiff)}>
35+
{formatMessage({ id: 'config-sync.Buttons.Export' })}
36+
</Button>
37+
)}
38+
onSubmit={(force) => dispatch(exportAllConfig(partialDiff, toggleNotification, formatMessage, post, get))}
39+
/>
40+
{!isEmpty(partialDiff) && (
41+
<Typography variant="epsilon">{Object.keys(partialDiff).length} {Object.keys(partialDiff).length === 1 ? "config change" : "config changes"}</Typography>
42+
)}
4943
</ActionButtonsStyling>
5044
);
5145
};

admin/src/components/ConfigDiff/index.jsx

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,39 @@ import {
88
Typography,
99
} from '@strapi/design-system';
1010

11-
const ConfigDiff = ({ isOpen, onClose, oldValue, newValue, configName }) => {
11+
const ConfigDiff = ({ oldValue, newValue, configName, trigger }) => {
1212
const { formatMessage } = useIntl();
13-
if (!isOpen) return null;
1413

1514
return (
16-
<Modal.Root
17-
onClose={onClose}
18-
labelledBy="title"
19-
>
20-
<Modal.Header>
21-
<Typography variant="omega" fontWeight="bold" textColor="neutral800">
22-
{formatMessage({ id: 'config-sync.ConfigDiff.Title' })} {configName}
23-
</Typography>
24-
</Modal.Header>
25-
<Modal.Body>
26-
<Grid.Root paddingBottom={4} style={{ textAlign: 'center' }}>
27-
<Grid.Item col={6}>
28-
<Typography variant="delta">{formatMessage({ id: 'config-sync.ConfigDiff.SyncDirectory' })}</Typography>
29-
</Grid.Item>
30-
<Grid.Item col={6}>
31-
<Typography variant="delta">{formatMessage({ id: 'config-sync.ConfigDiff.Database' })}</Typography>
32-
</Grid.Item>
33-
</Grid.Root>
34-
<ReactDiffViewer
35-
oldValue={JSON.stringify(oldValue, null, 2)}
36-
newValue={JSON.stringify(newValue, null, 2)}
37-
splitView
38-
compareMethod={DiffMethod.WORDS}
39-
/>
40-
</Modal.Body>
15+
<Modal.Root>
16+
<Modal.Trigger>
17+
{trigger}
18+
</Modal.Trigger>
19+
<Modal.Content>
20+
<Modal.Header>
21+
<Typography variant="omega" fontWeight="bold" textColor="neutral800">
22+
{formatMessage({ id: 'config-sync.ConfigDiff.Title' })} {configName}
23+
</Typography>
24+
</Modal.Header>
25+
<Modal.Body>
26+
<Grid.Root paddingBottom={4} style={{ textAlign: 'center' }}>
27+
<Grid.Item col={6}>
28+
<Typography variant="delta" style={{ width: '100%' }}>{formatMessage({ id: 'config-sync.ConfigDiff.SyncDirectory' })}</Typography>
29+
</Grid.Item>
30+
<Grid.Item col={6}>
31+
<Typography variant="delta" style={{ width: '100%' }}>{formatMessage({ id: 'config-sync.ConfigDiff.Database' })}</Typography>
32+
</Grid.Item>
33+
</Grid.Root>
34+
<Typography variant="pi">
35+
<ReactDiffViewer
36+
oldValue={JSON.stringify(oldValue, null, 2)}
37+
newValue={JSON.stringify(newValue, null, 2)}
38+
splitView
39+
compareMethod={DiffMethod.WORDS}
40+
/>
41+
</Typography>
42+
</Modal.Body>
43+
</Modal.Content>
4144
</Modal.Root>
4245
);
4346
};

admin/src/components/ConfigList/ConfigListRow/index.jsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
2-
import { Tr, Td, Checkbox } from '@strapi/design-system';
2+
import { Tr, Td, Checkbox, Typography } from '@strapi/design-system';
33

4-
const CustomRow = ({ row, checked, updateValue }) => {
4+
const CustomRow = ({ row, checked, updateValue, ...props }) => {
55
const { configName, configType, state, onClick } = row;
66

77
const stateStyle = (stateStr) => {
@@ -34,6 +34,7 @@ const CustomRow = ({ row, checked, updateValue }) => {
3434

3535
return (
3636
<Tr
37+
{...props}
3738
onClick={(e) => {
3839
if (e.target.type !== 'checkbox') {
3940
onClick(configType, configName);
@@ -44,18 +45,18 @@ const CustomRow = ({ row, checked, updateValue }) => {
4445
<Td>
4546
<Checkbox
4647
aria-label={`Select ${configName}`}
47-
value={checked}
48-
onValueChange={updateValue}
48+
checked={checked}
49+
onCheckedChange={updateValue}
4950
/>
5051
</Td>
51-
<Td>
52-
<p>{configName}</p>
52+
<Td onClick={(e) => props.onClick(e)}>
53+
<Typography variant="omega">{configName}</Typography>
5354
</Td>
54-
<Td>
55-
<p>{configType}</p>
55+
<Td onClick={(e) => props.onClick(e)}>
56+
<Typography variant="omega">{configType}</Typography>
5657
</Td>
57-
<Td>
58-
<p style={stateStyle(state)}>{state}</p>
58+
<Td onClick={(e) => props.onClick(e)}>
59+
<Typography variant="omega" style={stateStyle(state)}>{state}</Typography>
5960
</Td>
6061
</Tr>
6162
);

admin/src/components/ConfigList/index.jsx

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { setConfigPartialDiffInState } from '../../state/actions/Config';
2222

2323

2424
const ConfigList = ({ diff, isLoading }) => {
25-
const [openModal, setOpenModal] = useState(false);
2625
const [originalConfig, setOriginalConfig] = useState({});
2726
const [newConfig, setNewConfig] = useState({});
2827
const [cName, setCname] = useState('');
@@ -72,7 +71,6 @@ const ConfigList = ({ diff, isLoading }) => {
7271
setOriginalConfig(diff.fileConfig[`${configType}.${configName}`]);
7372
setNewConfig(diff.databaseConfig[`${configType}.${configName}`]);
7473
setCname(`${configType}.${configName}`);
75-
setOpenModal(true);
7674
},
7775
});
7876
});
@@ -89,13 +87,6 @@ const ConfigList = ({ diff, isLoading }) => {
8987
dispatch(setConfigPartialDiffInState(newPartialDiff));
9088
}, [checkedItems]);
9189

92-
const closeModal = () => {
93-
setOriginalConfig({});
94-
setNewConfig({});
95-
setCname('');
96-
setOpenModal(false);
97-
};
98-
9990
if (isLoading) {
10091
return (
10192
<div style={{ textAlign: 'center', marginTop: 40 }}>
@@ -117,22 +108,14 @@ const ConfigList = ({ diff, isLoading }) => {
117108

118109
return (
119110
<div>
120-
<ConfigDiff
121-
isOpen={openModal}
122-
oldValue={originalConfig}
123-
newValue={newConfig}
124-
onClose={closeModal}
125-
configName={cName}
126-
/>
127111
<Table colCount={4} rowCount={rows.length + 1}>
128112
<Thead>
129113
<Tr>
130114
<Th>
131115
<Checkbox
132116
aria-label={formatMessage({ id: 'config-sync.ConfigList.SelectAll' })}
133-
indeterminate={isIndeterminate}
134-
onValueChange={(value) => setCheckedItems(checkedItems.map(() => value))}
135-
value={allChecked}
117+
checked={isIndeterminate ? "indeterminate" : allChecked}
118+
onCheckedChange={(value) => setCheckedItems(checkedItems.map(() => value))}
136119
/>
137120
</Th>
138121
<Th>
@@ -148,14 +131,21 @@ const ConfigList = ({ diff, isLoading }) => {
148131
</Thead>
149132
<Tbody>
150133
{rows.map((row, index) => (
151-
<ConfigListRow
134+
<ConfigDiff
152135
key={row.configName}
153-
row={row}
154-
checked={checkedItems[index]}
155-
updateValue={() => {
156-
checkedItems[index] = !checkedItems[index];
157-
setCheckedItems([...checkedItems]);
158-
}}
136+
oldValue={originalConfig}
137+
newValue={newConfig}
138+
configName={cName}
139+
trigger={(
140+
<ConfigListRow
141+
row={row}
142+
checked={checkedItems[index]}
143+
updateValue={() => {
144+
checkedItems[index] = !checkedItems[index];
145+
setCheckedItems([...checkedItems]);
146+
}}
147+
/>
148+
)}
159149
/>
160150
))}
161151
</Tbody>

0 commit comments

Comments
 (0)