UI dependencies upgrade (#26)

* upgrading dependencies

* making notification adapter editable
This commit is contained in:
Christian Kellner
2021-05-20 14:21:29 +02:00
committed by GitHub
parent a64167fcfc
commit 2899dfc20d
8 changed files with 532 additions and 1240 deletions

View File

@@ -6,7 +6,7 @@ module.exports = {
browser: true, browser: true,
}, },
parser: 'babel-eslint', parser: 'babel-eslint',
extends: ['eslint:recommended', 'prettier', 'prettier/react'], extends: ['eslint:recommended', 'prettier'],
plugins: ['react'], plugins: ['react'],
globals: { globals: {
Promise: false, Promise: false,

View File

@@ -1,3 +1,7 @@
###### [V5.0.0]
- Upgrading dependencies
- NodeJS 12 is now the minimum supported version
###### [V4.0.0] ###### [V4.0.0]
Bringing back Immoscout :tada: Bringing back Immoscout :tada:

View File

@@ -1,11 +1,11 @@
{ {
"name": "fredy", "name": "fredy",
"version": "4.0.0", "version": "5.0.0",
"description": "[F]ind [R]eal [E]states [d]amn eas[y].", "description": "[F]ind [R]eal [E]states [d]amn eas[y].",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
"dev": "yarn && export BUILD_DEV='true' && export NODE_ENV='development' && webpack-dev-server --progress --colors --watch --config ./webpack.dev.js", "dev": "yarn && export BUILD_DEV='true' && export NODE_ENV='development' && webpack-dev-server --progress --colors --watch --config ./webpack.dev.js",
"prod": "export BUILD_DEV='false' && export NODE_ENV='production' && webpack --config ./webpack.prod.js", "prod": "export BUILD_DEV='false' && webpack --node-env=production --config ./webpack.prod.js",
"format": "prettier --write lib/**/*.js ui/src/**/*.js test/**/*.js *.js --single-quote --print-width 120", "format": "prettier --write lib/**/*.js ui/src/**/*.js test/**/*.js *.js --single-quote --print-width 120",
"test": "mocha --timeout 20000 test/**/*.test.js" "test": "mocha --timeout 20000 test/**/*.test.js"
}, },
@@ -41,7 +41,7 @@
}, },
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=11.0.0", "node": ">=12.0.0",
"npm": ">=6.0.0" "npm": ">=6.0.0"
}, },
"browserslist": [ "browserslist": [
@@ -79,31 +79,31 @@
"x-ray": "2.3.4" "x-ray": "2.3.4"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "7.14.2", "@babel/core": "7.14.3",
"@babel/preset-env": "7.14.2", "@babel/preset-env": "7.14.2",
"@babel/preset-react": "7.13.13", "@babel/preset-react": "7.13.13",
"babel-eslint": "10.1.0", "babel-eslint": "10.1.0",
"babel-loader": "8.2.2", "babel-loader": "8.2.2",
"chai": "4.3.4", "chai": "4.3.4",
"clean-webpack-plugin": "3.0.0", "clean-webpack-plugin": "3.0.0",
"copy-webpack-plugin": "6.3.0", "copy-webpack-plugin": "8.1.1",
"css-loader": "5.0.1", "css-loader": "5.2.4",
"eslint": "7.26.0", "eslint": "7.26.0",
"eslint-config-prettier": "7.1.0", "eslint-config-prettier": "8.3.0",
"eslint-plugin-react": "7.23.1", "eslint-plugin-react": "7.23.2",
"file-loader": "6.2.0", "file-loader": "6.2.0",
"history": "5.0.0", "history": "5.0.0",
"husky": "4.3.8", "husky": "4.3.8",
"less": "4.1.1", "less": "4.1.1",
"less-loader": "7.2.1", "less-loader": "9.0.0",
"lint-staged": "10.5.4", "lint-staged": "11.0.0",
"mocha": "8.4.0", "mocha": "8.4.0",
"prettier": "2.3.0", "prettier": "2.3.0",
"proxyquire": "2.1.3", "proxyquire": "2.1.3",
"redux-logger": "3.0.6", "redux-logger": "3.0.6",
"style-loader": "2.0.0", "style-loader": "2.0.0",
"url-loader": "4.1.1", "url-loader": "4.1.1",
"webpack": "4.44.2", "webpack": "5.37.1",
"webpack-cli": "3.3.12", "webpack-cli": "3.3.12",
"webpack-dev-server": "3.11.2", "webpack-dev-server": "3.11.2",
"webpack-merge": "5.7.3" "webpack-merge": "5.7.3"

View File

@@ -31,8 +31,8 @@ const content = (jobs, onJobRemoval, onJobStatusChanged, onJobEdit, onJobInsight
<Table.Cell> <Table.Cell>
<div style={{ float: 'right' }}> <div style={{ float: 'right' }}>
<Button circular color="teal" icon="chart line" onClick={() => onJobInsight(job.id)} /> <Button circular color="teal" icon="chart line" onClick={() => onJobInsight(job.id)} />
<Button circular color="red" icon="trash" onClick={() => onJobRemoval(job.id)} />
<Button circular color="blue" icon="edit" onClick={() => onJobEdit(job.id)} /> <Button circular color="blue" icon="edit" onClick={() => onJobEdit(job.id)} />
<Button circular color="red" icon="trash" onClick={() => onJobRemoval(job.id)} />
</div> </div>
</Table.Cell> </Table.Cell>
</Table.Row> </Table.Row>

View File

@@ -12,7 +12,7 @@ const emptyTable = () => {
); );
}; };
const content = (adapterData, onRemove) => { const content = (adapterData, onRemove, onEdit) => {
return ( return (
<Fragment> <Fragment>
{adapterData.map((data) => { {adapterData.map((data) => {
@@ -21,6 +21,7 @@ const content = (adapterData, onRemove) => {
<Table.Cell>{data.name}</Table.Cell> <Table.Cell>{data.name}</Table.Cell>
<Table.Cell> <Table.Cell>
<div style={{ float: 'right' }}> <div style={{ float: 'right' }}>
<Button circular color="blue" icon="edit" onClick={() => onEdit(data.id)} />
<Button circular color="red" icon="trash" onClick={() => onRemove(data.id)} /> <Button circular color="red" icon="trash" onClick={() => onRemove(data.id)} />
</div> </div>
</Table.Cell> </Table.Cell>
@@ -31,7 +32,7 @@ const content = (adapterData, onRemove) => {
); );
}; };
export default function NotificationAdapterTable({ notificationAdapter = [], onRemove } = {}) { export default function NotificationAdapterTable({ notificationAdapter = [], onRemove, onEdit } = {}) {
return ( return (
<Table singleLine inverted> <Table singleLine inverted>
<Table.Header> <Table.Header>
@@ -42,7 +43,7 @@ export default function NotificationAdapterTable({ notificationAdapter = [], onR
</Table.Header> </Table.Header>
<Table.Body> <Table.Body>
{notificationAdapter.length === 0 ? emptyTable() : content(notificationAdapter, onRemove)} {notificationAdapter.length === 0 ? emptyTable() : content(notificationAdapter, onRemove, onEdit)}
</Table.Body> </Table.Body>
</Table> </Table>
); );

View File

@@ -29,6 +29,7 @@ export default function JobMutator() {
const [providerCreationVisible, setProviderCreationVisibility] = useState(false); const [providerCreationVisible, setProviderCreationVisibility] = useState(false);
const [notificationCreationVisible, setNotificationCreationVisibility] = useState(false); const [notificationCreationVisible, setNotificationCreationVisibility] = useState(false);
const [editNotificationAdapter, setEditNotificationAdapter] = useState(null);
const [providerData, setProviderData] = useState(defaultProviderData); const [providerData, setProviderData] = useState(defaultProviderData);
const [name, setName] = useState(defaultName); const [name, setName] = useState(defaultName);
const [blacklist, setBlacklist] = useState(defaultBlacklist); const [blacklist, setBlacklist] = useState(defaultBlacklist);
@@ -88,7 +89,7 @@ export default function JobMutator() {
ctx.showToast({ ctx.showToast({
title: 'Error', title: 'Error',
message: Exception.json != null ? Exception.json.message : Exception, message: Exception.json != null ? Exception.json.message : Exception,
delay: 35000, delay: 8000,
backgroundColor: '#db2828', backgroundColor: '#db2828',
color: '#fff', color: '#fff',
}); });
@@ -106,14 +107,25 @@ export default function JobMutator() {
}} }}
/> />
<NotificationAdapterMutator {notificationCreationVisible && (
visible={notificationCreationVisible} <NotificationAdapterMutator
onVisibilityChanged={(visible) => setNotificationCreationVisibility(visible)} visible={notificationCreationVisible}
selected={providerData} onVisibilityChanged={(visible) => {
onData={(data) => { setEditNotificationAdapter(null);
setNotificationAdapterData([...notificationAdapterData, data]); setNotificationCreationVisibility(visible);
}} }}
/> selected={notificationAdapterData}
editNotificationAdapter={
editNotificationAdapter == null
? null
: notificationAdapterData.find((adapter) => adapter.id === editNotificationAdapter)
}
onData={(data) => {
const oldData = [...notificationAdapterData].filter((o) => o.id !== data.id);
setNotificationAdapterData([...oldData, data]);
}}
/>
)}
<Headline text={jobToBeEdit ? 'Edit a Job' : 'Create a new Job'} /> <Headline text={jobToBeEdit ? 'Edit a Job' : 'Create a new Job'} />
<Form className="jobMutation__form"> <Form className="jobMutation__form">
@@ -174,8 +186,13 @@ export default function JobMutator() {
<NotificationAdapterTable <NotificationAdapterTable
notificationAdapter={notificationAdapterData} notificationAdapter={notificationAdapterData}
onRemove={(adapterId) => { onRemove={(adapterId) => {
setEditNotificationAdapter(null);
setNotificationAdapterData(notificationAdapterData.filter((adapter) => adapter.id !== adapterId)); setNotificationAdapterData(notificationAdapterData.filter((adapter) => adapter.id !== adapterId));
}} }}
onEdit={(adapterId) => {
setEditNotificationAdapter(adapterId);
setNotificationCreationVisibility(true);
}}
/> />
</div> </div>

View File

@@ -42,15 +42,29 @@ const validate = (selectedAdapter) => {
return [...new Set(results)]; return [...new Set(results)];
}; };
function spreadPrefilledAdapterWithValues(prefilled, fields) {
if (prefilled != null && fields != null) {
Object.keys(fields).forEach((fieldKey) => {
prefilled.fields[fieldKey].value = fields[fieldKey];
});
}
}
export default function NotificationAdapterMutator({ export default function NotificationAdapterMutator({
onVisibilityChanged, onVisibilityChanged,
visible = false, visible = false,
selected = [], selected = [],
editNotificationAdapter,
onData, onData,
} = {}) { } = {}) {
const adapter = useSelector((state) => state.notificationAdapter); const adapter = useSelector((state) => state.notificationAdapter);
const [selectedAdapter, setSelectedAdapter] = useState(null); const preFilledSelectedAdapter =
editNotificationAdapter == null ? null : adapter.find((a) => a.id === editNotificationAdapter.id);
spreadPrefilledAdapterWithValues(preFilledSelectedAdapter, editNotificationAdapter?.fields);
const [selectedAdapter, setSelectedAdapter] = useState(preFilledSelectedAdapter);
const [validationMessage, setValidationMessage] = useState(null); const [validationMessage, setValidationMessage] = useState(null);
const [successMessage, setSuccessMessage] = useState(null); const [successMessage, setSuccessMessage] = useState(null);
@@ -107,9 +121,12 @@ export default function NotificationAdapterMutator({
setSelectedAdapter({ setSelectedAdapter({
...selectedAdapter, ...selectedAdapter,
config: { fields: {
...selectedAdapter.fields, ...selectedAdapter.fields,
[key]: uiElement, [key]: {
...selectedAdapter.fields[key],
value,
},
}, },
}); });
}; };
@@ -187,7 +204,11 @@ export default function NotificationAdapterMutator({
}; };
}) })
//filter out those, that have already been selected //filter out those, that have already been selected
.filter((option) => selected.find((selectedOption) => selectedOption.id === option.key) == null) .filter((option) =>
editNotificationAdapter != null
? true
: selected.find((selectedOption) => selectedOption.id === option.key) == null
)
.sort(sortAdapter)} .sort(sortAdapter)}
onChange={(e, { value }) => { onChange={(e, { value }) => {
setSuccessMessage(null); setSuccessMessage(null);

1671
yarn.lock

File diff suppressed because it is too large Load Diff