-
Notifications
You must be signed in to change notification settings - Fork 111
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
Conversation
Deploy preview for chef-automate ready! Built with commit 9b9dc15 |
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.
Changes look good to me. Please change the screenshot.
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.
Also, please address the semgrep error reported by Buildkite.
components/automate-ui/src/app/entities/environments/environment.effects.ts
Outdated
Show resolved
Hide resolved
components/automate-ui/src/app/entities/environments/environment.model.ts
Outdated
Show resolved
Hide resolved
...src/app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.html
Outdated
Show resolved
Hide resolved
...src/app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.html
Outdated
Show resolved
Hide resolved
...src/app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.html
Outdated
Show resolved
Hide resolved
.../app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.spec.ts
Outdated
Show resolved
Hide resolved
.../app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.spec.ts
Show resolved
Hide resolved
.../app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.spec.ts
Show resolved
Hide resolved
.../app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.spec.ts
Outdated
Show resolved
Hide resolved
...i/src/app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.ts
Outdated
Show resolved
Hide resolved
fd506a0
to
3a7e6bb
Compare
...src/app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.html
Outdated
Show resolved
Hide resolved
...src/app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.html
Outdated
Show resolved
Hide resolved
...src/app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.scss
Outdated
Show resolved
Hide resolved
|
||
describe('create environment', () => { | ||
let store: Store<NgrxStateAtom>; | ||
const environment = { |
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.
Can we strongly type this constant? That provides a guarantee that all the properties are valid.
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.
Not sure why you marked this resolved; it still has no type.
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.
yes, i have updated the changes
.../app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.spec.ts
Outdated
Show resolved
Hide resolved
version: ['', [Validators.required, Validators.pattern(Regex.patterns.VALID_VERSION)]] | ||
}); | ||
|
||
this.operatorKeys = ['~>', '>=', '>', '=', '<', '<=']; |
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.
Add an in-code comment explaining ~>
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.
added code comments.
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.
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 ~>
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.
Added in-code comment for ~>
: approximately greater than; also known as "pessimistically greater than", or "pessimistic"
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.
Are you looking for this above change?
...p/modules/infra-proxy/infra-environment-constraint/infra-environment-constraint.component.ts
Outdated
Show resolved
Hide resolved
...p/modules/infra-proxy/infra-environment-constraint/infra-environment-constraint.component.ts
Outdated
Show resolved
Hide resolved
); | ||
} | ||
|
||
selected(value, i) { |
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.
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.
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.
working on these changes, will update
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.
Those handle methods are specific to name, operator, version that's why i created separated functions to handle these changes.
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.
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
.
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 have added the functions for each four blocks.
...p/modules/infra-proxy/infra-environment-constraint/infra-environment-constraint.component.ts
Outdated
Show resolved
Hide resolved
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.
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.
Nice catch, @SEAjamieD ! |
@SEAjamieD Yes, I would like to have more guidance on this. |
f87ccb0
to
b7eebcb
Compare
@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. |
...i/src/app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.ts
Outdated
Show resolved
Hide resolved
...i/src/app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.ts
Outdated
Show resolved
Hide resolved
...i/src/app/modules/infra-proxy/create-environment-modal/create-environment-modal.component.ts
Show resolved
Hide resolved
...p/modules/infra-proxy/infra-environment-constraint/infra-environment-constraint.component.ts
Outdated
Show resolved
Hide resolved
version: ['', [Validators.required, Validators.pattern(Regex.patterns.VALID_VERSION)]] | ||
}); | ||
|
||
this.operatorKeys = ['~>', '>=', '>', '=', '<', '<=']; |
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.
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 ~>
...p/modules/infra-proxy/infra-environment-constraint/infra-environment-constraint.component.ts
Outdated
Show resolved
Hide resolved
...p/modules/infra-proxy/infra-environment-constraint/infra-environment-constraint.component.ts
Outdated
Show resolved
Hide resolved
...p/modules/infra-proxy/infra-environment-constraint/infra-environment-constraint.component.ts
Outdated
Show resolved
Hide resolved
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { |
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 a couple real tests, too.
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 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.
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; | ||
} |
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.
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.
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.
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.
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 Could you take a look at this. Should be able to eliminate the duplication. (OK to do this in a follow-up PR.)
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.
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
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. |
b7eebcb
to
c620ee8
Compare
@msorens yes, it get resolved |
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. |
a9267da
to
41ffd65
Compare
@SEAjamieD i have added the changes |
I've approved the UI changes, however I think you should wait for @msorens approval before merging |
@SEAjamieD Sure, will create a new issue regarding this. |
this.operatorKeys = ['~>', // approximately greater than; | ||
// also known as "pessimistically greater than", or "pessimistic" |
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 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.
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; | ||
} |
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 Could you take a look at this. Should be able to eliminate the duplication. (OK to do this in a follow-up PR.)
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 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') { |
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.
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:
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>
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>
da197b7
to
9b9dc15
Compare
While acceptance testing, observed
|
π© 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
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:
FEAT
on-screen and a pop-up will appear you need to toggle theInfra 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
CreateEnvironment.mp4