diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js
index 660bfe13e51..7c1dd36c18e 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js
@@ -125,7 +125,7 @@ class AddReview extends React.Component {
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js
index c69d68de227..eb32114bb5b 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/CurrentUsersReview.js
@@ -1,6 +1,6 @@
import React from "react";
import {List, message, Typography, Empty, Button, Row, Col} from "antd";
-import SingleReview from "./SingleReview";
+import SingleReview from "./singleReview/SingleReview";
import axios from "axios";
import config from "../../../../../public/conf/config.json";
import AddReview from "./AddReview";
@@ -42,6 +42,14 @@ class CurrentUsersReview extends React.Component {
});
};
+ updateCallback = (response) =>{
+ const {rating, content} = response;
+ this.setState({
+ rating,
+ content
+ });
+ };
+
render() {
const {data} = this.state;
const {uuid} = this.props;
@@ -55,22 +63,15 @@ class CurrentUsersReview extends React.Component {
}}>
{data.length > 0 && (
-
-
- (
-
-
-
- )}
- >
-
-
-
-
-
-
+ (
+
+
+
+ )}
+ >
+
)}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.css
index 606437675a2..2f93bd74f4f 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.css
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.css
@@ -13,11 +13,4 @@
position: absolute;
bottom: -40px;
left: 50%;
-}
-
-img.twemoji {
- height: 1em;
- width: 1em;
- margin: 0 .05em 0 .1em;
- vertical-align: -0.1em;
}
\ No newline at end of file
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.js
index 54ba6321aca..c01a859c6a1 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/Reviews.js
@@ -3,7 +3,7 @@ import {List, message, Avatar, Spin, Button} from 'antd';
import "./Reviews.css";
import InfiniteScroll from 'react-infinite-scroller';
-import SingleReview from "./SingleReview";
+import SingleReview from "./singleReview/SingleReview";
import axios from "axios";
import config from "../../../../../public/conf/config.json";
@@ -87,31 +87,33 @@ class Reviews extends React.Component {
};
render() {
+ const {loading, hasMore, data, loadMore} = this.state;
+ const {uuid} = this.props;
return (
(
-
+
)}
>
- {this.state.loading && this.state.hasMore && (
+ {loading && hasMore && (
)}
- {!this.state.loadMore && (this.state.data.length >= limit) && (
+ {!loadMore && (data.length >= limit) && (
)}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.css
new file mode 100644
index 00000000000..7bdb6e5d2cb
--- /dev/null
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.css
@@ -0,0 +1,26 @@
+img.twemoji {
+ height: 1em;
+ width: 1em;
+ margin: 0 .05em 0 .1em;
+ vertical-align: -0.1em;
+}
+
+.edit-button {
+ color: #1890ff;
+ text-decoration: none;
+ outline: none;
+ cursor: pointer;
+ font-weight: normal;
+ font-size: 0.8em;
+ padding-left: 5px;
+}
+
+.delete-button {
+ color: #e74c3c;
+ text-decoration: none;
+ outline: none;
+ cursor: pointer;
+ font-weight: normal;
+ font-size: 0.8em;
+ padding-left: 5px;
+}
\ No newline at end of file
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/SingleReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js
similarity index 78%
rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/SingleReview.js
rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js
index 60497086d0b..66a7033bd50 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/SingleReview.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/SingleReview.js
@@ -3,7 +3,8 @@ import {Avatar} from "antd";
import {List, Typography} from "antd";
import StarRatings from "react-star-ratings";
import Twemoji from "react-twemoji";
-import "./Reviews.css";
+import "./SingleReview.css";
+import EditReview from "./editReview/EditReview";
const {Text, Paragraph} = Typography;
const colorList = ['#f0932b', '#badc58', '#6ab04c', '#eb4d4b', '#0abde3', '#9b59b6', '#3498db', '#22a6b3','#e84393','#f9ca24'];
@@ -11,7 +12,7 @@ const colorList = ['#f0932b', '#badc58', '#6ab04c', '#eb4d4b', '#0abde3', '#9b59
class SingleReview extends React.Component {
render() {
- const {review} = this.props;
+ const {review, isEditable, isDeletable, uuid} = this.props;
const {username} = review;
const randomColor = colorList[username.length%10];
const avatarLetter = username.charAt(0).toUpperCase();
@@ -34,6 +35,14 @@ class SingleReview extends React.Component {
);
+ const title = (
+
+ {review.username}
+ {isEditable && ()}
+ {isDeletable && (delete)}
+
+ );
+
return (
}
- title={review.username}
+ title={title}
description={content}
/>
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.css
new file mode 100644
index 00000000000..d4d0955a757
--- /dev/null
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.css
@@ -0,0 +1,9 @@
+.edit-button {
+ color: #1890ff;
+ text-decoration: none;
+ outline: none;
+ cursor: pointer;
+ font-weight: normal;
+ font-size: 0.8em;
+ padding-left: 5px;
+}
\ No newline at end of file
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/EditReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js
similarity index 85%
rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/EditReview.js
rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js
index ddc7892b40a..ed72f515117 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/EditReview.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/singleReview/editReview/EditReview.js
@@ -2,7 +2,8 @@ import React from "react";
import {Drawer, Button, Icon, Row, Col, Typography, Divider, Input, Spin, notification} from 'antd';
import StarRatings from "react-star-ratings";
import axios from "axios";
-import config from "../../../../../public/conf/config.json";
+import config from "../../../../../../../public/conf/config.json";
+import "./EditReview.css";
const {Title} = Typography;
const {TextArea} = Input;
@@ -19,11 +20,18 @@ class EditReview extends React.Component {
};
}
+ componentDidMount() {
+ const {content,rating,id} = this.props.review;
+ console.log(this.props.review);
+ this.setState({
+ content,
+ rating
+ });
+ }
+
showDrawer = () => {
this.setState({
visible: true,
- content: '',
- rating: 0,
loading: false
});
};
@@ -34,6 +42,7 @@ class EditReview extends React.Component {
});
};
+
changeRating = (newRating, name) => {
this.setState({
rating: newRating
@@ -46,6 +55,7 @@ class EditReview extends React.Component {
onSubmit = () => {
const {content, rating} = this.state;
+ const {id} = this.props.review;
const {uuid} = this.props;
this.setState({
loading: true
@@ -56,11 +66,11 @@ class EditReview extends React.Component {
rating: rating
};
- axios.post(
- config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid,
+ axios.put(
+ config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid+"/"+id,
payload,
).then(res => {
- if (res.status === 201) {
+ if (res.status === 200) {
this.setState({
loading: false,
visible: false
@@ -68,12 +78,8 @@ class EditReview extends React.Component {
notification["success"]({
message: 'Done!',
description:
- 'Your review has been posted successfully.',
+ 'Your review has been update successfully.',
});
-
- setTimeout(() => {
- window.location.href = uuid;
- }, 2000)
} else {
this.setState({
loading: false,
@@ -82,7 +88,7 @@ class EditReview extends React.Component {
notification["error"]({
message: 'Something went wrong',
description:
- "We are unable to add your review right now.",
+ "We are unable to update your review right now.",
});
}
@@ -107,11 +113,8 @@ class EditReview extends React.Component {
render() {
return (
-
-
-
+
+ edit
- Add review
+ Edit review
@@ -156,7 +159,7 @@ class EditReview extends React.Component {
-
+
);
}
}