From f2096e9378b84ba437b15a5537c2ead73c38f0eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stephan=20M=C3=BCller?= Date: Mon, 16 Apr 2018 10:57:31 +0200 Subject: [PATCH] mgr/dashboard: Changes deletion button to link MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This change was made because a link can be placed anywhere instead of a button element. Signed-off-by: Stephan Müller --- .../shared/components/components.module.ts | 6 ++-- .../deletion-link.component.html} | 6 ++-- .../deletion-link.component.scss} | 0 .../deletion-link.component.spec.ts} | 32 +++++++++---------- .../deletion-link.component.ts} | 9 +++--- 5 files changed, 25 insertions(+), 28 deletions(-) rename src/pybind/mgr/dashboard/frontend/src/app/shared/components/{deletion-button/deletion-button.component.html => deletion-link/deletion-link.component.html} (96%) rename src/pybind/mgr/dashboard/frontend/src/app/shared/components/{deletion-button/deletion-button.component.scss => deletion-link/deletion-link.component.scss} (100%) rename src/pybind/mgr/dashboard/frontend/src/app/shared/components/{deletion-button/deletion-button.component.spec.ts => deletion-link/deletion-link.component.spec.ts} (88%) rename src/pybind/mgr/dashboard/frontend/src/app/shared/components/{deletion-button/deletion-button.component.ts => deletion-link/deletion-link.component.ts} (89%) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts index c716d9a5befbf..cc3dd5bbfebe3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts @@ -9,7 +9,7 @@ import { PipesModule } from '../pipes/pipes.module'; import { DeleteConfirmationComponent } from './delete-confirmation-modal/delete-confirmation-modal.component'; -import { DeletionButtonComponent } from './deletion-button/deletion-button.component'; +import { DeletionLinkComponent } from './deletion-link/deletion-link.component'; import { HelperComponent } from './helper/helper.component'; import { ModalComponent } from './modal/modal.component'; import { SparklineComponent } from './sparkline/sparkline.component'; @@ -38,7 +38,7 @@ import { ViewCacheComponent } from './view-cache/view-cache.component'; UsageBarComponent, DeleteConfirmationComponent, ModalComponent, - DeletionButtonComponent + DeletionLinkComponent ], providers: [], exports: [ @@ -52,7 +52,7 @@ import { ViewCacheComponent } from './view-cache/view-cache.component'; entryComponents: [ DeleteConfirmationComponent, ModalComponent, - DeletionButtonComponent + DeletionLinkComponent ] }) export class ComponentsModule { } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-button/deletion-button.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-link/deletion-link.component.html similarity index 96% rename from src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-button/deletion-button.component.html rename to src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-link/deletion-link.component.html index 8744e4b345c7d..9910fe9d7b3c6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-button/deletion-button.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-link/deletion-link.component.html @@ -1,9 +1,7 @@ - + + The spinner is handled by the controller if you have use the modal as ViewChild in order to use it's functions to stop the spinner or close the dialog. - - + + The spinner is handled by the modal if your given deletion function returns a Observable. - + ` }) class MockComponent { - @ViewChild('ctrlDeleteButton') ctrlDeleteButton: DeletionButtonComponent; - @ViewChild('modalDeleteButton') modalDeleteButton: DeletionButtonComponent; + @ViewChild('ctrlDeleteButton') ctrlDeleteButton: DeletionLinkComponent; + @ViewChild('modalDeleteButton') modalDeleteButton: DeletionLinkComponent; someData = [1, 2, 3, 4, 5]; finished: number[]; @@ -56,14 +56,14 @@ class MockComponent { } } -describe('DeletionButtonComponent', () => { +describe('DeletionLinkComponent', () => { let mockComponent: MockComponent; - let component: DeletionButtonComponent; + let component: DeletionLinkComponent; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ MockComponent, DeletionButtonComponent, ModalComponent, + declarations: [ MockComponent, DeletionLinkComponent, ModalComponent, SubmitButtonComponent], imports: [ModalModule.forRoot(), ReactiveFormsModule], }) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-button/deletion-button.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-link/deletion-link.component.ts similarity index 89% rename from src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-button/deletion-button.component.ts rename to src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-link/deletion-link.component.ts index 407e411e92d7f..cd79da24fc0d4 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-button/deletion-button.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-link/deletion-link.component.ts @@ -9,15 +9,14 @@ import { Observable } from 'rxjs/Observable'; import { SubmitButtonComponent } from '../submit-button/submit-button.component'; @Component({ - selector: 'cd-deletion-button', - templateUrl: './deletion-button.component.html', - styleUrls: ['./deletion-button.component.scss'] + selector: 'cd-deletion-link', + templateUrl: './deletion-link.component.html', + styleUrls: ['./deletion-link.component.scss'] }) -export class DeletionButtonComponent implements OnInit { +export class DeletionLinkComponent implements OnInit { @ViewChild(SubmitButtonComponent) submitButton: SubmitButtonComponent; @Input() metaType: string; @Input() pattern = 'yes'; - @Input() btnClasses = 'btn btn-sm btn-primary'; @Input() deletionObserver: () => Observable; @Output() toggleDeletion = new EventEmitter(); bsModalRef: BsModalRef; -- 2.39.5