From ebfb61d77631f813746942ef011ca328b1e634f9 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 21 Oct 2017 08:22:02 +0200 Subject: [PATCH 1/4] Renamed admin param to request from search --- client/app/Root.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/app/Root.jsx b/client/app/Root.jsx index 707e644..c9b8cb2 100644 --- a/client/app/Root.jsx +++ b/client/app/Root.jsx @@ -14,7 +14,7 @@ class Root extends Component { - + From 87a2de1d0b486233712964d8dede6c5ea028b9cd Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 21 Oct 2017 09:44:12 +0200 Subject: [PATCH 2/4] Reflects the changes to the url paramater for admin, is now names requestParam. Also the param is passed to Sidebar so that we can highlight the one selected. --- client/app/components/admin/Admin.jsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/client/app/components/admin/Admin.jsx b/client/app/components/admin/Admin.jsx index 8594c11..31a451d 100644 --- a/client/app/components/admin/Admin.jsx +++ b/client/app/components/admin/Admin.jsx @@ -29,7 +29,7 @@ class AdminComponent extends React.Component { fetchJSON('https://apollo.kevinmidboe.com/api/v1/plex/requests/all', 'GET') .then(result => { this.setState({ - requested_objects: result.requestedItems + requested_objects: result.requestedItems.reverse() }) }) } @@ -49,18 +49,25 @@ class AdminComponent extends React.Component { return } - let display = undefined - if (this.props.match.params.search && this.state.requested_objects !== '') { - display = this.state.requested_objects[this.props.match.params.search] + let selectedRequest = undefined; + let listItemSelected = undefined; + + const requestParam = this.props.match.params.request; + if (requestParam && this.state.requested_objects !== '') { + selectedRequest = this.state.requested_objects[requestParam] + listItemSelected = requestParam } return (
- +
- +
) From 277105e6df1ce12104b1e18c0c1e1229b3696594 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 21 Oct 2017 09:45:46 +0200 Subject: [PATCH 3/4] Our selected Request is passed through props, the prop name is now changed from display to selectedRequest. --- client/app/components/admin/AdminRequestInfo.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/app/components/admin/AdminRequestInfo.jsx b/client/app/components/admin/AdminRequestInfo.jsx index fa7c36e..dd508de 100644 --- a/client/app/components/admin/AdminRequestInfo.jsx +++ b/client/app/components/admin/AdminRequestInfo.jsx @@ -35,7 +35,7 @@ class AdminRequestInfo extends Component { minHeight: '450px', } } - const request = this.props.display; + const request = this.props.selectedRequest; if (request) { return ( From a0565f79d22c1505732c58815c9b51db53e6dde0 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 21 Oct 2017 09:48:13 +0200 Subject: [PATCH 4/4] Changed name of variable element to requestElement and now the link name of a list item is generated by generateListElements and if this element is the one selected make it visually different --- client/app/components/admin/Sidebar.jsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/client/app/components/admin/Sidebar.jsx b/client/app/components/admin/Sidebar.jsx index 09dc4ab..5d001b0 100644 --- a/client/app/components/admin/Sidebar.jsx +++ b/client/app/components/admin/Sidebar.jsx @@ -3,12 +3,23 @@ import { Link } from 'react-router-dom'; class SidebarComponent extends Component { + generateListElements(index, item) { + if (index == this.props.listItemSelected) + return ( + {item.name} + ) + else + return ( + {item.name} + ) + } + displayRequestedElementsInfo() { if (this.props.requested_objects) { - let element = this.props.requested_objects.map((item, index) => { + let requestedElement = this.props.requested_objects.map((item, index) => { return ( - {item.name} + { this.generateListElements(index, item) } {item.status} {item.requested_date} @@ -25,7 +36,7 @@ class SidebarComponent extends Component { - {element} + {requestedElement} )