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

Sachin/automate infra proxy server ui #2581

Merged
merged 6 commits into from
Jan 30, 2020

Conversation

sachin-msys
Copy link
Contributor

@sachin-msys sachin-msys commented Dec 26, 2019

🔩 Description: What code changed, and why?

Code changes for introduction of infra proxy module in automate-ui In order to make a single source of truth for chef infra servers data here

In this PR following points we have covered:

  1. Created infra-proxy module in automate-ui to keep all infra-proxy related component separate
  2. Designed infra proxy UI flows and used Infra-proxy-service

⛓️ Related Resources

Refered Wireframes: https://chef.invisionapp.com/share/PZSLN5TJ8B9#/screens/369724917
For feature, description refer: #1544

[ Updated Mock Ups Jan 17, 2020 ] - addition of Cookbooks to the InVision prototype
https://chef.invisionapp.com/share/3JVLVFMASDZ#/401258846_V0_-_Client_Runs_-_Cookbooks_-_Details_-_Description
Note: The side nav may different because ideally would love to aggregate the cookbooks from all orgs.

👍 Definition of Done

I have added infra proxy module and UI new pages

  1. chef server's list page
  2. create chef-server popup modal

👟 How to Build

  • build components/infra-proxy-service
  • rebuild components/automate-gateway
  • rebuild components/automate-deployment
  • build components/automate-ui

NOTE: This PR is dependent on PR #2173 so build steps are depending on the same for Infra-proxy-service

@sachin-msys sachin-msys changed the title added chef infra server module in automate Scahin/automate infra proxy server ui Dec 26, 2019
@sachin-msys sachin-msys force-pushed the Sachin/automate-infra-proxy-server-ui branch from e44e766 to f37785b Compare December 27, 2019 09:39
@sachin-msys sachin-msys self-assigned this Dec 27, 2019
Copy link
Contributor

@msorens msorens left a comment

Choose a reason for hiding this comment

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

Looking good; some comments noted below.

Comment on lines 25 to 28
// Allows valid FQDN only
VALID_FQDN: '(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/?',

// Allows valid IP Address only (ipv4)
VALID_IP_ADDRESS: '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'
Copy link
Contributor

Choose a reason for hiding this comment

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

If you copied these from a published source it is important to add a comment noting the source.
If you created these from scratch, I think it would be really good to add tests (at least a couple dozen for each) that show what does and does not validate. That will let folks who are less familiar with reading regex's be able to judge whether it meets product needs.

Just a few problem examples off-hand for FQDN:

These should match but do not:

    http://fo_o.bar/
    https://bit.ly/2OWGwiL

These should not match but do:

    http://foo.bar com/
    http://foo.bar..com/
    http://...foo.bar.com/
    http://foo.bar-.-.

Probably better to find a reliable, documented source rather than create your own to avoid such problem areas. 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @msorens
I have rewrote the REGX for FQDN but still not able to create a perfect one so can I get a help on the same please.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did a bit of web searching and found a couple possibilities but because of the nature of an FQDN there does not seem to be a consensus of a good matching regex. So my suggestion is let's back up; you should chat with whoever is requesting this work (is that @jonong1972 ?) to find out what types of FQDN's are needed. It may be that for chef servers we can more precisely specify a URL.

Copy link
Contributor

Choose a reason for hiding this comment

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

I found that we use this in a couple spots in the code base:



which, in English means: either http:// or https:// followed by something-dot-something.
It is a very forgiving pattern--it will not exclude any valid ones, which is important--though it will certainly allow invalid ones.

@jonong1972 Do you think that pattern would be sufficient here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@msorens created followed regx which is allowing most of valid ones and blocking most of invalid one

VALID_FQDN: /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-zA-Z0-9_]+([\-\.]{1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,5}(:[0-9]{1,5})?(\/.*)?$/,

tried and added test cases for the examples which you have provided
Valid Inputs

http://fo_o.bar/
https://bit.ly/2OWGwiL

Invalid Inputs

 http://foo.bar com/
 http://foo.bar..com/
 http://...foo.bar.com/
 http://foo.bar-.-.

working well with above all can we go with this ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I want to get some product or UX guidance on this question--I will try to speak to @jonong1972 about this tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sachin-msys lets not do any validation on this input right now, we can come back and iterate later after this work is out of discovery.

Copy link
Contributor Author

@sachin-msys sachin-msys Jan 29, 2020

Choose a reason for hiding this comment

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

@susanev yes sure sounds good, for now resolved conflict please have a look thanks


it('should create', () => {
expect(component).toBeTruthy();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some tests. The functionality of the underlying component is simple, yes, but should still be tested. You should be able to adapt existing tests for other components that do very similar things.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tests; thank you!

@sachin-msys sachin-msys force-pushed the Sachin/automate-infra-proxy-server-ui branch from 610144c to ac8f117 Compare January 14, 2020 21:21
@sachin-msys sachin-msys changed the title Scahin/automate infra proxy server ui Sachin/automate infra proxy server ui Jan 14, 2020
@jonong1972
Copy link

I updated the description with a link to the Cookbooks section. We can discuss in next meeting of the small things.

@sachin-msys sachin-msys force-pushed the Sachin/automate-infra-proxy-server-ui branch 2 times, most recently from 1263cf3 to 1a265a5 Compare January 23, 2020 11:22
@vjeffrey
Copy link

yesterday we discussed trying to get this pr merged asap to get some bits merged and try to move towards a more iterative approach.
it looks like there's a conflicting file blocking this.
if there are more unanswered questions/feedback, we can create issues to address those next to support moving forward.
please let me know if you need anything from me to get that done!

@sachin-msys sachin-msys force-pushed the Sachin/automate-infra-proxy-server-ui branch from 1a265a5 to 202f229 Compare January 29, 2020 18:54
Copy link
Contributor

@SEAjamieD SEAjamieD left a comment

Choose a reason for hiding this comment

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

Still going through but pushing this through now so you can get started - have a few changes that will be needed because of more recent UI changes specifically related to chef-control-menu.

Comment on lines 50 to 52
<chef-control-menu>
<chef-option data-cy="delete" (click)="startServerDelete(server)">Remove Chef Server</chef-option>
</chef-control-menu>
Copy link
Contributor

Choose a reason for hiding this comment

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

We are no longer using chef-control-menu. It has been replaced with Angular Material.

suggest using:

<mat-select panelClass="chef-control-menu">
    <mat-option data-cy="delete" (onSelectionChange)="startServerDelete($event, server)">Remove Chef Server</mat-option>
</mat-select>

You'll also need to pass in the event, so that in chef-servers-list.component.ts you can add a gate for isUserInput

you can find an example of that here: https://github.com/chef/automate/pull/2283/files in project-list.component.ts.

Happy to explain more if necessary. Here is an example of it in use: #2283 (comment)

Comment on lines 1 to 5
chef-table-new {
.three-dot-column {
text-align: right;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is now global, so it can be deleted from this file all together 😄

Comment on lines 123 to 126
public startServerDelete(server: Server): void {
this.serverToDelete = server;
this.deleteModalVisible = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

related to my comment above, since we are now using mat-select instead of chef-control-menu, we need to put a guard in place or we'll get two event fires. Suggest changing this function to look like this:

  public startServerDelete($event: ChefKeyboardEvent, server: Server): void {
    if ($event.isUserInput) {
      this.serverToDelete = server;
      this.deleteModalVisible = true;
    }
  }

The reason for this is that when using mat-select, if fires off two events, one for a selection and one for a deselection. $event.isUserInput = true is the user selected event.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SEAjamieD Thanks for the review. I have incorporated all suggested changes please have a look

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the changes - they look great 👍

@susanev susanev requested review from SEAjamieD and msorens January 30, 2020 19:15
Copy link
Contributor

@SEAjamieD SEAjamieD left a comment

Choose a reason for hiding this comment

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

The changes I requested look good 🎉

@susanev susanev requested review from jonong1972 and removed request for jonong1972 January 30, 2020 19:19
Copy link
Contributor

@msorens msorens left a comment

Choose a reason for hiding this comment

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

Looking good!
The one thing I noticed is that there was a decision to remove validation on URLs but that validation is still present. I am approving anyway; leave the call on that change for @susanev since she had the last word there.

For future work: it would be really, really helpful if you provide instructions on how to exercise this code. Not just what to rebuild, but precise steps on what to do after logging in on the browser. I would have liked to run this code but was unable to, not being familiar with it.


it('should create', () => {
expect(component).toBeTruthy();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tests; thank you!

templateUrl: './create-chef-server-modal.component.html',
styleUrls: ['./create-chef-server-modal.component.scss']
})
export class CreateChefServerModalComponent implements OnInit {
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment for future work--not for now:

This code follows our existing patterns fine. But we recently introduced a new, cleaner pattern that I would like you and your team to be aware of for modals--see #2704. It encapsulates the code for the modal in a much cleaner way.

Again, no need to apply to this PR; sounds like we want to get this merged ASAP. But please take a look in case of future modals.

@susanev susanev merged commit f414394 into master Jan 30, 2020
@chef-expeditor chef-expeditor bot deleted the Sachin/automate-infra-proxy-server-ui branch January 30, 2020 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants