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

Change Project Type Form #1610

Merged
merged 25 commits into from
Jan 31, 2023
Merged

Change Project Type Form #1610

merged 25 commits into from
Jan 31, 2023

Conversation

Pezmc
Copy link
Contributor

@Pezmc Pezmc commented Jan 25, 2023

Description

Implements changing of project types as a "danger" action (this section likely to be renamed in future).

When a user changes project type, the project is suspended, reconfigured, then resumed.

Technically, this uses the same form as the create project form, with some tweaks in behaviour such as hiding the template fields.

UI After UX Review

See comment thread for details.

Screenshot 2023-01-30 at 16 14 51

Screenshot 2023-01-30 at 17 08 18

Original UI from PR

Screenshot 2023-01-25 at 16 17 36

Screenshot 2023-01-25 at 16 18 03

Related Issue(s)

#595

Checklist

Requirements

  • Extract shared logic between create/update/copy into a single component
  • During edit only permit the Confirm Changes when changes to the project have been made (i.e. dirty form)
  • Do not permit template to be updated
  • In the UI combine update stack and update project type
  • E2E test coverage of updating a projects stack or type
  • E2E test coverage of creating and copying projects (previously untested)

@Pezmc Pezmc force-pushed the change-project-type-refactor branch from a24f1af to 74fbc10 Compare January 25, 2023 10:21
@Pezmc Pezmc marked this pull request as ready for review January 25, 2023 16:58
@joepavitt
Copy link
Contributor

@Pezmc just flagging a conflict, fairly sure we want what you have, but wanted to make sure as it's likely linked to the moving of the "you have credit" message

@@ -361,7 +361,55 @@ module.exports = async function (app) {
}
}, async (request, reply) => {
let changed = false
if (request.body.stack) {
if (request.body.changeProjectType === true) {
Copy link
Member

Choose a reason for hiding this comment

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

This end point is somewhat overloaded, but it does already let you set the ProjectType of the project only if the project doesn't already have a ProjectType set. This was added when we introduced ProjectTypes as a one-off task for users to set the type of their project. This is why the handling for that will bail out early if the Project already has a ProjectType set.

I'm wondering if, rather than introduce a changeProjectType flag when we don't have equivalents for the other things you can change, this logic should be moved down to the existing handling when body.projectType is set (line 434 of the proposed changes).

That block then has two branches - one for setting ProjectType initially, and one for changing ProjectType.

We should look at the data on production, but handling projects without a ProjectType is very much a legacy edge case that would only apply to FF instances that have been running since before ProjectTypes were introduced.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if, rather than introduce a changeProjectType flag when we don't have equivalents for the other things you can change, this logic should be moved down to the existing handling when body.projectType is set (line 434 of the proposed changes).

Essentially, there was the original "no project type" code that was rather implicit in the fact that if body supplied a projectType.

With the introduction of Change Project Type, the body needs to contain both projectType AND stack in the body - so the explicit changeProjectType was introduced to make this 100% explicit as to intention rather than inferring intention from values in body. It is much more deliberate than being present or not.

Also, since the first part of the logic would capture execution (because body.stack is needed in a project type change) we would have to have some if (stack && !projectType) logic in the first part of the handler (i.e. less explicit intention)

@Pezmc
Copy link
Contributor Author

Pezmc commented Jan 27, 2023

I've resolved the conflict with main from #1613 and made a couple of minor tweaks to make the endpoint easier to follow.

I'm going to re-work that method in a follow up PR as it's become incredibly overloaded.

@knolleary
Copy link
Member

Can you summarize the public API changes this is making? (ie to the /api/v1/projects/... end point) I appreciate its an overloaded endpoint already, so it would be good to get something written down to outline what is being changed.

@Pezmc
Copy link
Contributor Author

Pezmc commented Jan 27, 2023

@knolleary The only API change is adding a new flag changeProjectDefinition to the /api/v1/projects endpoint, which triggers a new path in the code (to be refactored away in follow up). When that flag is set, both projectType and stack are required, and the projects type and stack are changed, with a project restart in-between.

@Pezmc Pezmc force-pushed the change-project-type-refactor branch from 125a4ba to bcd0487 Compare January 27, 2023 17:01
@Pezmc
Copy link
Contributor Author

Pezmc commented Jan 27, 2023

@knolleary
Copy link
Member

Having tried this out, I see you've combined changing stack and changing type into one option.

Updating the stack is a far more routine maintenance action on the project than changing the type. That said, we did introduce versioning of stacks - and if there is a new version of the existing stack available, they get an 'Update Stack' button which gives them a one-click update without having to make any choices:

image

For the new button 'Change Project Settings' doesn't feel like the right text. As we discussed in slack, Project Settings means something else here. How about just labelling it as Change Project Type as that is what it's for.

@Steve-Mcl
Copy link
Contributor

Updating the stack is a far more routine maintenance action on the project than changing the type. That said, we did introduce versioning of stacks - and if there is a new version of the existing stack available, they get an 'Update Stack' button which gives them a one-click update without having to make any choices

Hi @knolleary not sure if you are asking if the "Update Stack" is now part of the "Change Project Type" or if you are answering a previous question - but for reference, the "Update Stack" button is still there on the form: https://github.com/flowforge/flowforge/pull/1610/files#diff-a5605eb4d14a272712bacb8569e913d4c3f1885a374d594f77277d7d91d2656bR20-R29

Apologies if I am misreading.

@knolleary
Copy link
Member

ot sure if you are asking if the "Update Stack" is now part of the "Change Project Type" or if you are answering a previous question - but for reference, the "Update Stack" button is still there on the form:

I appreciate my comment is a little muddled because I changed tack half way through writing it.

My original point is the 'Change Stack' button has been replaced by this new 'Change Project Settings' button

image

This means changing a project's stack now forces the user through billing considerations, whereas it is only when they change the type will anything need to change with their billing.

@Steve-Mcl
Copy link
Contributor

My original point is the 'Change Stack' button has been replaced by this new 'Change Project Settings' button

This means changing a project's stack now forces the user through billing considerations, whereas it is only when they change the type will anything need to change with their billing.

@knolleary

In my initial work, the change of stack did not show any change of billing. The whole section around billing was totally hidden unless the project type was being changed. I have yet to work through all the changes but I assume that is still the case. I will update you on what I find

@Pezmc
Copy link
Contributor Author

Pezmc commented Jan 30, 2023

@knolleary I've addressed the comments from our call earlier this morning and this PR is ready for re-review

Danger Screen

  • Restored the change stack option
  • Moved the change project option further down as it's a less common operation

Screenshot 2023-01-30 at 16 14 51

Change Project Page

  • Charges table hidden when there are only changes to stack

Screenshot 2023-01-30 at 17 08 28

  • UI tweaks to improve look of form

Screenshot 2023-01-30 at 17 08 18

Screenshots updated in description

@knolleary knolleary merged commit 7f22949 into main Jan 31, 2023
@knolleary knolleary deleted the change-project-type-refactor branch January 31, 2023 09:53
@Steve-Mcl Steve-Mcl linked an issue Feb 14, 2023 that may be closed by this pull request
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.

Change project type
4 participants