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

Added Create Environment UI #4803

Merged
merged 17 commits into from
Mar 23, 2021
Merged

Added Create Environment UI #4803

merged 17 commits into from
Mar 23, 2021

Conversation

himanshi-chhabra
Copy link
Contributor

@himanshi-chhabra himanshi-chhabra commented Mar 5, 2021

πŸ”© Description: What code changed, and why?

We need to add UI for Create Environment

⛓️ Related Resources

#4544

πŸ‘ Definition of Done

Added create functionality for Environment in which we can create a particular environment.

πŸ‘Ÿ How to Build and Test the Change

STEP 1
inside the hab studio

[default:/src:0]# build components/automate-ui-devproxy/
[default:/src:0]# start_automate_ui_background
[default:/src:0]# start_all_services

STEP 2
open new window
go to automate UI path

$ cd components/automate-ui
and run the command 

npm run serve:hab

To add data https://github.com/chef/automate/blob/master/dev-docs/adding-data/adding_test_data.md#adding-data-to-infra-views
PFA video for these changes.

Steps:

  1. Go To Infrastructure -> Chef Servers -> click server name-> click on org name -> Environment
  2. To see the create button type FEAT on-screen and a pop-up will appear you need to toggle the Infra server(Remaining) to ON and then refresh the page, will see a create button on the right of the environment tab page.

βœ… Checklist

πŸ“· Screenshots, if applicable

create_update_1
create_update_2
create_en3
create_en4

CreateEnvironment.mp4

@netlify
Copy link

netlify bot commented Mar 5, 2021

Deploy preview for chef-automate ready!

Built with commit 9b9dc15

https://deploy-preview-4803--chef-automate.netlify.app

@vinay033 vinay033 self-requested a review March 5, 2021 20:19
Copy link
Collaborator

@vinay033 vinay033 left a comment

Choose a reason for hiding this comment

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

Changes look good to me. Please change the screenshot.

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.

Also, please address the semgrep error reported by Buildkite.


describe('create environment', () => {
let store: Store<NgrxStateAtom>;
const environment = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we strongly type this constant? That provides a guarantee that all the properties are valid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why you marked this resolved; it still has no type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, i have updated the changes

version: ['', [Validators.required, Validators.pattern(Regex.patterns.VALID_VERSION)]]
});

this.operatorKeys = ['~>', '>=', '>', '=', '<', '<='];
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an in-code comment explaining ~>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added code comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

Again, you did not read my request.
(1) Please delete the comment // operators for Cookbook version; that is self-evident.
(2) Please add an in-code comment explaining ~>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in-code comment for ~> : approximately greater than; also known as "pessimistically greater than", or "pessimistic"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you looking for this above change?

);
}

selected(value, i) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow! What is this method doing?
Suggest each block should be extracted into a named function so this function will look something like:

selectLanguage(...) {
  setLanguageValueFromIndex(...);
  setNameIn???ArraytoValue(...);
  doSomethingSomethingWithConstraints(...);
  etc...
}

And looking further, you can then reuse those sub-functions below in the handle* methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

working on these changes, will update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those handle methods are specific to name, operator, version that's why i created separated functions to handle these changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like all you did was rename selected to handleName, etc., which is not at all what I was asking. Inside handleEditName you have what looks like 4 blocks of code. Each of those 4 blocks should be extracted into a named function so handleEditName will look something like I showed above. And then you can reuse those subfunctions in handleEditOperator and handleEditVersion.

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 have added the functions for each four blocks.

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.

Similar to my comments on #4813 - in the SCSS files there is a lot of fixed widths and heights being used, which is ultimately causing certain elements to remain stiff in the view. These views should all be made pretty flexible.

If you'd like more specific guidance on this, I'm happy to go more in depth, or review in a pair session.

@msorens
Copy link
Contributor

msorens commented Mar 16, 2021

Nice catch, @SEAjamieD !

@himanshi-chhabra
Copy link
Contributor Author

Similar to my comments on #4813 - in the SCSS files there is a lot of fixed widths and heights being used, which is ultimately causing certain elements to remain stiff in the view. These views should all be made pretty flexible.

If you'd like more specific guidance on this, I'm happy to go more in depth, or review in a pair session.

@SEAjamieD Yes, I would like to have more guidance on this.

@himanshi-chhabra
Copy link
Contributor Author

himanshi-chhabra commented Mar 19, 2021

Similar to my comments on #4813 - in the SCSS files there is a lot of fixed widths and heights being used, which is ultimately causing certain elements to remain stiff in the view. These views should all be made pretty flexible.

If you'd like more specific guidance on this, I'm happy to go more in depth, or review in a pair session.

@SEAjamieD Hi Jamie, regarding this I have added the fixed-width of the modal in create Environment as we discussed and also added the visual indicator of which button is in focus.

version: ['', [Validators.required, Validators.pattern(Regex.patterns.VALID_VERSION)]]
});

this.operatorKeys = ['~>', '>=', '>', '=', '<', '<='];
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, you did not read my request.
(1) Please delete the comment // operators for Cookbook version; that is self-evident.
(2) Please add an in-code comment explaining ~>

fixture.detectChanges();
});

it('should create', () => {
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 a couple real tests, too.

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 have removed this file as it will not specify any to run test case as I already added a test case regarding tabs in Create spec file.

Comment on lines +1 to +16
import { Component, Input } from '@angular/core';

@Component({
selector: 'app-infra-tab',
template: `
<div [hidden]="!active" class="test">
<ng-content></ng-content>
</div>
`
})
// TODO:eng-ex The active tab should be tracked in the parent and not the individual tab
export class InfraTabComponent {
@Input() tabTitle: string;
@Input() active = false;
@Input() disabled = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of making an almost exact duplicate of an existing component, please reuse the existing one (TabComponent) -- which means add the disabled property that you seem to need.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree with you I have already tried to use the TabComponent file but it's using class="pane" in HTML and if I try to override the CSS of that class it will override at everyplace. that's the reason I have added this file.

Copy link
Contributor

Choose a reason for hiding this comment

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

@SEAjamieD Could you take a look at this. Should be able to eliminate the duplication. (OK to do this in a follow-up PR.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we definitely shouldn't be making new components that are this similar. Worst case lets extend the component we already have.

I've created a new issue to manage this situation here: #4866

@msorens
Copy link
Contributor

msorens commented Mar 22, 2021

Please also (a) get your unit tests passing in buildkite, and (b) talk to the releng team about getting your PR unblocked in the verify-private pipeline--that seems to be happening every time and you need to get it fixed.

@himanshi-chhabra
Copy link
Contributor Author

Please also (a) get your unit tests passing in buildkite, and (b) talk to the releng team about getting your PR unblocked in the verify-private pipeline--that seems to be happening every time and you need to get it fixed.

@msorens yes, it get resolved

@SEAjamieD
Copy link
Contributor

Screen Shot 2021-03-22 at 11 09 16 AM

The biggest concern in this PR right now is that none of the buttons above are keyboard accessible. We should always be making sure that anything our users can do with a mouse, can also be done via keyboard.

@SEAjamieD
Copy link
Contributor

Similar to my comments on #4813 - in the SCSS files there is a lot of fixed widths and heights being used, which is ultimately causing certain elements to remain stiff in the view. These views should all be made pretty flexible.
If you'd like more specific guidance on this, I'm happy to go more in depth, or review in a pair session.

@SEAjamieD Hi Jamie, regarding this I have added the fixed-width of the modal in create Environment as we discussed and also added the visual indicator of which button is in focus.

This will work for now. We should pair program sometime in the near future and I can be more explicit about what flexible means and how we should strive for flexibility. I will sync up with UX on the new designs and we can come up with a look for the Modals at small and large screen sizes, and then we can drop the new styles into all of the newly designed modals.

@himanshi-chhabra
Copy link
Contributor Author

Screen Shot 2021-03-22 at 11 09 16 AM

The biggest concern in this PR right now is that none of the buttons above are keyboard accessible. We should always be making sure that anything our users can do with a mouse, can also be done via keyboard.

@SEAjamieD i have added the changes

@SEAjamieD
Copy link
Contributor

I've approved the UI changes, however I think you should wait for @msorens approval before merging

@himanshi-chhabra
Copy link
Contributor Author

Similar to my comments on #4813 - in the SCSS files there is a lot of fixed widths and heights being used, which is ultimately causing certain elements to remain stiff in the view. These views should all be made pretty flexible.
If you'd like more specific guidance on this, I'm happy to go more in depth, or review in a pair session.

@SEAjamieD Hi Jamie, regarding this I have added the fixed-width of the modal in create Environment as we discussed and also added the visual indicator of which button is in focus.

This will work for now. We should pair program sometime in the near future and I can be more explicit about what flexible means and how we should strive for flexibility. I will sync up with UX on the new designs and we can come up with a look for the Modals at small and large screen sizes, and then we can drop the new styles into all of the newly designed modals.

@SEAjamieD Sure, will create a new issue regarding this.

Comment on lines 36 to 37
this.operatorKeys = ['~>', // approximately greater than;
// also known as "pessimistically greater than", or "pessimistic"
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize you copied this from the docs, but it is still a mystery.
Your job is to explain your code to the reader. What does it mean? This comment is inadequate.

Also, would suggest to rename the variable to operators instead of operatorKeys, to be less confusing.

Comment on lines +1 to +16
import { Component, Input } from '@angular/core';

@Component({
selector: 'app-infra-tab',
template: `
<div [hidden]="!active" class="test">
<ng-content></ng-content>
</div>
`
})
// TODO:eng-ex The active tab should be tracked in the parent and not the individual tab
export class InfraTabComponent {
@Input() tabTitle: string;
@Input() active = false;
@Input() disabled = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@SEAjamieD Could you take a look at this. Should be able to eliminate the duplication. (OK to do this in a follow-up PR.)

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 much better. I would like to urge that this PR be examined for missing unit tests; I point out one file below but there may be others. I would normally use "request changes" because of the lack of tests, but because of deadlines, I am approving on the condition that you will add some unit tests before you merge. 😁

this.selectedCookbookNames.forEach((element, index) => {
if (index === cookbookIndex) {
previousName = element;
if (newName && newName !== 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really looking for the string "undefined" ?? Or are you trying to check if newName is undefined? If the latter, that will not work. The non-value undefined is falsy, so all you need is this:

Suggested change
if (newName && newName !== 'undefined') {
if (newName) {

Note that if this was unit-tested, I would not have to ask the question. 😁
And I am just noticing that this file does not have any unit tests; there is a lot going on here and it definitely needs tests.

Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
vinay033 and others added 16 commits March 23, 2021 15:42
Signed-off-by: vinay sharma <vsharma@chef.io>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
Signed-off-by: Himanshi Chhabra <himanshi.chhabra@msystechnologies.com>
@kalroy kalroy merged commit 20d2f27 into master Mar 23, 2021
@kalroy kalroy deleted the Himanshi/create_Environment_UI branch March 23, 2021 11:26
@himanshi-chhabra
Copy link
Contributor Author

While acceptance testing, observed

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.

None yet

5 participants