From e17a4bf6273f53573a76f01e9d7b29483d7df8b3 Mon Sep 17 00:00:00 2001
From: gidsi
Date: Wed, 3 Apr 2019 23:08:08 +0200
Subject: [PATCH] Fix delete urls
---
backend/database.go | 14 --------------
frontend/src/components/SpaceApiInput.jsx | 8 ++++----
frontend/src/components/UrlList.jsx | 2 +-
frontend/src/redux/modules/calendar.js | 3 ---
frontend/src/redux/modules/spaceurl.js | 9 +++++----
5 files changed, 10 insertions(+), 26 deletions(-)
diff --git a/backend/database.go b/backend/database.go
index 5cf1571..2ae6ef7 100644
--- a/backend/database.go
+++ b/backend/database.go
@@ -1,7 +1,6 @@
package main
import (
- "github.com/gofrs/uuid"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"log"
@@ -95,19 +94,6 @@ func readSpaceurl() []SpaceUrl {
c := session.DB(config.MongoDbDatabase).C("spaceurl")
result := []SpaceUrl{}
c.Find(bson.M{}).Iter().All(&result)
-
- for _, spaceUrl := range result {
- if spaceUrl.Id == "" {
- generatedUuid, err := uuid.NewV4()
-
- if err != nil {
- log.Printf("%v", err)
- }
- spaceUrl.Id = generatedUuid.String()
- updateSpaceurl(spaceUrl)
- }
- }
-
return result
}
diff --git a/frontend/src/components/SpaceApiInput.jsx b/frontend/src/components/SpaceApiInput.jsx
index 4001453..9a2f3ef 100644
--- a/frontend/src/components/SpaceApiInput.jsx
+++ b/frontend/src/components/SpaceApiInput.jsx
@@ -59,7 +59,7 @@ class SpaceApiInput extends React.Component {
.set('Content-Type', 'application/json')
.end((err) => {
if (!err) {
- this.spaceApiInput.input.value = '';
+ this.spaceApiInput.value = '';
this.setState({ open: true });
}
});
@@ -78,16 +78,16 @@ class SpaceApiInput extends React.Component {
(this.spaceApiInput = ref)}
+ inputRef={ref => (this.spaceApiInput = ref)}
style={{ width: '100%', maxWidth: '340px' }}
/>
diff --git a/frontend/src/components/UrlList.jsx b/frontend/src/components/UrlList.jsx
index bc0673f..3d338e0 100644
--- a/frontend/src/components/UrlList.jsx
+++ b/frontend/src/components/UrlList.jsx
@@ -42,7 +42,7 @@ export class UrlList extends React.Component {
};
deleteSpaceUrl = (spaceUrl) => {
- this.props.deleteSpaceUrl(spaceUrl.url, this.state.secret);
+ this.props.deleteSpaceUrl(spaceUrl.id, this.state.secret);
};
render() {
diff --git a/frontend/src/redux/modules/calendar.js b/frontend/src/redux/modules/calendar.js
index 37637cf..edbf1ed 100644
--- a/frontend/src/redux/modules/calendar.js
+++ b/frontend/src/redux/modules/calendar.js
@@ -35,9 +35,6 @@ export const actions = {
fetchCalendars,
};
-const formatDate = date => (date.format('DD.MM.YYYY'));
-const formatTime = date => (date.format('HH:mm'));
-
export default handleActions({
[CALENDARS_FETCHED]: (state, { payload }) => {
const items = flatten(flatten(
diff --git a/frontend/src/redux/modules/spaceurl.js b/frontend/src/redux/modules/spaceurl.js
index 209524a..c1058b1 100644
--- a/frontend/src/redux/modules/spaceurl.js
+++ b/frontend/src/redux/modules/spaceurl.js
@@ -4,6 +4,7 @@ import { createAction, handleActions } from 'redux-actions';
import config from '../../api/config';
export const itemStruct = PropTypes.shape({
+ id: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
validated: PropTypes.bool.isRequired,
lastUpdated: PropTypes.number.isRequired,
@@ -47,14 +48,14 @@ export const validateSpaceUrl = (spaceUrl, secret) => (dispatch) => {
);
};
-export const deleteSpaceUrl = (spaceUrl, secret) => (dispatch) => {
+export const deleteSpaceUrl = (spaceUrlId, secret) => (dispatch) => {
request
- .delete(`${config.api.url}/urls/spaceUrl/${secret}`)
+ .delete(`${config.api.url}/urls/${spaceUrlId}/${secret}`)
.set('Content-Type', 'application/json')
.end(
(err) => {
if (!err) {
- dispatch(deleteSpace(spaceUrl));
+ dispatch(deleteSpace(spaceUrlId));
}
}
);
@@ -83,5 +84,5 @@ export default handleActions({
return newState;
},
- [SPACEURL_DELETE]: (state, { payload }) => state.items.filter(ele => ele.url != payload.url),
+ [SPACEURL_DELETE]: (state, { payload }) => state.items.filter(ele => ele.id !== payload),
}, { items: [] });