summaryrefslogtreecommitdiffstats
path: root/ui/src/components/user.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/components/user.tsx')
-rw-r--r--ui/src/components/user.tsx57
1 files changed, 49 insertions, 8 deletions
diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx
index 078ce89c..854dd6ef 100644
--- a/ui/src/components/user.tsx
+++ b/ui/src/components/user.tsx
@@ -48,6 +48,7 @@ import { ListingTypeSelect } from './listing-type-select';
import { CommentNodes } from './comment-nodes';
import { MomentTime } from './moment-time';
import { i18n } from '../i18next';
+import moment from 'moment';
enum View {
Overview,
@@ -382,6 +383,7 @@ export class User extends Component<any, UserState> {
nodes={[{ comment: i.data as Comment }]}
admins={this.state.admins}
noIndent
+ showCommunity
showContext
enableDownvotes={this.state.site.enable_downvotes}
/>
@@ -399,6 +401,7 @@ export class User extends Component<any, UserState> {
nodes={commentsToFlatNodes(this.state.comments)}
admins={this.state.admins}
noIndent
+ showCommunity
showContext
enableDownvotes={this.state.site.enable_downvotes}
/>
@@ -440,6 +443,15 @@ export class User extends Component<any, UserState> {
)}
</ul>
</h5>
+ <div className="d-flex align-items-center mb-2">
+ <svg class="icon">
+ <use xlinkHref="#icon-cake"></use>
+ </svg>
+ <span className="ml-2">
+ {i18n.t('cake_day_title')}{' '}
+ {moment.utc(user.published).local().format('MMM DD, YYYY')}
+ </span>
+ </div>
<div>
{i18n.t('joined')} <MomentTime data={user} showAgo />
</div>
@@ -525,7 +537,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>
@@ -549,6 +561,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
@@ -883,12 +907,14 @@ export class User extends Component<any, UserState> {
{i18n.t('prev')}
</button>
)}
- <button
- class="btn btn-sm btn-secondary"
- onClick={linkEvent(this, this.nextPage)}
- >
- {i18n.t('next')}
- </button>
+ {this.state.comments.length + this.state.posts.length > 0 && (
+ <button
+ class="btn btn-sm btn-secondary"
+ onClick={linkEvent(this, this.nextPage)}
+ >
+ {i18n.t('next')}
+ </button>
+ )}
</div>
);
}
@@ -1061,6 +1087,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;
@@ -1178,7 +1220,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);