Skip to content

Commit 300aea5

Browse files
committed
history mode
1 parent a452e90 commit 300aea5

File tree

1 file changed

+145
-5
lines changed
  • src/user/Admin/Tickets/TicketDiscussion/History

1 file changed

+145
-5
lines changed

src/user/Admin/Tickets/TicketDiscussion/History/History.js

Lines changed: 145 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,171 @@
11
import React, { Component } from "react";
2-
import Moment from "react-moment";
32
import { Timeline } from "antd";
3+
import Moment from "react-moment";
4+
import Modal from "react-bootstrap/Modal";
5+
import Badge from "react-bootstrap/Badge";
6+
import ReactMarkdown from "react-markdown";
47

58
class History extends Component {
9+
constructor(props) {
10+
super(props);
11+
this.state = {
12+
modal: null,
13+
};
14+
}
15+
16+
handleClose = () => {
17+
this.setState({
18+
modal: null,
19+
});
20+
};
21+
622
view = () => {};
23+
724
render() {
825
return (
9-
<div style={{padding: "10px 2rem", overflowY: "scroll", height: "75vh"}}>
26+
<div
27+
style={{ padding: "10px 2rem", overflowY: "scroll", height: "75vh" }}
28+
>
1029
<Timeline>
1130
{this.props.ticket.history.map((ele, index) => {
1231
return (
1332
<Timeline.Item key={index}>
1433
<div className="history-item" onClick={() => this.view()}>
1534
<div className="line">
16-
<h5>{ele.updatedBy}</h5>
35+
<h5>{ele.updatedBy.name}</h5>
1736
<h5>
1837
<Moment format="DD MMM YYYY">{ele.updatedAt}</Moment>
1938
</h5>
2039
</div>
21-
<div className="line">
22-
<p>{ele.content}</p>
40+
<div>
41+
{ele.type === "title" ? (
42+
<span>
43+
{"Updated Title from "}
44+
<strong>
45+
<del>{ele.title.old}</del>
46+
</strong>
47+
{" to "}
48+
<strong>{ele.title.new}</strong>
49+
</span>
50+
) : (
51+
""
52+
)}
53+
{ele.type === "add tag" ? (
54+
<soan>
55+
Assigned tag{" "}
56+
<Badge
57+
pill
58+
variant="info"
59+
style={{ fontSize: "13px", margin: "2px" }}
60+
>
61+
<span style={{ verticalAlign: "middle" }}>
62+
{ele.tag}
63+
</span>
64+
</Badge>
65+
</soan>
66+
) : (
67+
""
68+
)}
69+
{ele.type === "remove tag" ? (
70+
<soan>
71+
Removed tag{" "}
72+
<Badge
73+
pill
74+
variant="info"
75+
style={{ fontSize: "13px", margin: "2px" }}
76+
>
77+
<span style={{ verticalAlign: "middle" }}>
78+
<del>{ele.tag}</del>
79+
</span>
80+
</Badge>
81+
</soan>
82+
) : (
83+
""
84+
)}
85+
{ele.type === "shortDescription" ? (
86+
<soan>
87+
<span>
88+
{"Ticket Summary Updated "}
89+
<span
90+
style={{
91+
color: "rgba(0,0,0,0.5)",
92+
textDecoration: "underline",
93+
cursor: "pointer",
94+
}}
95+
onClick={() =>
96+
this.setState({
97+
modal: {
98+
title: "History - Ticket Summary",
99+
bodyTitle: "Updated Ticket Summary",
100+
bodyContent: ele.shortDescription,
101+
type: ele.type,
102+
},
103+
})
104+
}
105+
>
106+
View Update
107+
</span>
108+
</span>
109+
</soan>
110+
) : (
111+
""
112+
)}
113+
{ele.type === "content" ? (
114+
<soan>
115+
<span>
116+
{"Ticket Content Updated "}
117+
<span
118+
style={{
119+
color: "rgba(0,0,0,0.5)",
120+
textDecoration: "underline",
121+
cursor: "pointer",
122+
}}
123+
onClick={() =>
124+
this.setState({
125+
modal: {
126+
title: "History - Ticket Content",
127+
bodyTitle: "Updated Ticket Content",
128+
bodyContent: ele.content,
129+
type: ele.type,
130+
},
131+
})
132+
}
133+
>
134+
View Update
135+
</span>
136+
</span>
137+
</soan>
138+
) : (
139+
""
140+
)}
23141
</div>
24142
</div>
25143
</Timeline.Item>
26144
);
27145
})}
28146
</Timeline>
147+
{this.state.modal && (
148+
<Modal
149+
centered
150+
className="modal"
151+
show={this.state.modal}
152+
onHide={this.handleClose}
153+
>
154+
<Modal.Header closeButton>
155+
<Modal.Title>{this.state.modal.title}</Modal.Title>
156+
</Modal.Header>
157+
<Modal.Body
158+
style={
159+
this.state.modal.type === "content"
160+
? { height: "500px", overflowY: "scroll", padding: "0 30px" }
161+
: {}
162+
}
163+
>
164+
<h5>{this.state.modal.bodyTitle}</h5>
165+
<ReactMarkdown source={this.state.modal.bodyContent}/>
166+
</Modal.Body>
167+
</Modal>
168+
)}
29169
</div>
30170
);
31171
}

0 commit comments

Comments
 (0)