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

Add a gcp project picker to the repo flow #5003

Merged
merged 5 commits into from
Oct 13, 2023

Conversation

siggisim
Copy link
Member

Screenshot:
Screenshot 2023-10-11 at 2 24 28 PM

@siggisim siggisim marked this pull request as ready for review October 11, 2023 21:25
Copy link
Member

@bduffany bduffany left a comment

Choose a reason for hiding this comment

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

I think you can simplify this by having the Picker render inline rather than in a modal, and then instead using <Modal> from app/components/modal/modal.tsx

<Modal
  isVisible={this.state.isPickerVisible}
  onRequestClose={() => this.setState({ isPickerVisible: false })} >
    <Picker
      options={this.state.pickerOptions}
      onSelect={selection => { this.setState({ selection, isPickerVisible: false}); } /> 
</Modal>

Benefits:

  • Can get rid of the custom CSS for showing the backdrop behind the picker (Modal should already handle this)
  • Inherit other nice behaviors from <Modal> such as dismissing with Esc
  • Picker becomes more generally useful, e.g. we might have a form where it makes sense to render this inline in the form
  • No need for the global picker service which adds a bit of complexity / indirection
  • No need to render <Picker> in the root component

selectedIndex: number;
}

export default class PickerComponent extends React.Component<{}, State> {
Copy link
Member

Choose a reason for hiding this comment

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

nit: the stuff under app/components doesn't use the "Component" suffix

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@siggisim
Copy link
Member Author

I think you can simplify this by having the Picker render inline rather than in a modal, and then instead using <Modal> from app/components/modal/modal.tsx

<Modal
  isVisible={this.state.isPickerVisible}
  onRequestClose={() => this.setState({ isPickerVisible: false })} >
    <Picker
      options={this.state.pickerOptions}
      onSelect={selection => { this.setState({ selection, isPickerVisible: false}); } /> 
</Modal>

Benefits:

  • Can get rid of the custom CSS for showing the backdrop behind the picker (Modal should already handle this)
  • Inherit other nice behaviors from <Modal> such as dismissing with Esc
  • Picker becomes more generally useful, e.g. we might have a form where it makes sense to render this inline in the form
  • No need for the global picker service which adds a bit of complexity / indirection
  • No need to render <Picker> in the root component

I've moved the Picker component to use a Modal instead of creating its own shade. That gets rid of the custom CSS and the nice modal behaviors like support for Esc (though I feel the focus behavior is a bit wonky - i.e. if you click on the shade when you've got another component focused, it doesn't seem to close the modal - it requires another click on the shade).

I like having the picker service, because it allows you to just say "have the user pick one of these options and give me the result in a promise" rather than having to build a whole fancy dom structure and manage state any time you want the user to pick something. Kind of like the old let result = input("Enter your input") api but a bit nicer. I'm down to separate this out into more reusable components once we have the need for more customization / reuse in other places.

@siggisim siggisim merged commit 6d0cfe1 into master Oct 13, 2023
7 checks passed
@siggisim siggisim deleted the siggi-dev-branch-20231011-142505 branch October 13, 2023 04:05
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