summaryrefslogtreecommitdiffstats
path: root/ui/src/components/user.tsx
diff options
context:
space:
mode:
authorDessalines <dessalines@users.noreply.github.com>2020-07-09 20:04:09 -0400
committerGitHub <noreply@github.com>2020-07-09 20:04:09 -0400
commit961d65c0ee304b97cc3932d7e2a7334a823e2969 (patch)
tree547161cf7ec7ba437d8f66cb67acac9721ee2440 /ui/src/components/user.tsx
parent50e6d81d0b40e1d9caa0db83d20026adf3aef631 (diff)
Remove button for avatars. Fixes #755 (#924)
Diffstat (limited to 'ui/src/components/user.tsx')
-rw-r--r--ui/src/components/user.tsx31
1 files changed, 29 insertions, 2 deletions
diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx
index af72a397..0e107363 100644
--- a/ui/src/components/user.tsx
+++ b/ui/src/components/user.tsx
@@ -535,7 +535,7 @@ export class User extends Component<any, UserState> {
htmlFor="file-upload"
class="pointer ml-4 text-muted small font-weight-bold"
>
- {!this.state.userSettingsForm.avatar ? (
+ {!this.checkSettingsAvatar ? (
<span class="btn btn-sm btn-secondary">
{i18n.t('upload_avatar')}
</span>
@@ -559,6 +559,18 @@ export class User extends Component<any, UserState> {
/>
</form>
</div>
+ {this.checkSettingsAvatar && (
+ <div class="form-group">
+ <button
+ class="btn btn-secondary btn-block"
+ onClick={linkEvent(this, this.removeAvatar)}
+ >
+ {`${capitalizeFirstLetter(i18n.t('remove'))} ${i18n.t(
+ 'avatar'
+ )}`}
+ </button>
+ </div>
+ )}
<div class="form-group">
<label>{i18n.t('language')}</label>
<select
@@ -1073,6 +1085,22 @@ export class User extends Component<any, UserState> {
});
}
+ removeAvatar(i: User, event: any) {
+ event.preventDefault();
+ i.state.userSettingsLoading = true;
+ i.state.userSettingsForm.avatar = '';
+ i.setState(i.state);
+
+ WebSocketService.Instance.saveUserSettings(i.state.userSettingsForm);
+ }
+
+ get checkSettingsAvatar(): boolean {
+ return (
+ this.state.userSettingsForm.avatar &&
+ this.state.userSettingsForm.avatar != ''
+ );
+ }
+
handleUserSettingsSubmit(i: User, event: any) {
event.preventDefault();
i.state.userSettingsLoading = true;
@@ -1190,7 +1218,6 @@ export class User extends Component<any, UserState> {
this.setState(this.state);
} else if (res.op == UserOperation.SaveUserSettings) {
let data = res.data as LoginResponse;
- this.state = this.emptyState;
this.state.userSettingsLoading = false;
this.setState(this.state);
UserService.Instance.login(data);