Skip to content
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

Create projects #154

Merged
merged 16 commits into from
Oct 23, 2023
Merged

Create projects #154

merged 16 commits into from
Oct 23, 2023

Conversation

oliverroick
Copy link
Contributor

@oliverroick oliverroick commented Sep 22, 2023

Contributes to #151

  • Adds new page at /create-project
  • Adds component NotFound; we show this when the user is signed in and does not have the required permission to create projects
  • Adds component CreateProjectform; it provides the form to create a new project

@oliverroick oliverroick marked this pull request as ready for review October 9, 2023 01:15
Copy link
Member

@nathanielrindlaub nathanielrindlaub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking solid @oliverroick! Thank you! Just a handful of misc. adjustments and bug fixes and I think we're good to merge.

src/features/projects/projectsSlice.js Show resolved Hide resolved
const stateMsg = useSelector(selectCreateProjectState);

const tzOptions = timeZonesNames.map((tz) => ({ value: tz, label: tz }));
const mlModelOptions = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pull the ML model options from the DB here rather than hard-code them. Just skimming the code here but I think if we use the fetchModels thunk and don't pass in any model _ids, it should return all of them, and we can build a list of mlModelOptions from that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to use the existing thunk because no project is selected on the create-project page. But I added a new thunk and state to store the model options.

src/features/projects/CreateProjectForm.jsx Show resolved Hide resolved
};
state.loadingStates.createProject = ls;

state.projects = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After I successfully create a project and try to navigate to the app by clicking the "application" nav link, the app crashes, and it looks like it may be because there's a bug here and all of the previous projects in state get accidentally overwritten with the newly created project. Your code here looks like it should work to me so I'm not totally sure what's going on...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bug, projects should be an array not an object. I fixed that but now I'm seeing another error TypeError: Cannot read property 'roles' of undefined but I'm not sure what this is related to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not seeing that new error.

However, I'm noticing another related bug. It's a little odd and I'm not sure how consequential so I'm not sure how much time to dedicate towards a fix, but the gist is:

  • for a super user to access the animl.camera/create-project form, they would either have to be signed in already or navigate to animl.camera/app and sign in to get their JWT with their creds. After being authenticated, the ProjectAndViewNav.jsx component looks to see if there are any projects in state, and if not, it fetches them. So at this point the user would presumably have some projects already in state.
  • if they they want to create a project, they'd have to manually type out that URL because there's no link to it, and when they navigate there it's a page refresh the projects get removed from state.
  • once the user successfully creates a project, that gets added to the state, BUT if they then navigate back to the app using the "application" nav link, the state is preserved and the ProjectAndViewNav.jsx component sees that there are already projects in the state so it doesn't re-fetch them.

There are probably some fairly straightforward ways to fix this (maybe instead of housing the create-projects form on a separate page, we put it in a modal), but I am not overly concerned about this so I think let's call it good enough for now.

@nathanielrindlaub nathanielrindlaub merged commit 42d6cec into main Oct 23, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants