style: Fix eslint warnings

pull/25/head
Boaz Poolman 2021-10-14 17:39:53 +02:00
parent d5b8b0b719
commit 10c361b27e
7 changed files with 40 additions and 52 deletions

View File

@ -112,6 +112,8 @@
"no-cond-assign": "warn",
"no-confusing-arrow": "off",
"no-console": "off",
"no-constant-condition": "warn",

View File

@ -1,11 +1,10 @@
import React from 'react';
import ReactDiffViewer, { DiffMethod } from 'react-diff-viewer';
import { ModalLayout, ModalFooter, ModalBody, ModalHeader } from '@strapi/parts/ModalLayout';
import { ModalLayout, ModalBody, ModalHeader } from '@strapi/parts/ModalLayout';
import { ButtonText } from '@strapi/parts/Text';
import { Button } from '@strapi/parts/Button';
const ConfigDiff = ({ isOpen, onClose, onToggle, oldValue, newValue, configName }) => {
const ConfigDiff = ({ isOpen, onClose, oldValue, newValue, configName }) => {
if (!isOpen) {
return null;
}
@ -30,13 +29,8 @@ const ConfigDiff = ({ isOpen, onClose, onToggle, oldValue, newValue, configName
/>
</section>
</ModalBody>
<ModalFooter>
<section style={{ alignItems: 'center' }}>
</section>
</ModalFooter>
</ModalLayout>
);
}
};
export default ConfigDiff;

View File

@ -1,10 +1,9 @@
import React from 'react';
import styled from 'styled-components';
const CustomRow = ({ row }) => {
const { config_name, config_type, state, onClick } = row;
const { configName, configType, state, onClick } = row;
const stateStyle = (state) => {
const stateStyle = (stateStr) => {
const style = {
display: 'inline-flex',
padding: '0 10px',
@ -14,17 +13,17 @@ const CustomRow = ({ row }) => {
fontWeight: '500',
};
if (state === 'Only in DB') {
if (stateStr === 'Only in DB') {
style.backgroundColor = '#cbf2d7';
style.color = '#1b522b';
}
if (state === 'Only in sync dir') {
if (stateStr === 'Only in sync dir') {
style.backgroundColor = '#f0cac7';
style.color = '#3d302f';
}
if (state === 'Different') {
if (stateStr === 'Different') {
style.backgroundColor = '#e8e6b7';
style.color = '#4a4934';
}
@ -33,12 +32,12 @@ const CustomRow = ({ row }) => {
};
return (
<tr onClick={() => onClick(config_type, config_name)}>
<tr onClick={() => onClick(configType, configName)}>
<td>
<p>{config_name}</p>
<p>{configName}</p>
</td>
<td>
<p>{config_type}</p>
<p>{configType}</p>
</td>
<td>
<p style={stateStyle(state)}>{state}</p>

View File

@ -1,12 +1,8 @@
import React, { useState, useEffect } from 'react';
import { isEmpty } from 'lodash';
import { NoContent } from '@strapi/helper-plugin';
import AddIcon from '@strapi/icons/AddIcon';
import { VisuallyHidden } from '@strapi/parts/VisuallyHidden';
import { Table, Thead, Tbody, Tr, Th, TFooter } from '@strapi/parts/Table';
import { Table, Thead, Tbody, Tr, Th } from '@strapi/parts/Table';
import { TableLabel } from '@strapi/parts/Text';
import { Button } from '@strapi/parts/Button';
import ConfigDiff from '../ConfigDiff';
import FirstExport from '../FirstExport';
@ -16,25 +12,25 @@ const ConfigList = ({ diff, isLoading }) => {
const [openModal, setOpenModal] = useState(false);
const [originalConfig, setOriginalConfig] = useState({});
const [newConfig, setNewConfig] = useState({});
const [configName, setConfigName] = useState('');
const [cName, setCname] = useState('');
const [rows, setRows] = useState([]);
const getConfigState = (configName) => {
if (
diff.fileConfig[configName] &&
diff.databaseConfig[configName]
diff.fileConfig[configName]
&& diff.databaseConfig[configName]
) {
return 'Different'
return 'Different';
} else if (
diff.fileConfig[configName] &&
!diff.databaseConfig[configName]
diff.fileConfig[configName]
&& !diff.databaseConfig[configName]
) {
return 'Only in sync dir'
return 'Only in sync dir';
} else if (
!diff.fileConfig[configName] &&
diff.databaseConfig[configName]
!diff.fileConfig[configName]
&& diff.databaseConfig[configName]
) {
return 'Only in DB'
return 'Only in DB';
}
};
@ -44,21 +40,21 @@ const ConfigList = ({ diff, isLoading }) => {
return;
}
let formattedRows = [];
Object.keys(diff.diff).map((configName) => {
const type = configName.split('.')[0]; // Grab the first part of the filename.
const name = configName.split(/\.(.+)/)[1]; // Grab the rest of the filename minus the file extension.
const formattedRows = [];
Object.keys(diff.diff).map((name) => {
const type = name.split('.')[0]; // Grab the first part of the filename.
const formattedName = name.split(/\.(.+)/)[1]; // Grab the rest of the filename minus the file extension.
formattedRows.push({
config_name: name,
config_type: type,
state: getConfigState(configName),
onClick: (config_type, config_name) => {
setOriginalConfig(diff.fileConfig[`${config_type}.${config_name}`]);
setNewConfig(diff.databaseConfig[`${config_type}.${config_name}`]);
setConfigName(`${config_type}.${config_name}`);
configName: formattedName,
configType: type,
state: getConfigState(name),
onClick: (configType, configName) => {
setOriginalConfig(diff.fileConfig[`${configType}.${configName}`]);
setNewConfig(diff.databaseConfig[`${configType}.${configName}`]);
setCname(`${configType}.${configName}`);
setOpenModal(true);
}
},
});
});
@ -68,7 +64,7 @@ const ConfigList = ({ diff, isLoading }) => {
const closeModal = () => {
setOriginalConfig({});
setNewConfig({});
setConfigName('');
setCname('');
setOpenModal(false);
};
@ -83,8 +79,7 @@ const ConfigList = ({ diff, isLoading }) => {
oldValue={originalConfig}
newValue={newConfig}
onClose={closeModal}
onToggle={closeModal}
configName={configName}
configName={cName}
/>
<Table colCount={4} rowCount={rows.length + 1}>
<Thead>

View File

@ -1,5 +1,5 @@
import pluginId from './pluginId';
const getTrad = id => `${pluginId}.${id}`;
const getTrad = (id) => `${pluginId}.${id}`;
export default getTrad;

View File

@ -1,4 +1,5 @@
const pluginPkg = require('../../../package.json');
const pluginId = pluginPkg.name.replace(
/^strapi-plugin-/i,
''

View File

@ -1,7 +1,6 @@
'use strict';
const fs = require('fs');
const types = require('./types');
/**
* An asynchronous bootstrap function that runs before
@ -14,8 +13,6 @@ const types = require('./types');
*/
module.exports = async () => {
// console.log(await types['core-store'].exportAll());
if (strapi.plugins['config-sync'].config.importOnBootstrap) {
if (fs.existsSync(strapi.plugins['config-sync'].config.destination)) {
await strapi.plugins['config-sync'].services.main.importAllConfig();