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

Deleting chef server message modal window #3478

Merged
merged 4 commits into from
Apr 29, 2020

Conversation

sachin-msys
Copy link
Contributor

🔩 Description: What code changed, and why?

User should NOT be allowed to delete a chef server if it has orgs, so added message window for the same.

⛓️ Related Resources

#3294

👍 Definition of Done

  • Added message window on delete a chef server if it has and organisation attached to it

👟 How to Build and Test the Change

  1. git fetch origin Sachin/infra-cookbook-details
  2. build components/automate-ui
  3. Go to Chef Servers option which is under Infrastructure tab and its under Chef-Server feature flag.
  4. Add chef server and one organisation under it.
  5. Add one more just chef server with no organisation.
  6. Now try to delete both chef server one by one you will able to see the delete and message window as shown in attached screen shots

✅ Checklist

📷 Screenshots, if applicable

server-with-org
server-without-org

@sachin-msys sachin-msys self-assigned this Apr 23, 2020
@sachin-msys sachin-msys linked an issue Apr 23, 2020 that may be closed by this pull request
@sachin-msys sachin-msys requested a review from a team April 27, 2020 21:24
<app-message-modal [title]="'Could Not Delete Server'" [visible]="messageModalVisible"
(close)="closeMessageModal()">
Before you can delete this server, delete all orgnisations attached to this server.
</app-message-modal>
<div class="page-body">
Copy link
Contributor

@scottopherson scottopherson Apr 27, 2020

Choose a reason for hiding this comment

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

@chef/ui-team is there consensus on listing many attributes/prop bindings on their own line or only wrapping them at a certain line length?

<app-create-chef-server-modal                                                                 |
  [visible]="createModalVisible"                                                              |
  [creating]="creatingChefServer"                                                             |
  (close)="closeCreateModal()"                                                                |
   ...etc...>                                                                                 |
</app-create-chef-server-modal>                                                               |

vs

<app-create-chef-server-modal [visible]="createModalVisible" [creating]="creatingChefServer"  |
   (close)="closeCreateModal()" ...etc...>                                                    |
</app-create-chef-server-modal>                                                               |

I've usually preferred to keep longer lists of attributes/prop bindings on their own line but don't mind either really. By default vscode wraps them by line length whenever you copy/paste html blocks

Copy link
Contributor

Choose a reason for hiding this comment

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

I used to be indifferent, but lately I am leaning towards one-per-line; it greatly improves readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed as one-per-line 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@msorens yea same. Better readability in file and in git diffs. Thx @sachin-msys 👍

@sachin-msys sachin-msys force-pushed the Sachin/chef-server-deleting-confirmation-modal branch from 79b1c8b to f58ef18 Compare April 27, 2020 22:40
Copy link
Contributor

@tarablack01 tarablack01 left a comment

Choose a reason for hiding this comment

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

Nice and simple 👍🏻

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; just a few corrections noted then OK to merge.

[title]="'Could Not Delete Server'"
[visible]="messageModalVisible"
(close)="closeMessageModal()">
Before you can delete this server, delete all orgnisations attached to this server.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Before you can delete this server, delete all orgnisations attached to this server.
Before you can delete this server, delete all organizations attached to it.

Comment on lines 228 to 231
component.startServerDelete(mockChefKeyEvent, genServer('uuid-111', 0));
expect(component.deleteModalVisible).toBe(true);
component.deleteServer();
expect(component.deleteModalVisible).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct indents.

const mockChefKeyEvent = new KeyboardEvent('keypress') as ChefKeyboardEvent;
mockChefKeyEvent.isUserInput = true;

it('upon selecting delete from control menu, opens with org count 0', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

My first impression was the test and body do not match. But after reviewing all the code I realized that it is a language ambiguity. 😁
Please change:

Suggested change
it('upon selecting delete from control menu, opens with org count 0', () => {
it('With no orgs, selecting delete from control menu opens the delete modal', () => {

mockChefKeyEvent.isUserInput = true;


it('upon selecting delete from control menu, opens with org count 1', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('upon selecting delete from control menu, opens with org count 1', () => {
it('With one org, selecting delete from control menu opens the message modal', () => {

Also, please add one more test:
'With multiple orgs, selecting delete from control menu opens the message modal'

@@ -208,5 +213,56 @@ describe('ChefServersListComponent', () => {

});
});

describe('delete modal', () => {
const mockChefKeyEvent = new KeyboardEvent('keypress') as ChefKeyboardEvent;
Copy link
Contributor

@msorens msorens Apr 28, 2020

Choose a reason for hiding this comment

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

I recently noticed this is the wrong usage and have started a PR (#3518) that will be fixing those that already exist. The problem is we should be using MatOptionSelectionChange rather than ChefKeyboardEvent. You can see the errors when we tighten up linting by changing strictOutputEventTypes to true in tsconfig.json, then running ng build.
So please change to this here and if you use it elsewhere:

Suggested change
const mockChefKeyEvent = new KeyboardEvent('keypress') as ChefKeyboardEvent;
const mockEvent = { isUserInput: true } as MatOptionSelectionChange;

@sachin-msys
Copy link
Contributor Author

@msorens done with all suggestions please have look.

@susanev susanev merged commit 3040814 into master Apr 29, 2020
@chef-expeditor chef-expeditor bot deleted the Sachin/chef-server-deleting-confirmation-modal branch April 29, 2020 15:05
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.

Problem deleting chef server with attached orgs
5 participants