New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Upload locally generated report to bowtie UI #297
Feature: Upload locally generated report to bowtie UI #297
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one major design suggestion, which boils down to:
-
instead of using
fetch()
directly in component we could useloaders
from react-router. As loaders can be parametrized we could have just one route for all the routes that require report data from web. https://reactrouter.com/en/main/route/loader -
ideally,
App
component could be just a component for pure presentation (maybe this component should get a rename?) - by that I mean it won't make any HTTP request or any other things like that, but it will receive report data (lines
) via prop or via beforementionedloader
data -
as for page where user is expected to upload local files - it could be implemented as a component that wraps
App
component, and it either renders the file drop area or theApp
with data extracted from provided file
I could use loaders
from the beginning, but now I think it gets more relevant as we have 2 sources of data. Also, if loader
API doesn't work for us we could provide out own abstraction for providing data from the web, which probably would be another version of wrapper for App
.
Let me know what you think about this approach or if anything is unclear
Was reading about Yes, It's better to fully utilize the feature of resuibility of components. Will create a wrapper component that will render either |
I had in mind that we could simplify routes configuration by having more generic routing, like: createHashRouter([
{
path: "/:draftName",
element: <App .../>,
loader: ({ params }) => {
return someFetchingFunction(params.draftName);
},
},
]); |
…e App with data extracted from provided file
tried this loader function - {
path: "/:draftName",
element: <ReportDataHandler />,
loader: ({ params }) => {
console.log(params.draftName);
return fetch(
`https://bowtie-json-schema.github.io/bowtie/${params.draftName}.jsonl`
)
.then((response) => response.text())
.then((jsonl) => {
const dataObjectsArray = jsonl.trim().split(/\n(?=\{)/);
const lines = dataObjectsArray.map((line) => JSON.parse(line));
return lines;
});
},
}, Even though the draftName variable correctly reflects the draft name in the console, why is it resolved as undefined in the URL? |
Are you sure the request call doesn't come from somewhere else in the code? Because if it prints it right it should also send request to a valid URL. If you still won't be able to fix it, you could commit your changes and then I could have a look |
Yes, the call was from another component! 😐 |
for more information, see https://pre-commit.ci
…bey/bowtie into upload-local-report
used Context APIs to make the theme data available centrally! |
for more information, see https://pre-commit.ci
…bey/bowtie into upload-local-report
for more information, see https://pre-commit.ci
…bey/bowtie into upload-local-report
Added the conditional rendering of components ( Most of the issues related to this specific PR have been resolved, and I think it is now ready to merge! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment/question, after that feel free to merge!
Co-authored-by: Julian Berman <Julian@GrayVines.com>
for more information, see https://pre-commit.ci
…bey/bowtie into upload-local-report
for more information, see https://pre-commit.ci
This PR enables users to upload locally generated JSON data to the Bowtie UI. It allows for a more informative and comprehensive representation of their local reports.