Skip to content

Commit

Permalink
Prevent multiple clicks on buttons (#3742)
Browse files Browse the repository at this point in the history
* add directive for throttle clicks

* adjust buttons

* adjust

* add missing license
  • Loading branch information
kgroschoff committed Oct 1, 2021
1 parent 137f2c4 commit fc5fbbe
Show file tree
Hide file tree
Showing 47 changed files with 142 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@

<mat-dialog-actions>
<button mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="form.invalid">
Add Automatic Backup
</button>
Expand Down
3 changes: 2 additions & 1 deletion src/app/backup/list/restore/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
<button mat-icon-button
[attr.id]="'km-delete-restore-' + backup.name"
matTooltip="Delete Automatic Backup"
(click)="delete(backup); $event.stopPropagation()"
kmThrottleClick
(throttleClick)="delete(backup); $event.stopPropagation()"
[disabled]="!canDelete">
<i class="km-icon-delete"></i>
</button>
Expand Down
3 changes: 2 additions & 1 deletion src/app/backup/list/snapshot/add-dialog/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@

<mat-dialog-actions>
<button mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="form.invalid">
Add Snapshot
</button>
Expand Down
3 changes: 2 additions & 1 deletion src/app/backup/list/snapshot/delete-dialog/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

<mat-dialog-actions>
<button mat-flat-button
(click)="delete()">
kmThrottleClick
(throttleClick)="delete()">
<i class="km-icon-mask km-icon-delete"></i>
<span>Delete Snapshot</span>
</button>
Expand Down
3 changes: 2 additions & 1 deletion src/app/backup/list/snapshot/restore-dialog/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@

<mat-dialog-actions>
<button mat-flat-button
(click)="restore()">
kmThrottleClick
(throttleClick)="restore()">
Restore Cluster
</button>
</mat-dialog-actions>
Expand Down
9 changes: 6 additions & 3 deletions src/app/cluster-template/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<button fxLayoutAlign="center center"
mat-flat-button
type="button"
(click)="create()"
kmThrottleClick
(throttleClick)="create()"
[disabled]="!canCreate()">
<i class="km-icon-mask km-icon-add"></i>
<span>Create Cluster Template</span>
Expand Down Expand Up @@ -97,13 +98,15 @@
<ng-container *ngSwitchCase="false">
<button mat-icon-button
matTooltip="Create Cluster from Template"
(click)="createCluster(element)"
kmThrottleClick
(throttleClick)="createCluster(element)"
[disabled]="!canCreateCluster()">
<i class="km-icon-mask km-icon-cluster-from-template"></i>
</button>
<button mat-icon-button
matTooltip="Delete Cluster Template"
(click)="delete(element)"
kmThrottleClick
(throttleClick)="delete(element)"
[disabled]="!canDelete(element)">
<i class="km-icon-mask km-icon-delete"></i>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
(valid)="valid = $event"></km-machine-networks>
</mat-dialog-content>
<mat-dialog-actions>
<button (click)="addMachineNetworks()"
<button kmThrottleClick
(throttleClick)="addMachineNetworks()"
mat-flat-button
[disabled]="!valid">
<i class="km-icon-mask km-icon-add"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
</mat-dialog-content>
<mat-dialog-actions>
<button mat-flat-button
(click)="changeVersion()"
kmThrottleClick
(throttleClick)="changeVersion()"
[disabled]="!selectedVersion">
<i class="km-icon-mask km-icon-check i-24"></i>
<span>Change Version</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
<button id="km-delete-cluster-dialog-delete-btn"
type="submit"
mat-flat-button
kmThrottleClick
(throttleClick)="deleteCluster()"
form="km-delete-cluster-dialog"
[disabled]="!inputNameMatches()">
<i class="km-icon-mask km-icon-delete i-24"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
<mat-dialog-actions>
<button id="km-constraint-dialog-btn"
mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="!form.valid">
<i [ngClass]="getIconClass()"></i>
<span>{{data.confirmLabel}} Constraint</span>
Expand Down
2 changes: 2 additions & 0 deletions src/app/cluster/cluster-details/edit-cluster/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
<button id="km-edit-cluster-dialog-edit-btn"
mat-flat-button
type="submit"
kmThrottleClick
(throttleClick)="editCluster()"
form="edit-cluster-form"
[disabled]="!form.valid || !providerSettingsPatch.isValid">
<i class="km-icon-mask km-icon-save"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<mat-dialog-actions>
<button id="km-gatekeeper-config-dialog-btn"
mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="!isValid()">
<i [ngClass]="getIconClass()"></i>
<span>{{data.confirmLabel}} Gatekeeper Config</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<mat-dialog-actions>
<button id="km-alertmanager-config-dialog-btn"
mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="!isValid()">
<i [ngClass]="getIconClass"></i>
<span>{{data.confirmLabel}} Alertmanager Config</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
<mat-dialog-actions>
<button id="km-rule-group-dialog-btn"
mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="!isValid()">
<i [ngClass]="getIconClass()"></i>
<span>{{data.confirmLabel}} Rule Group</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@
<button id="km-add-binding-dialog-add-btn"
mat-flat-button
type="submit"
kmThrottleClick
(throttleClick)="addBinding()"
form="add-binding-form"
[disabled]="!form.valid">
<i class="km-icon-mask km-icon-add"></i>
Expand Down
3 changes: 2 additions & 1 deletion src/app/cluster/cluster-details/revoke-token/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
</mat-dialog-content>
<mat-dialog-actions>
<button mat-flat-button
(click)="revokeToken()"
kmThrottleClick
(throttleClick)="revokeToken()"
[disabled]="!revokeAdminToken && !revokeViewerToken">
<i class="km-icon-mask km-icon-check i-24"></i>
<span>Revoke Token</span>
Expand Down
3 changes: 2 additions & 1 deletion src/app/cluster/cluster-details/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
fxLayoutAlign="center center"
mat-flat-button
type="button"
(click)="downloadKubeconfig()"
kmThrottleClick
(throttleClick)="downloadKubeconfig()"
[disabled]="!isClusterRunning">
<i class="km-icon-mask km-icon-download"></i>
<span>Download</span>
Expand Down
3 changes: 2 additions & 1 deletion src/app/cluster/external-cluster-details/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
mat-flat-button
color="tertiary"
fxLayoutAlign="center center"
(click)="disconnect()"
kmThrottleClick
(throttleClick)="disconnect()"
[disabled]="!isDisconnectEnabled()">
<i class="km-icon-mask km-icon-disconnect"></i>
<span>Disconnect</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
<mat-dialog-actions>
<button id="km-allowed-registry-dialog-btn"
mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="form.invalid">
<i [ngClass]="getIconClass()"></i>
<span>{{data.confirmLabel}} Allowed Registry</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
class="spinner"></mat-spinner>

<button mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="form.invalid || saving">
<i class="km-icon-mask km-icon-edit"></i>
<span>Configure Metering</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
class="spinner"></mat-spinner>

<button mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="form.invalid || saving">
<i class="km-icon-mask km-icon-edit"></i>
<span>Edit Credentials</span>
Expand Down
3 changes: 2 additions & 1 deletion src/app/dynamic/enterprise/metering/list/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
</ng-container>

<button mat-icon-button
(click)="download(element)"
kmThrottleClick
(throttleClick)="download(element)"
[disabled]="!canDownload(element)">
<i class="km-icon-mask km-icon-download"></i>
</button>
Expand Down
2 changes: 2 additions & 0 deletions src/app/member/add-member/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
<button id="km-add-member-dialog-add-btn"
mat-flat-button
type="submit"
kmThrottleClick
(throttleClick)="addMember()"
form="add-member-form"
[disabled]="!addMemberForm.valid">
<i class="km-icon-mask km-icon-add"></i>
Expand Down
2 changes: 2 additions & 0 deletions src/app/member/edit-member/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<button id="km-edit-member-dialog-edit-btn"
mat-flat-button
type="submit"
kmThrottleClick
(throttleClick)="editMember()"
form="edit-member-form"
[disabled]="!form.valid">
<i class="km-icon-mask km-icon-edit w-24"></i>
Expand Down
2 changes: 2 additions & 0 deletions src/app/project/edit-project/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
<button id="km-edit-project-dialog-edit-btn"
mat-flat-button
type="submit"
kmThrottleClick
(throttleClick)="editProject()"
form="edit-project-form"
[disabled]="!form.valid">
<i class="km-icon-mask km-icon-edit w-24"></i>
Expand Down
2 changes: 2 additions & 0 deletions src/app/serviceaccount/add-serviceaccount/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
<button id="km-add-serviceaccount-dialog-add-btn"
mat-flat-button
type="submit"
kmThrottleClick
(throttleClick)="addServiceAccount()"
form="add-service-account-form"
[disabled]="!addServiceAccountForm.valid">
<i class="km-icon-mask km-icon-add"></i>
Expand Down
2 changes: 2 additions & 0 deletions src/app/serviceaccount/edit-serviceaccount/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
<button id="km-edit-serviceaccount-dialog-edit-btn"
mat-flat-button
type="submit"
kmThrottleClick
(throttleClick)="editServiceAccount()"
form="edit-service-account-form"
[disabled]="!editServiceAccountForm.valid">
<i class="km-icon-mask km-icon-edit w-24"></i>
Expand Down
6 changes: 4 additions & 2 deletions src/app/serviceaccount/token/add/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
id="km-serviceaccount-token-dialog-update-btn"
mat-flat-button
[disabled]="updating || form.invalid"
(click)="update()">
kmThrottleClick
(throttleClick)="update()">
<i [ngClass]="getIconClass()"></i>
<span>{{mode}} Token</span>
</button>
Expand Down Expand Up @@ -86,7 +87,8 @@
*ngIf="updating"></mat-spinner>
<button mat-flat-button
[disabled]="updating || form.invalid"
(click)="update()">
kmThrottleClick
(throttleClick)="update()">
<i [ngClass]="getIconClass()"></i>
<span>{{mode}} Token</span>
</button>
Expand Down
2 changes: 2 additions & 0 deletions src/app/settings/admin/admins/add-admin-dialog/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<mat-dialog-actions>
<button mat-flat-button
type="submit"
kmThrottleClick
(throttleClick)="add()"
form="add-admin-form"
id="km-add-admin-dialog-save-btn"
[disabled]="!form.valid">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
<mat-dialog-actions>
<button mat-flat-button
id="km-edit-bucket-setting-dialog-save-btn"
(click)="edit()"
kmThrottleClick
(throttleClick)="edit()"
[disabled]="!form.valid">
<i class="km-icon-mask km-icon-edit"></i>
<span>Edit Bucket Settings</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<mat-dialog-actions>
<button mat-flat-button
id="km-edit-credentials-dialog-save-btn"
(click)="edit()"
kmThrottleClick
(throttleClick)="edit()"
[disabled]="!form.valid">
<i class="km-icon-mask km-icon-edit"></i>
<span>Edit Credentials</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@
</mat-dialog-content>
<mat-dialog-actions>
<button mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
id="km-add-dc-save-btn"
[disabled]="!form.valid">
<i [ngClass]="getIconClass()"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<mat-dialog-actions>
<button id="km-constraint-template-dialog-btn"
mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="!isValid()">
<i [ngClass]="getIconClass()"></i>
<span>{{data.confirmLabel}} Constraint Template</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
<mat-dialog-actions>
<button id="km-default-constraint-dialog-btn"
mat-flat-button
(click)="save()"
kmThrottleClick
(throttleClick)="save()"
[disabled]="!form.valid">
<i [ngClass]="getIconClass()"></i>
<span>{{data.confirmLabel}} Default Constraint</span>
Expand Down
3 changes: 2 additions & 1 deletion src/app/settings/admin/presets/dialog/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
id="km-settings-preset-create-btn"
[disabled]="creating || invalid"
*ngIf="last"
(click)="save()">
kmThrottleClick
(throttleClick)="save()">
<i class="km-icon-mask km-icon-add"></i>
<span>Create</span>
</button>
Expand Down
3 changes: 2 additions & 1 deletion src/app/settings/admin/presets/edit-dialog/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
</div>

<button mat-icon-button
(click)="save(provider.name, !provider.enabled)"
kmThrottleClick
(throttleClick)="save(provider.name, !provider.enabled)"
class="show-icon"
fxLayoutAlign="center center">
<i [ngClass]="provider.enabled ? 'km-icon-mask km-icon-show' : 'km-icon-mask km-icon-hide'"></i>
Expand Down
2 changes: 2 additions & 0 deletions src/app/shared/components/add-project-dialog/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
<button id="km-add-project-dialog-save"
mat-flat-button
type="submit"
kmThrottleClick
(throttleClick)="addProject()"
form="add-project-form"
[disabled]="!form.valid">
<i class="km-icon-mask km-icon-save"></i>
Expand Down
2 changes: 2 additions & 0 deletions src/app/shared/components/add-ssh-key-dialog/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
<mat-dialog-actions>
<button id="km-add-ssh-key-dialog-save"
type="submit"
kmThrottleClick
(throttleClick)="addSSHKey()"
mat-flat-button
form="add-ssh-key-form"
[disabled]="!addSSHKeyForm.valid">
Expand Down
Loading

0 comments on commit fc5fbbe

Please sign in to comment.