From 9db530f2ddc8e0808ee7495789d7e7625dce70ea Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 21 Jan 2017 00:20:25 -0300 Subject: [PATCH] Ivan - Add ticket view page for no user system[skip ci] --- client/src/app/Routes.js | 3 +- .../panel/tickets/admin-panel-view-ticket.js | 14 ++- client/src/app/main/main-check-ticket-page.js | 2 +- client/src/app/main/main-view-ticket-page.js | 20 ++++ .../src/app/main/main-view-ticket-page.scss | 3 + client/src/app/main/main-view-ticket.js | 104 ------------------ client/src/data/fixtures/ticket-fixtures.js | 2 + 7 files changed, 40 insertions(+), 108 deletions(-) create mode 100644 client/src/app/main/main-view-ticket-page.js create mode 100644 client/src/app/main/main-view-ticket-page.scss delete mode 100644 client/src/app/main/main-view-ticket.js diff --git a/client/src/app/Routes.js b/client/src/app/Routes.js index 6349f569..70bcdcad 100644 --- a/client/src/app/Routes.js +++ b/client/src/app/Routes.js @@ -14,6 +14,7 @@ import MainVerifyTokenPage from 'app/main/main-verify-token-page'; import MainRecoverPasswordPage from 'app/main/main-recover-password/main-recover-password-page'; import MainMaintenancePage from 'app/main/main-maintenance-page'; import MainCheckTicketPage from 'app/main/main-check-ticket-page'; +import MainViewTicketPage from 'app/main/main-view-ticket-page'; import DashboardLayout from 'app/main/dashboard/dashboard-layout'; import DashboardListTicketsPage from 'app/main/dashboard/dashboard-list-tickets/dashboard-list-tickets-page'; @@ -67,7 +68,7 @@ export default ( - + diff --git a/client/src/app/admin/panel/tickets/admin-panel-view-ticket.js b/client/src/app/admin/panel/tickets/admin-panel-view-ticket.js index b0002fdc..6cf0f8c3 100644 --- a/client/src/app/admin/panel/tickets/admin-panel-view-ticket.js +++ b/client/src/app/admin/panel/tickets/admin-panel-view-ticket.js @@ -12,6 +12,16 @@ import Header from 'core-components/header'; class AdminPanelViewTicket extends React.Component { + static propTypes = { + avoidSeen: React.PropTypes.bool, + assignmentAllowed: React.PropTypes.bool + }; + + static defaultProps = { + avoidSeen: false, + assignmentAllowed: true + }; + state = { loading: true, ticket: {} @@ -62,7 +72,7 @@ class AdminPanelViewTicket extends React.Component { return { ticket: this.state.ticket, onChange: this.retrieveTicket.bind(this), - assignmentAllowed: true, + assignmentAllowed: this.props.assignmentAllowed, customResponses: this.props.customResponses, editable: this.state.ticket.owner && this.state.ticket.owner.id == SessionStore.getSessionData().userId }; @@ -83,7 +93,7 @@ class AdminPanelViewTicket extends React.Component { ticket: result.data }); - if(result.data.unreadStaff) { + if(!this.props.avoidSeen && result.data.unreadStaff) { API.call({ path: '/ticket/seen', data: { diff --git a/client/src/app/main/main-check-ticket-page.js b/client/src/app/main/main-check-ticket-page.js index 4eb84a37..f95297a3 100644 --- a/client/src/app/main/main-check-ticket-page.js +++ b/client/src/app/main/main-check-ticket-page.js @@ -88,7 +88,7 @@ class MainCheckTicketPage extends React.Component { onTicketGetSuccess(result) { SessionStore.setItem('token', result.data.token); - setTimeout(() => {browserHistory.push('/view-ticket/' + this.state.form.email + '/' + this.state.form.ticketNumber)}, 2000); + setTimeout(() => {browserHistory.push('/view-ticket/' + this.state.form.ticketNumber)}, 2000); } } diff --git a/client/src/app/main/main-view-ticket-page.js b/client/src/app/main/main-view-ticket-page.js new file mode 100644 index 00000000..b5517367 --- /dev/null +++ b/client/src/app/main/main-view-ticket-page.js @@ -0,0 +1,20 @@ +import React from 'react'; + +import AdminPanelViewTicket from 'app/admin/panel/tickets/admin-panel-view-ticket' + +import Widget from 'core-components/widget'; + +class MainViewTicketPage extends React.Component { + + render() { + return ( +
+ + + +
+ ); + } +} + +export default MainViewTicketPage; \ No newline at end of file diff --git a/client/src/app/main/main-view-ticket-page.scss b/client/src/app/main/main-view-ticket-page.scss new file mode 100644 index 00000000..4ba281a7 --- /dev/null +++ b/client/src/app/main/main-view-ticket-page.scss @@ -0,0 +1,3 @@ +.main-view-ticket-page { + padding: 0 15px; +} \ No newline at end of file diff --git a/client/src/app/main/main-view-ticket.js b/client/src/app/main/main-view-ticket.js deleted file mode 100644 index 3d093cc9..00000000 --- a/client/src/app/main/main-view-ticket.js +++ /dev/null @@ -1,104 +0,0 @@ -import React from 'react'; -import _ from 'lodash'; -import {connect} from 'react-redux'; - -import API from 'lib-app/api-call'; -import i18n from 'lib-app/i18n'; -import SessionStore from 'lib-app/session-store'; - -import TicketViewer from 'app-components/ticket-viewer'; -import Loading from 'core-components/loading'; -import Header from 'core-components/header'; - -class MainViewTicket extends React.Component { - - state = { - loading: true, - ticket: {} - }; - - componentDidMount() { - this.retrieveTicket(); - } - - render() { - return ( -
-
- {(this.state.loading) ? this.renderLoading() : this.renderView()} -
- ); - } - - renderLoading() { - return ( -
- -
- ) - }; - - renderView() { - return (_.isEmpty(this.state.ticket)) ? this.renderNoPermissionError() : this.renderTicketView(); - } - - renderNoPermissionError() { - return ( -
- {i18n('NO_PERMISSION')} -
- ); - } - - renderTicketView() { - return ( -
- -
- ); - } - - getTicketViewProps() { - return { - ticket: this.state.ticket, - onChange: this.retrieveTicket.bind(this), - assignmentAllowed: true, - customResponses: this.props.customResponses, - editable: this.state.ticket.owner && this.state.ticket.owner.id == SessionStore.getSessionData().userId - }; - } - - retrieveTicket() { - API.call({ - path: '/ticket/get', - data: { - ticketNumber: this.props.params.ticketNumber - } - }).then(this.onRetrieveSuccess.bind(this)).catch(this.onRetrieveFail.bind(this)) - } - - onRetrieveSuccess(result) { - this.setState({ - loading: false, - ticket: result.data - }); - - if(result.data.unreadStaff) { - API.call({ - path: '/ticket/seen', - data: { - ticketNumber: this.props.params.ticketNumber - } - }); - } - } - - onRetrieveFail() { - this.setState({ - loading: false, - ticket: {} - }); - } -} - -export default MainViewTicket; \ No newline at end of file diff --git a/client/src/data/fixtures/ticket-fixtures.js b/client/src/data/fixtures/ticket-fixtures.js index 1975b855..dea4ee7f 100644 --- a/client/src/data/fixtures/ticket-fixtures.js +++ b/client/src/data/fixtures/ticket-fixtures.js @@ -110,10 +110,12 @@ module.exports = [ closed: false, priority: 'medium', author: { + id: 3, name: 'Haskell Curry', email: 'haskell@lambda.com' }, owner: { + id: 1, name: 'Steve Jobs' }, events: [