From 0bd099d05ac8f296d24df556e4fcd1ee7ba10001 Mon Sep 17 00:00:00 2001 From: Guillermo Date: Thu, 19 Dec 2019 17:06:12 -0300 Subject: [PATCH] add support for custom ticket lists --- .../src/app-components/ticket-query-list.js | 8 ++++++- .../src/app/admin/panel/admin-panel-menu.js | 21 +++++++++++++++++-- .../tickets/admin-panel-search-tickets.js | 4 +++- client/src/index.html | 1 - tests/staff/get-all.rb | 1 - 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/client/src/app-components/ticket-query-list.js b/client/src/app-components/ticket-query-list.js index a5c7edbc..f28dbc3b 100644 --- a/client/src/app-components/ticket-query-list.js +++ b/client/src/app-components/ticket-query-list.js @@ -22,6 +22,12 @@ class TicketQueryList extends React.Component { this.getTickets(); } + componentDidUpdate(prevProps) { + if (this.props.customList.title !== prevProps.customList.title) { + this.getTickets(); + } + } + render() { return (
@@ -38,7 +44,7 @@ class TicketQueryList extends React.Component { path: '/ticket/search', data: { page : this.state.page, - ...this.props.filters + ...this.props.customList.filters } }).then((result) => { this.setState({ diff --git a/client/src/app/admin/panel/admin-panel-menu.js b/client/src/app/admin/panel/admin-panel-menu.js index da34ccb7..20734df3 100644 --- a/client/src/app/admin/panel/admin-panel-menu.js +++ b/client/src/app/admin/panel/admin-panel-menu.js @@ -76,7 +76,7 @@ class AdminPanelMenu extends React.Component { getGroupItemIndex() { const group = this.getRoutes()[this.getGroupIndex()]; - const pathname = this.props.location.pathname; + const pathname = this.props.location.pathname + this.props.location.search; return _.findIndex(group.items, {path: pathname}); } @@ -90,7 +90,23 @@ class AdminPanelMenu extends React.Component { return (groupIndex === -1) ? 0 : groupIndex; } + getCustomlists() { + if(window.customTicketList){ + return window.customTicketList.map((item, index) => { + return { + name: item.title, + path: '/admin/panel/tickets/search-tickets?custom=' + index, + level: 1 + } + }) + } else { + return []; + } + } + getRoutes() { + const customLists = this.getCustomlists(); + return this.getItemsByFilteredByLevel([ { groupName: i18n('DASHBOARD'), @@ -135,7 +151,8 @@ class AdminPanelMenu extends React.Component { name: i18n('CUSTOM_RESPONSES'), path: '/admin/panel/tickets/custom-responses', level: 2 - } + }, + ...customLists ]) }, { diff --git a/client/src/app/admin/panel/tickets/admin-panel-search-tickets.js b/client/src/app/admin/panel/tickets/admin-panel-search-tickets.js index b9f4842d..2dd4f530 100644 --- a/client/src/app/admin/panel/tickets/admin-panel-search-tickets.js +++ b/client/src/app/admin/panel/tickets/admin-panel-search-tickets.js @@ -14,13 +14,15 @@ class AdminPanelSearchTickets extends React.Component { return (
- {(this.props.error) ? {i18n('ERROR_RETRIEVING_TICKETS')} : } + {(this.props.error) ? {i18n('ERROR_RETRIEVING_TICKETS')} : }
); } getFilters() { + let customList = window.customTicketList[this.props.location.query.custom*1] ? window.customTicketList[this.props.location.query.custom*1] : null return { + ...customList }; } } diff --git a/client/src/index.html b/client/src/index.html index 90c8c2e2..a00af5b1 100755 --- a/client/src/index.html +++ b/client/src/index.html @@ -12,7 +12,6 @@
- diff --git a/tests/staff/get-all.rb b/tests/staff/get-all.rb index 432fa3cd..f8571c71 100644 --- a/tests/staff/get-all.rb +++ b/tests/staff/get-all.rb @@ -13,7 +13,6 @@ describe'/staff/get-all' do result['data'][0]['departments'] = result['data'][0]['departments'].sort_by do |department| department['id'].to_i end - puts result['data'] (result['data'][0]['name']).should.equal('Emilia Clarke') (result['data'][0]['email']).should.equal('staff@opensupports.com')