Skip to content

Commit

Permalink
UI dependencies upgrade (#26)
Browse files Browse the repository at this point in the history
* upgrading dependencies

* making notification adapter editable
  • Loading branch information
orangecoding authored May 20, 2021
1 parent a64167f commit 2899dfc
Show file tree
Hide file tree
Showing 8 changed files with 544 additions and 1,252 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
###### [V5.0.0]
- Upgrading dependencies
- NodeJS 12 is now the minimum supported version

###### [V4.0.0]
Bringing back Immoscout :tada:

Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand Down Expand Up @@ -41,7 +41,7 @@
},
"license": "MIT",
"engines": {
"node": ">=11.0.0",
"node": ">=12.0.0",
"npm": ">=6.0.0"
},
"browserslist": [
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/table/JobTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
7 changes: 4 additions & 3 deletions ui/src/components/table/NotificationAdapterTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const emptyTable = () => {
);
};

const content = (adapterData, onRemove) => {
const content = (adapterData, onRemove, onEdit) => {
return (
<Fragment>
{adapterData.map((data) => {
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
);
Expand Down
35 changes: 26 additions & 9 deletions ui/src/views/jobs/mutation/JobMutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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',
});
Expand All @@ -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">
Expand Down Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -107,9 +121,12 @@ export default function NotificationAdapterMutator({

setSelectedAdapter({
...selectedAdapter,
config: {
fields: {
...selectedAdapter.fields,
[key]: uiElement,
[key]: {
...selectedAdapter.fields[key],
value,
},
},
});
};
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 2899dfc

Please sign in to comment.