-
Notifications
You must be signed in to change notification settings - Fork 114
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
Conversation
e44e766
to
f37785b
Compare
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.
Looking good; some comments noted below.
components/automate-ui/src/app/entities/servers/server.effects.ts
Outdated
Show resolved
Hide resolved
components/automate-ui/src/app/entities/servers/server.reducer.ts
Outdated
Show resolved
Hide resolved
...nts/automate-ui/src/app/modules/infra-proxy/chef-servers-list/chef-servers-list.component.ts
Show resolved
Hide resolved
// 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]?)$' |
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.
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. 😁
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.
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.
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 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.
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 found that we use this in a couple spots in the code base:
automate/components/automate-ui/src/app/pages/notification-form/notification-form.component.html
Line 97 in f8ca770
pattern="https?://[^.]+\..+" |
automate/components/automate-ui/src/app/pages/data-feed-form/data-feed-form.component.html
Line 37 in f8ca770
pattern="https?://[^.]+\..+" |
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?
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.
@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 ?
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 want to get some product or UX guidance on this question--I will try to speak to @jonong1972 about this tomorrow.
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.
@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.
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.
@susanev yes sure sounds good, for now resolved conflict please have a look thanks
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); |
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.
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.
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.
Nice tests; thank you!
610144c
to
ac8f117
Compare
I updated the description with a link to the Cookbooks section. We can discuss in next meeting of the small things. |
1263cf3
to
1a265a5
Compare
yesterday we discussed trying to get this pr merged asap to get some bits merged and try to move towards a more iterative approach. |
Signed-off-by: Sachin Bachhav <[email protected]>
Signed-off-by: Sachin Bachhav <[email protected]>
Signed-off-by: Sachin Bachhav <[email protected]>
Signed-off-by: Sachin Bachhav <[email protected]>
Signed-off-by: Sachin Bachhav <[email protected]>
1a265a5
to
202f229
Compare
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.
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.
<chef-control-menu> | ||
<chef-option data-cy="delete" (click)="startServerDelete(server)">Remove Chef Server</chef-option> | ||
</chef-control-menu> |
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.
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)
chef-table-new { | ||
.three-dot-column { | ||
text-align: right; | ||
} | ||
} |
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.
This is now global, so it can be deleted from this file all together 😄
public startServerDelete(server: Server): void { | ||
this.serverToDelete = server; | ||
this.deleteModalVisible = true; | ||
} |
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.
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.
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.
@SEAjamieD Thanks for the review. I have incorporated all suggested changes please have a look
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.
Thanks for the changes - they look great 👍
Signed-off-by: Sachin Bachhav <[email protected]>
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.
The changes I requested look good 🎉
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.
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(); | ||
}); |
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.
Nice tests; thank you!
templateUrl: './create-chef-server-modal.component.html', | ||
styleUrls: ['./create-chef-server-modal.component.scss'] | ||
}) | ||
export class CreateChefServerModalComponent implements OnInit { |
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.
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.
🔩 Description: What code changed, and why?
Code changes for introduction of
infra proxy module
inautomate-ui
In order to make a single source of truth for chef infra servers data hereIn this PR following points we have covered:
infra-proxy
module in automate-ui to keep allinfra-proxy
related component separateinfra proxy
UI flows and usedInfra-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
👟 How to Build
NOTE: This PR is dependent on PR #2173 so build steps are depending on the same for
Infra-proxy-service