mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
UI dependencies upgrade (#26)
* upgrading dependencies * making notification adapter editable
This commit is contained in:
committed by
GitHub
parent
a64167fcfc
commit
2899dfc20d
@@ -6,7 +6,7 @@ module.exports = {
|
||||
browser: true,
|
||||
},
|
||||
parser: 'babel-eslint',
|
||||
extends: ['eslint:recommended', 'prettier', 'prettier/react'],
|
||||
extends: ['eslint:recommended', 'prettier'],
|
||||
plugins: ['react'],
|
||||
globals: {
|
||||
Promise: false,
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
###### [V5.0.0]
|
||||
- Upgrading dependencies
|
||||
- NodeJS 12 is now the minimum supported version
|
||||
|
||||
###### [V4.0.0]
|
||||
Bringing back Immoscout :tada:
|
||||
|
||||
|
||||
22
package.json
22
package.json
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "fredy",
|
||||
"version": "4.0.0",
|
||||
"version": "5.0.0",
|
||||
"description": "[F]ind [R]eal [E]states [d]amn eas[y].",
|
||||
"scripts": {
|
||||
"start": "node index.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",
|
||||
"test": "mocha --timeout 20000 test/**/*.test.js"
|
||||
},
|
||||
@@ -41,7 +41,7 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=11.0.0",
|
||||
"node": ">=12.0.0",
|
||||
"npm": ">=6.0.0"
|
||||
},
|
||||
"browserslist": [
|
||||
@@ -79,31 +79,31 @@
|
||||
"x-ray": "2.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.14.2",
|
||||
"@babel/core": "7.14.3",
|
||||
"@babel/preset-env": "7.14.2",
|
||||
"@babel/preset-react": "7.13.13",
|
||||
"babel-eslint": "10.1.0",
|
||||
"babel-loader": "8.2.2",
|
||||
"chai": "4.3.4",
|
||||
"clean-webpack-plugin": "3.0.0",
|
||||
"copy-webpack-plugin": "6.3.0",
|
||||
"css-loader": "5.0.1",
|
||||
"copy-webpack-plugin": "8.1.1",
|
||||
"css-loader": "5.2.4",
|
||||
"eslint": "7.26.0",
|
||||
"eslint-config-prettier": "7.1.0",
|
||||
"eslint-plugin-react": "7.23.1",
|
||||
"eslint-config-prettier": "8.3.0",
|
||||
"eslint-plugin-react": "7.23.2",
|
||||
"file-loader": "6.2.0",
|
||||
"history": "5.0.0",
|
||||
"husky": "4.3.8",
|
||||
"less": "4.1.1",
|
||||
"less-loader": "7.2.1",
|
||||
"lint-staged": "10.5.4",
|
||||
"less-loader": "9.0.0",
|
||||
"lint-staged": "11.0.0",
|
||||
"mocha": "8.4.0",
|
||||
"prettier": "2.3.0",
|
||||
"proxyquire": "2.1.3",
|
||||
"redux-logger": "3.0.6",
|
||||
"style-loader": "2.0.0",
|
||||
"url-loader": "4.1.1",
|
||||
"webpack": "4.44.2",
|
||||
"webpack": "5.37.1",
|
||||
"webpack-cli": "3.3.12",
|
||||
"webpack-dev-server": "3.11.2",
|
||||
"webpack-merge": "5.7.3"
|
||||
|
||||
@@ -31,8 +31,8 @@ const content = (jobs, onJobRemoval, onJobStatusChanged, onJobEdit, onJobInsight
|
||||
<Table.Cell>
|
||||
<div style={{ float: 'right' }}>
|
||||
<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="red" icon="trash" onClick={() => onJobRemoval(job.id)} />
|
||||
</div>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
|
||||
@@ -12,7 +12,7 @@ const emptyTable = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const content = (adapterData, onRemove) => {
|
||||
const content = (adapterData, onRemove, onEdit) => {
|
||||
return (
|
||||
<Fragment>
|
||||
{adapterData.map((data) => {
|
||||
@@ -21,6 +21,7 @@ const content = (adapterData, onRemove) => {
|
||||
<Table.Cell>{data.name}</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div style={{ float: 'right' }}>
|
||||
<Button circular color="blue" icon="edit" onClick={() => onEdit(data.id)} />
|
||||
<Button circular color="red" icon="trash" onClick={() => onRemove(data.id)} />
|
||||
</div>
|
||||
</Table.Cell>
|
||||
@@ -31,7 +32,7 @@ const content = (adapterData, onRemove) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default function NotificationAdapterTable({ notificationAdapter = [], onRemove } = {}) {
|
||||
export default function NotificationAdapterTable({ notificationAdapter = [], onRemove, onEdit } = {}) {
|
||||
return (
|
||||
<Table singleLine inverted>
|
||||
<Table.Header>
|
||||
@@ -42,7 +43,7 @@ export default function NotificationAdapterTable({ notificationAdapter = [], onR
|
||||
</Table.Header>
|
||||
|
||||
<Table.Body>
|
||||
{notificationAdapter.length === 0 ? emptyTable() : content(notificationAdapter, onRemove)}
|
||||
{notificationAdapter.length === 0 ? emptyTable() : content(notificationAdapter, onRemove, onEdit)}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
);
|
||||
|
||||
@@ -29,6 +29,7 @@ export default function JobMutator() {
|
||||
|
||||
const [providerCreationVisible, setProviderCreationVisibility] = useState(false);
|
||||
const [notificationCreationVisible, setNotificationCreationVisibility] = useState(false);
|
||||
const [editNotificationAdapter, setEditNotificationAdapter] = useState(null);
|
||||
const [providerData, setProviderData] = useState(defaultProviderData);
|
||||
const [name, setName] = useState(defaultName);
|
||||
const [blacklist, setBlacklist] = useState(defaultBlacklist);
|
||||
@@ -88,7 +89,7 @@ export default function JobMutator() {
|
||||
ctx.showToast({
|
||||
title: 'Error',
|
||||
message: Exception.json != null ? Exception.json.message : Exception,
|
||||
delay: 35000,
|
||||
delay: 8000,
|
||||
backgroundColor: '#db2828',
|
||||
color: '#fff',
|
||||
});
|
||||
@@ -106,14 +107,25 @@ export default function JobMutator() {
|
||||
}}
|
||||
/>
|
||||
|
||||
<NotificationAdapterMutator
|
||||
visible={notificationCreationVisible}
|
||||
onVisibilityChanged={(visible) => setNotificationCreationVisibility(visible)}
|
||||
selected={providerData}
|
||||
onData={(data) => {
|
||||
setNotificationAdapterData([...notificationAdapterData, data]);
|
||||
}}
|
||||
/>
|
||||
{notificationCreationVisible && (
|
||||
<NotificationAdapterMutator
|
||||
visible={notificationCreationVisible}
|
||||
onVisibilityChanged={(visible) => {
|
||||
setEditNotificationAdapter(null);
|
||||
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'} />
|
||||
<Form className="jobMutation__form">
|
||||
@@ -174,8 +186,13 @@ export default function JobMutator() {
|
||||
<NotificationAdapterTable
|
||||
notificationAdapter={notificationAdapterData}
|
||||
onRemove={(adapterId) => {
|
||||
setEditNotificationAdapter(null);
|
||||
setNotificationAdapterData(notificationAdapterData.filter((adapter) => adapter.id !== adapterId));
|
||||
}}
|
||||
onEdit={(adapterId) => {
|
||||
setEditNotificationAdapter(adapterId);
|
||||
setNotificationCreationVisibility(true);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -42,15 +42,29 @@ const validate = (selectedAdapter) => {
|
||||
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({
|
||||
onVisibilityChanged,
|
||||
visible = false,
|
||||
selected = [],
|
||||
editNotificationAdapter,
|
||||
onData,
|
||||
} = {}) {
|
||||
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 [successMessage, setSuccessMessage] = useState(null);
|
||||
|
||||
@@ -107,9 +121,12 @@ export default function NotificationAdapterMutator({
|
||||
|
||||
setSelectedAdapter({
|
||||
...selectedAdapter,
|
||||
config: {
|
||||
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((option) => selected.find((selectedOption) => selectedOption.id === option.key) == null)
|
||||
.filter((option) =>
|
||||
editNotificationAdapter != null
|
||||
? true
|
||||
: selected.find((selectedOption) => selectedOption.id === option.key) == null
|
||||
)
|
||||
.sort(sortAdapter)}
|
||||
onChange={(e, { value }) => {
|
||||
setSuccessMessage(null);
|
||||
|
||||
Reference in New Issue
Block a user