Skip to content

Implement URL based ticket loading #17

Closed
campb303 opened this issue Aug 6, 2020 · 4 comments
Closed

Implement URL based ticket loading #17

campb303 opened this issue Aug 6, 2020 · 4 comments
Assignees
Labels
feature-request Request for functionality that has not already been implemented

Comments

@campb303
Copy link
Collaborator

campb303 commented Aug 6, 2020

webqueue2 currently have no way to go straight to an item from a URL. This must be done by loading the page, finding the item and selecting it. This has several drawbacks:

  • The very common workflow of referring to an item becomes very tedious
  • Items cannot be linked to
  • Items cannot be referenced by ecnslackbot

Using react-router all of this functionality can be achieved allowing for getting an item by something like:

webqueue2.com/me/22 --> the ME 22 ItemView

@campb303 campb303 added feature-request Request for functionality that has not already been implemented frontend labels Aug 7, 2020
@campb303 campb303 added this to the v1 milestone Sep 14, 2020
@celfreic celfreic self-assigned this Sep 24, 2020
@celfreic
Copy link

celfreic commented Sep 29, 2020

Found that react-router may result in semi-major application architecture changes needing to be made. Route path="/sample/:var" will allow for a route parameter named var to referenced in the component or JSX render block. See react router documentation for more details.

Since the rendering of blocks of JSX is dependent upon routes, it may make sense to move forward with the selection of queue table items to redirect the app to an appropriate route. That route would then trigger any necessary API calls or backpropagation of information to the app. The resulting architecture change would mean that many of the current component props may need to change. <ItemTable setActiveItem={setActiveItem} setSidebarOpen={setSidebarOpen}/> would no longer need to hold reference to a state for setting the active item. Side bar opening can also be simplified or removed altogether. Instead the active item and current queue would both need to become app-level references that passed into the route block that will control ItemView. Thus the architecture for rendering becomes more so dependent on the route parameters than changing functionality itself, and its modifications are made to the route parameters.

For a simple start that utilizes a global list of items see this video.

@celfreic
Copy link

celfreic commented Oct 1, 2020

Documenting the various React-Routers:

import {BrowserRouter as Router, Route} from "react-router-dom";

<Router>
     <Route path="/" render={() => (
          <p>Root content</p>
     )}/>
    <Route path="/first" render={() => (
          <p>First item (Root should be above me, url should be /first)</p>
     )}/>
</Router>
import {HashRouter as Router, Route} from "react-router-dom";

<Router>
     <Route path="/" render={() => (
          <p>Root content</p>
     )}/>
    <Route path="/first" render={() => (
          <p>First item (Root should be above me, url should be #/first)</p>
     )}/>
</Router>
  • MemoryRouter: Router that persists the URL in memory so that navigation can be done without changing the address in the address bar. Useful for testing.
    localhost:3000 => localhost:3000
import {MemoryRouter as Router, Route, Link} from "react-router-dom";

<Router>
     <Route path="/" render={() => (
          <p>Root content</p>
     )}/>
    <Link to="/first">First</Link>
    <Route path="/first" render={() => (
          <p>First item (Root should be above me, url should be unchanged)</p>
     )}/>
</Router>
  • StaticRouter: Router that never changes location. Most useful in server-side rendering scenarios where the user is not clicking. Sample not provided because server side rendering via http is outside the scope of this project currently.

@celfreic
Copy link

celfreic commented Oct 1, 2020

Moving forward architecture changes should ensure that the content within the box surrounding Items is the only area affected by the Router so that it will still mount the surrounding box initially. Also Ensure that any changes made to the URL via clicking rows in the item table are made to the browser history and are compatible with the back button.

@campb303
Copy link
Collaborator Author

Resolved here

Sign in to join this conversation on GitHub.
Labels
feature-request Request for functionality that has not already been implemented
Projects
None yet
Development

No branches or pull requests

2 participants