Skip to content

Commit

Permalink
unify inputs requiring buttons like password inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelk committed Dec 4, 2020
1 parent aa5ee50 commit f8b530e
Show file tree
Hide file tree
Showing 26 changed files with 177 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@
</ng-container>
</ng-template>
</my-help>
<input
type="password" id="password" autocomplete="new-password" class="form-control"
formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }"
>
<my-input-toggle-hidden formControlName="password" id="password"
[ngClass]="{ 'input-error': formErrors['password'] }"
autocomplete="new-password"></my-input-toggle-hidden>
<div *ngIf="formErrors.password" class="form-error">
{{ formErrors.password }}
</div>
Expand Down
8 changes: 4 additions & 4 deletions client/src/app/+login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ <h6 class="alert-heading" i18n>
<div class="form-group">
<label i18n for="password">Password</label>
<div>
<input
type="password" name="password" id="password" i18n-placeholder placeholder="Password" required tabindex="2" autocomplete="current-password"
formControlName="password" class="form-control" [ngClass]="{ 'input-error': formErrors['password'] }"
>
<my-input-toggle-hidden formControlName="password" id="password"
i18n-placeholder placeholder="Password"
[ngClass]="{ 'input-error': formErrors['password'] }"
autocomplete="current-password"></my-input-toggle-hidden>
<a i18n-title class="forgot-password-button" (click)="openForgotPasswordModal()" title="Click here to reset your password">I forgot my password</a>
</div>
<div *ngIf="formErrors.password" class="form-error">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ <h1>
<h2 i18n class="applications-title">SUBSCRIPTION FEED</h2>
<div i18n class="applications-description">
Use third-party feed aggregators to retrieve the list of videos from
channels you subscribed to. Make sure to keep your token private.
channels you subscribed to.
</div>
</div>

<div class="form-group col-12 col-lg-8 col-xl-9">

<div class="form-group">
<label i18n for="feed-url">Feed URL</label>
<my-input-readonly-copy [value]="feedUrl"></my-input-readonly-copy>
<my-input-toggle-hidden [value]="feedUrl" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>
</div>

<div class="form-group">
<label i18n for="feed-token">Feed Token</label>
<my-input-readonly-copy [value]="feedToken"></my-input-readonly-copy>
<my-input-toggle-hidden [value]="feedToken" [withCopy]="true" [readonly]="true"></my-input-toggle-hidden>

<div class="form-group-description" i18n>⚠️ Never share your feed token with anyone.</div>
</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
<form role="form" class="change-email" (ngSubmit)="changeEmail()" [formGroup]="form" *ngIf="user.pluginAuth === null">

<div class="form-group">
<label i18n for="new-email">New email</label>
<input
type="email" id="new-email" i18n-placeholder placeholder="Your new email" class="form-control"
type="email" id="new-email" i18n-placeholder placeholder="New email" class="form-control"
formControlName="new-email" [ngClass]="{ 'input-error': formErrors['new-email'] }"
>
<div *ngIf="formErrors['new-email']" class="form-error">
Expand All @@ -23,11 +22,11 @@
</div>

<div class="form-group">
<label i18n for="new-email">Your current password</label>
<input
type="password" id="password" i18n-placeholder placeholder="Your password" autocomplete="off"
formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }" class="form-control"
>
<my-input-toggle-hidden formControlName="password"
id="password"
i18n-placeholder placeholder="Current password"
[ngClass]="{ 'input-error': formErrors['password'] }"
autocomplete="current-password"></my-input-toggle-hidden>
<div *ngIf="formErrors['password']" class="form-error">
{{ formErrors['password'] }}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ label {
font-size: 100%;
}

input[type=password],
my-input-toggle-hidden {
width: 340px;
display: block;
}

input[type=email] {
@include peertube-input-text(340px);

Expand All @@ -20,10 +24,13 @@ input[type=submit] {

.current-email,
.pending-email {
font-size: 16px;
margin-bottom: 15px;

.email {
font-weight: $font-semibold;
}
}

.form-group {
width: max-content;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@
<form role="form" (ngSubmit)="changePassword()" [formGroup]="form">

<label i18n for="current-password">Change password</label>
<input
type="password" id="current-password" i18n-placeholder placeholder="Current password" autocomplete="current-password"
formControlName="current-password" [ngClass]="{ 'input-error': formErrors['current-password'] }" class="form-control"
>
<my-input-toggle-hidden formControlName="current-password"
id="current-password"
i18n-placeholder placeholder="Current password"
[ngClass]="{ 'input-error': formErrors['current-password'] }"
autocomplete="current-password"></my-input-toggle-hidden>
<div *ngIf="formErrors['current-password']" class="form-error">
{{ formErrors['current-password'] }}
</div>

<input
type="password" id="new-password" i18n-placeholder placeholder="New password" autocomplete="new-password"
formControlName="new-password" [ngClass]="{ 'input-error': formErrors['new-password'] }" class="form-control"
>
<my-input-toggle-hidden formControlName="new-password"
id="new-password"
i18n-placeholder placeholder="New password"
[ngClass]="{ 'input-error': formErrors['new-password'] }"
autocomplete="new-password"></my-input-toggle-hidden>
<div *ngIf="formErrors['new-password']" class="form-error">
{{ formErrors['new-password'] }}
</div>

<input
type="password" id="new-confirmed-password" i18n-placeholder placeholder="Confirm new password" autocomplete="new-password"
formControlName="new-confirmed-password" class="form-control"
>
<my-input-toggle-hidden formControlName="new-confirmed-password"
id="new-confirmed-password"
i18n-placeholder placeholder="Confirm new password"
[ngClass]="{ 'input-error': formErrors['new-confirmed-password'] }"
autocomplete="new-password"></my-input-toggle-hidden>
<div *ngIf="formErrors['new-confirmed-password']" class="form-error">
{{ formErrors['new-confirmed-password'] }}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ label {
font-size: 100%;
}

input[type=password] {
@include peertube-input-text(340px);
my-input-toggle-hidden {
width: 340px;
display: block;
}

&#new-password,
&#new-confirmed-password {
margin-top: 15px;
}
#new-password,
#new-confirmed-password {
margin-top: 15px;
}

input[type=submit] {
Expand All @@ -22,4 +22,3 @@ input[type=submit] {

margin-top: 15px;
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { filter } from 'rxjs/operators'
import { Component, OnInit } from '@angular/core'
import { AuthService, Notifier, UserService } from '@app/core'
import { USER_CONFIRM_PASSWORD_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { USER_CONFIRM_PASSWORD_VALIDATOR, USER_PASSWORD_VALIDATOR, USER_EXISTING_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { User } from '@shared/models'

Expand All @@ -25,7 +25,7 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On

ngOnInit () {
this.buildForm({
'current-password': USER_PASSWORD_VALIDATOR,
'current-password': USER_EXISTING_PASSWORD_VALIDATOR,
'new-password': USER_PASSWORD_VALIDATOR,
'new-confirmed-password': USER_CONFIRM_PASSWORD_VALIDATOR
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
@import '_mixins';

.delete-me {
font-size: 15px;

button {
@include peertube-button;
@include danger-button;
Expand Down
16 changes: 8 additions & 8 deletions client/src/app/+reset-password/reset-password.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
<form role="form" (ngSubmit)="resetPassword()" [formGroup]="form">
<div class="form-group">
<label i18n for="password">Password</label>
<input
type="password" name="password" id="password" i18n-placeholder placeholder="Password" required autocomplete="new-password"
formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }"
>
<my-input-toggle-hidden formControlName="password" id="password"
i18n-placeholder placeholder="Password"
[ngClass]="{ 'input-error': formErrors['password'] }"
autocomplete="new-password"></my-input-toggle-hidden>
<div *ngIf="formErrors.password" class="form-error">
{{ formErrors.password }}
</div>
</div>

<div class="form-group">
<label i18n for="password-confirm">Confirm password</label>
<input
type="password" name="password-confirm" id="password-confirm" i18n-placeholder placeholder="Confirmed password" required autocomplete="new-password"
formControlName="password-confirm" [ngClass]="{ 'input-error': formErrors['password-confirm'] }"
>
<my-input-toggle-hidden formControlName="password-confirm" id="password-confirm"
i18n-placeholder placeholder="Confirmed password"
[ngClass]="{ 'input-error': formErrors['password-confirm'] }"
autocomplete="new-password"></my-input-toggle-hidden>
<div *ngIf="formErrors['password-confirm']" class="form-error">
{{ formErrors['password-confirm'] }}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@

<div class="form-group">
<label for="password" i18n>Password</label>
<input
type="password" id="password" i18n-placeholder placeholder="Password" autocomplete="new-password"
formControlName="password" class="form-control" [ngClass]="{ 'input-error': formErrors['password'] }"
>
<my-input-toggle-hidden formControlName="password" id="password"
i18n-placeholder placeholder="Password"
[ngClass]="{ 'input-error': formErrors['password'] }"
autocomplete="new-password"></my-input-toggle-hidden>
<div *ngIf="formErrors.password" class="form-error">
{{ formErrors.password }}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@

<div class="form-group">
<label for="liveVideoRTMPUrl" i18n>Live RTMP Url</label>
<my-input-readonly-copy id="liveVideoRTMPUrl" [value]="liveVideo.rtmpUrl"></my-input-readonly-copy>
<my-input-toggle-hidden id="liveVideoRTMPUrl" [value]="liveVideo.rtmpUrl" [withToggle]="false" [withCopy]="true" [show]="true" [readonly]="true"></my-input-toggle-hidden>
</div>

<div class="form-group">
<label for="liveVideoStreamKey" i18n>Live stream key</label>
<my-input-readonly-copy id="liveVideoStreamKey" [value]="liveVideo.streamKey"></my-input-readonly-copy>
<my-input-toggle-hidden id="liveVideoStreamKey" [value]="liveVideo.streamKey" [withCopy]="true" [readonly]="true"></my-input-toggle-hidden>

<div class="form-group-description" i18n>⚠️ Never share your stream key with anyone.</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions client/src/app/shared/form-validators/user-validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export const USER_EMAIL_VALIDATOR: BuildFormValidator = {
}
}

export const USER_EXISTING_PASSWORD_VALIDATOR: BuildFormValidator = {
VALIDATORS: [
Validators.required
],
MESSAGES: {
'required': $localize`Password is required.`
}
}

export const USER_PASSWORD_VALIDATOR: BuildFormValidator = {
VALIDATORS: [
Validators.required,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<input *ngIf="setting.type === 'input'" type="text" [id]="setting.name" [formControlName]="setting.name" />

<input *ngIf="setting.type === 'input-password'" type="password" [id]="setting.name" [formControlName]="setting.name" />
<my-input-toggle-hidden *ngIf="setting.type === 'input-password'" [formControlName]="setting.name" [id]="setting.name"></my-input-toggle-hidden>

<textarea *ngIf="setting.type === 'input-textarea'" type="text" [id]="setting.name" [formControlName]="setting.name"></textarea>

Expand Down
2 changes: 1 addition & 1 deletion client/src/app/shared/shared-forms/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './form-validator.service'
export * from './form-reactive'
export * from './select'
export * from './input-readonly-copy.component'
export * from './input-toggle-hidden.component'
export * from './input-switch.component'
export * from './markdown-textarea.component'
export * from './peertube-checkbox.component'
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="input-group input-group-sm">
<input [id]="id" [autocomplete]="autocomplete" [value]="value" [placeholder]="placeholder" [(ngModel)]="value" (ngModelChange)="update()" [ngClass]="{ 'readonly': readonly }" [readonly]="readonly"
#input (click)="input.select()" (input)="update()" (change)="update()" [type]="inputType" class="form-control" />

<div *ngIf="withToggle || withCopy" class="input-group-append">
<button *ngIf="withToggle" (click)="toggle()" type="button" class="btn btn-outline-secondary" [title]="toggleTitle">
<span class="glyphicon glyphicon-eye-{{ show ? 'open' : 'close' }}"></span>
</button>
<button *ngIf="withCopy" [cdkCopyToClipboard]="input.value" (click)="activateCopiedMessage()" type="button" class="btn btn-outline-secondary" i18n-title title="Copy">
<span class="glyphicon glyphicon-copy"></span>
</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@import '_variables';
@import '_mixins';

input {
@include peertube-input-text(auto);

// set again properties of peertube-input-text that are overriden by .input-group
font-size: 15px !important;
padding-left: 15px !important;
padding-right: 15px !important;
}
Loading

0 comments on commit f8b530e

Please sign in to comment.