Skip to content

Commit 28dfb80

Browse files
committed
refactor(core): markdown fixes and misc cleanup
1 parent 1c198eb commit 28dfb80

File tree

9 files changed

+61
-26
lines changed

9 files changed

+61
-26
lines changed

src/client/components/EasyMDE/index.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import PropTypes from 'prop-types'
1818
import Log from '../../logger'
1919

2020
import $ from 'jquery'
21+
import ReactMarkdown from 'react-markdown'
22+
import gfm from 'remark-gfm'
23+
import rehypeRaw from 'rehype-raw'
2124
import toMarkdown from 'tomarkdown'
2225
import Easymde from 'easymde'
2326

@@ -109,7 +112,7 @@ class EasyMDE extends React.Component {
109112
static getDerivedStateFromProps (nextProps, state) {
110113
if (typeof nextProps.defaultValue !== 'undefined') {
111114
if (!state.loaded && nextProps.defaultValue !== state.value)
112-
return { value: toMarkdown(nextProps.defaultValue), loaded: true }
115+
return { value: toMarkdown(nextProps.defaultValue).replace(/\\n/gi, '\n'), loaded: true }
113116
}
114117

115118
return null

src/client/components/Nav/Sidebar/index.jsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import NavSeparator from 'components/Nav/NavSeperator'
2020
import Submenu from 'components/Nav/Submenu'
2121
import SubmenuItem from 'components/Nav/SubmenuItem'
2222

23-
import { updateNavChange } from '../../../actions/nav'
23+
import { updateNavChange } from 'actions/nav'
2424

2525
import Helpers from 'lib/helpers'
2626

@@ -30,11 +30,15 @@ class Sidebar extends React.Component {
3030
}
3131

3232
componentDidMount () {
33-
Helpers.UI.getPlugins((err, result) => {
34-
if (!err && result.plugins) {
35-
this.setState({ plugins: result.plugins })
36-
}
37-
})
33+
// Helpers.UI.getPlugins((err, result) => {
34+
// if (!err && result.plugins) {
35+
// this.setState({ plugins: result.plugins })
36+
// }
37+
// })
38+
const sidebarRoute = document.getElementById('__sidebar_route').innerText
39+
const sidebarSubRoute = document.getElementById('__sidebar_sub_route').innerText
40+
41+
this.props.updateNavChange({ activeItem: sidebarRoute, activeSubItem: sidebarSubRoute })
3842
}
3943

4044
componentDidUpdate () {
@@ -77,6 +81,7 @@ class Sidebar extends React.Component {
7781

7882
render () {
7983
const { activeItem, activeSubItem, sessionUser } = this.props
84+
8085
return (
8186
<div
8287
className={'sidebar nopadding'}

src/client/containers/Modals/CreateTicketModal.jsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { fetchAccountsCreateTicket } from 'actions/accounts'
2626

2727
import $ from 'jquery'
2828
import helpers from 'lib/helpers'
29-
import socket from 'lib/socket'
3029

3130
import BaseModal from 'containers/Modals/BaseModal'
3231
import Grid from 'components/Grid'
@@ -105,7 +104,7 @@ class CreateTicketModal extends React.Component {
105104
e.preventDefault()
106105
const $form = $(e.target)
107106

108-
let data = {}
107+
const data = {}
109108
if (this.issueText.length < 1) return
110109
const allowAgentUserTickets =
111110
this.props.viewdata.get('ticketSettings').get('allowAgentUserTickets') &&
@@ -140,7 +139,7 @@ class CreateTicketModal extends React.Component {
140139
data.tags = this.tagSelect.value
141140
data.priority = this.selectedPriority
142141
data.issue = this.issueMde.easymde.value()
143-
data.socketid = socket.ui.socket.io.engine.id
142+
data.socketid = this.props.socket.io.engine.id
144143

145144
this.props.createTicket(data)
146145
}
@@ -320,6 +319,7 @@ class CreateTicketModal extends React.Component {
320319

321320
CreateTicketModal.propTypes = {
322321
shared: PropTypes.object.isRequired,
322+
socket: PropTypes.object.isRequired,
323323
viewdata: PropTypes.object.isRequired,
324324
ticketTypes: PropTypes.object.isRequired,
325325
priorities: PropTypes.object.isRequired,
@@ -335,6 +335,7 @@ CreateTicketModal.propTypes = {
335335

336336
const mapStateToProps = state => ({
337337
shared: state.shared,
338+
socket: state.shared.socket,
338339
viewdata: state.common.viewdata,
339340
ticketTypes: state.ticketsState.types,
340341
priorities: state.ticketsState.priorities,

src/client/containers/Settings/Legal/index.jsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class LegalSettingsContainer extends React.Component {
3838

3939
onSavePrivacyPolicyClicked (e) {
4040
e.preventDefault()
41+
console.log(this.state.privacyPolicy)
4142
this.props
4243
.updateSetting({
4344
stateName: 'privacyPolicy',
@@ -87,7 +88,4 @@ const mapStateToProps = state => ({
8788
settings: state.settings.settings
8889
})
8990

90-
export default connect(
91-
mapStateToProps,
92-
{ updateSetting }
93-
)(LegalSettingsContainer)
91+
export default connect(mapStateToProps, { updateSetting })(LegalSettingsContainer)

src/client/containers/Tickets/CommentNotePartial.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import ReactHtmlParser from 'react-html-parser'
1717
import Avatar from 'components/Avatar/Avatar'
1818

1919
import helpers from 'lib/helpers'
20-
// import socket from 'lib/socket'
2120

2221
const setupImages = parent => {
2322
const imagesEl = parent.body.querySelectorAll('img:not(.hasLinked)')

src/client/containers/Tickets/SingleTicketContainer.jsx

+22-6
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@ class SingleTicketContainer extends React.Component {
232232
}
233233

234234
transferToThirdParty (e) {
235-
// Update below
236-
// socket.ui.sendUpdateTicketStatus(this.ticket._id, 3)
237235
this.props.transferToThirdParty({ uid: this.ticket.uid })
238236
}
239237

@@ -713,12 +711,21 @@ class SingleTicketContainer extends React.Component {
713711
showSubject: false,
714712
text: comment.comment,
715713
onPrimaryClick: data => {
716-
socket.ui.setCommentText(this.ticket._id, comment._id, data.text)
714+
this.props.socket.emit(TICKETS_COMMENT_NOTE_SET, {
715+
_id: this.ticket._id,
716+
item: comment._id,
717+
isNote: comment.isNote,
718+
value: data.text
719+
})
717720
}
718721
})
719722
}}
720723
onRemoveClick={() => {
721-
socket.ui.removeComment(this.ticket._id, comment._id)
724+
this.props.socket.emit(TICKETS_COMMENT_NOTE_REMOVE, {
725+
_id: this.ticket._id,
726+
value: comment._id,
727+
isNote: comment.isNote
728+
})
722729
}}
723730
/>
724731
))}
@@ -742,12 +749,21 @@ class SingleTicketContainer extends React.Component {
742749
showSubject: false,
743750
text: note.note,
744751
onPrimaryClick: data => {
745-
socket.ui.setNoteText(this.ticket._id, note._id, data.text)
752+
this.props.socket.emit(TICKETS_COMMENT_NOTE_SET, {
753+
_id: this.ticket._id,
754+
item: note._id,
755+
isNote: note.isNote,
756+
value: data.text
757+
})
746758
}
747759
})
748760
}}
749761
onRemoveClick={() => {
750-
socket.ui.removeNote(this.ticket._id, note._id)
762+
this.props.socket.emit(TICKETS_COMMENT_NOTE_REMOVE, {
763+
_id: this.ticket._id,
764+
value: note._id,
765+
isNote: note.isNote
766+
})
751767
}}
752768
/>
753769
))}

src/client/lib/useTrudeskReady.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import $ from 'jquery'
33

44
export default function useTrudeskReady (callback) {
55
useEffect(() => {
6-
$(window).on('$trudesk:ready', () => {
6+
$(window).on('trudesk:ready', () => {
77
if (typeof callback === 'function') return callback()
88
})
99
}, [])

src/controllers/api/v1/common.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
* Copyright (c) 2014-2019. All rights reserved.
1313
*/
1414

15-
var _ = require('lodash')
16-
var async = require('async')
17-
var winston = require('winston')
15+
const _ = require('lodash')
16+
const async = require('async')
17+
const winston = require('../../../logger')
1818

19-
var commonV1 = {}
19+
const commonV1 = {}
2020

2121
/**
2222
* Preforms login with username/password and adds
@@ -135,4 +135,16 @@ commonV1.logout = function (req, res) {
135135
)
136136
}
137137

138+
commonV1.privacyPolicy = async (req, res) => {
139+
const SettingsUtil = require('../../../settings/settingsUtil')
140+
try {
141+
const results = await SettingsUtil.getSettings()
142+
143+
return res.json({ success: true, privacyPolicy: results.data.settings.privacyPolicy.value })
144+
} catch (err) {
145+
winston.warn(err)
146+
return res.status(500).json({ success: false, error: err })
147+
}
148+
}
149+
138150
module.exports = commonV1

src/controllers/api/v1/routes.js

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = function (middleware, router, controllers) {
3131
router.post('/api/v1/login', apiCtrl.common.login)
3232
router.get('/api/v1/login', apiv1, apiCtrl.common.getLoggedInUser)
3333
router.get('/api/v1/logout', apiv1, apiCtrl.common.logout)
34+
router.get('/api/v1/privacypolicy', apiCtrl.common.privacyPolicy)
3435

3536
// Roles
3637
router.get('/api/v1/roles', apiv1, apiCtrl.roles.get)

0 commit comments

Comments
 (0)