Skip to content

Commit

Permalink
privacy public/private
Browse files Browse the repository at this point in the history
  • Loading branch information
Resul Avan authored and Resul Avan committed Jun 21, 2020
1 parent d985cf0 commit b33b647
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 62 deletions.
4 changes: 1 addition & 3 deletions src/components/error/Error404.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<template>
<div>
<pre>{{ error}}</pre>
</div>
<pre>{{ error}}</pre>
</template>

<script lang="ts">
Expand Down
13 changes: 11 additions & 2 deletions src/components/form/ProfileUpdateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
class="has-margin-bottom-15"
/>

<PrivacyDropdown v-model="updatedUser.privacy"
:label="$t('common.field.privacy')"
rules="required"
label-position="on-border"
vid="privacy"
class="has-margin-5"/>

<InputWithValidation
v-model="updatedUser.username"
:label="$t('common.field.username')"
Expand Down Expand Up @@ -95,9 +102,10 @@
sendNotification
} from '~/service/notification-service';
import { handleError } from '~/service/error-service';
import PrivacyDropdown from '~/components/ui/dropdown/PrivacyDropdown.vue';
@Component({
components: { FieldWithValue, InputNoValidation, ValidationObserver, InputWithValidation }
components: { PrivacyDropdown, FieldWithValue, InputNoValidation, ValidationObserver, InputWithValidation }
})
export default class ProfileUpdateForm extends Vue {
Expand All @@ -116,7 +124,8 @@
if (!savedUser) {
return
}
await this.$router.replace(getUserRoute(Routes.PROFILE_SETTINGS, savedUser.username as string))
await this.$router.replace(getUserRoute(Routes.PROFILE_SETTINGS, savedUser.username as string)).catch(() => {
})
await sendNotification(this.$store.dispatch, getSuccessNotificationMessage(this.$t('notification.profile.updated')))
})
.catch((error: Error) =>
Expand Down
36 changes: 16 additions & 20 deletions src/components/profile/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
<div class="media-content">
<div class="content">
<p><strong>{{ fullName }}</strong></p>
<p v-if="user.username">
<small>@{{ user.username }}</small>
<p><small>@{{ user.username }}</small></p>
<p>
<b-tooltip :label="$t(`privacy.${userPrivacyConfig.privacyType}.description`)">
<b-taglist attached>
<b-tag :type="userPrivacyConfig.type">{{$t(`privacy.${userPrivacyConfig.privacyType}.title`)}}</b-tag>
<b-tag type="is-light">{{$t(`privacy.${userPrivacyConfig.privacyType}.subtitle`)}}</b-tag>
</b-taglist>
</b-tooltip>
</p>
</div>
</div>
Expand All @@ -24,14 +30,15 @@
<div class="columns is-centered">

<div class="column is-half">
<h2 class="subtitle has-text-centered">{{$t('card.user.title')}}</h2>
<h2 class="subtitle has-text-centered">{{$t('profile.card.info.title')}}</h2>
<ProfileInfo :auth-user="authUser" :user="user"/>
</div>

</div>

<div class="columns is-centered">
<div class="column is-half"><h2 class="subtitle has-text-centered">{{$t('card.linkedAccounts.title')}}</h2>
<div class="column is-half"><h2 class="subtitle has-text-centered">
{{$t('profile.card.linkedAccounts.title')}}</h2>
</div>
</div>

Expand All @@ -43,15 +50,7 @@

<script lang="ts">
import { Component, Prop, Vue } from 'nuxt-property-decorator';
import {
AuthUser,
ProfilePhotoStorageRef,
ProviderConfig,
ProviderType,
StateNamespace,
SupportedProviders,
User
} from "~/types";
import { AuthUser, PrivacyList, PrivacyType, StateNamespace, User } from "~/types";
import ProfileInfo from "~/components/profile/ProfileInfo.vue";
import ProfilePhoto from "~/components/profile/ProfilePhoto.vue";
import CoverPhoto from "~/components/profile/CoverPhoto.vue";
Expand All @@ -75,15 +74,12 @@
return this.authUser.userId === this.user.id
}
get parentFolderRef() {
return ProfilePhotoStorageRef.folderRef
.replace(ProfilePhotoStorageRef.parameters.userId, this.authUser.userId)
get userPrivacy() {
return this.user.privacy || PrivacyType.PRIVATE
}
get passwordProvider(): ProviderConfig | undefined {
return this.authUser.providers.find((providerData) => providerData.providerType === ProviderType.PASSWORD) ?
SupportedProviders.find(provider => provider.providerType === ProviderType.PASSWORD)
: undefined
get userPrivacyConfig() {
return PrivacyList.find((privacyConfig) => privacyConfig.privacyType === this.userPrivacy)
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/profile/ProfileInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
<b-field v-if="authUser.email" :label="$t('common.field.email')" horizontal>
<b-field grouped>
<span>{{ authUser.email }}</span>
<b-tooltip v-if="authUser.verified" :label="$t('card.user.mailVerified')">
<b-tooltip v-if="authUser.verified" :label="$t('profile.card.info.mailVerified')">
<b-icon type="is-success"
class="has-margin-left-15"
pack="fas"
icon="check"/>
</b-tooltip>

<b-tooltip v-else :label="$t('card.user.mailNotVerified')">
<b-tooltip v-else :label="$t('profile.card.info.mailNotVerified')">
<b-icon type="is-warning"
class="has-margin-left-15"
pack="fas"
Expand All @@ -48,7 +48,7 @@
@click="submit"
:disabled="loading"
>
{{ $t('card.user.verifyButton') }}
{{ $t('profile.card.info.verifyButton') }}
</b-button>

<b-button
Expand All @@ -68,7 +68,7 @@
type="is-primary"
@click="showSetPasswordModal"
>
{{ $t('card.user.updatePasswordButton') }}
{{ $t('profile.card.info.updatePasswordButton') }}
</b-button>

</div>
Expand Down
82 changes: 82 additions & 0 deletions src/components/ui/dropdown/PrivacyDropdown.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<template>
<ValidationProvider
:vid="vid"
:name="$attrs.name || $attrs.label"
:rules="rules"
v-slot="{ errors, valid }"
validate="input"
>
<b-field
v-bind="$attrs"
:type="{ 'is-danger': errors[0], 'is-success': valid }"
:message="errors"
:horizontal="horizontal"
:label="$attrs.label"
:label-position="labelPosition"
>
<b-dropdown :value="value" @input="input" aria-role="list" class="has-margin-top-10">
<b-button v-if="selectedPrivacyType" slot="trigger" :class="selectedPrivacyType.type" :outlined="!value">
<b-icon :icon="selectedPrivacyType.icon" class="has-margin-left-5"/>
<span class="has-margin-left-5">{{$t(`privacy.${selectedPrivacyType.privacyType}.title`)}}</span>
<b-icon icon="menu-down"></b-icon>
</b-button>

<b-button v-else slot="trigger" class="is-primary" :outlined="!value">
<b-icon icon="account-remove-outline" class="has-margin-left-5"/>
<span class="has-margin-left-5">{{$t(`privacy.notSelected`)}}</span>
<b-icon icon="menu-down"></b-icon>
</b-button>

<b-dropdown-item v-for="(privacy, index) in privacyList"
:key="index"
:value="privacy.privacyType"
aria-role="listitem">
<div class="media" :class="privacy.type">
<b-icon class="media-left" :icon="privacy.icon"></b-icon>
<div class="media-content">
<h3>{{$t(`privacy.${privacy.privacyType}.title`)}}</h3>
<h4>{{$t(`privacy.${privacy.privacyType}.subtitle`)}}</h4>
<small>{{$t(`privacy.${privacy.privacyType}.description`)}}</small>
</div>
</div>
</b-dropdown-item>
</b-dropdown>
<small v-if="value" class="has-margin-top-5 has-margin-left-5">{{$t(`privacy.${value}.description`)}}</small>
</b-field>
</ValidationProvider>
</template>

<script lang="ts">
import { Component, Emit, Model, Prop, Vue } from 'nuxt-property-decorator';
import { PrivacyList, PrivacyType } from '~/types';
import { ValidationProvider } from 'vee-validate';
@Component({
components: { ValidationProvider }
})
export default class PrivacyDropdown extends Vue {
@Model('input', { required: true }) readonly value!: PrivacyType;
@Prop({ type: String, required: true }) vid !: string;
@Prop({ type: String, required: true }) rules !: string;
@Prop({ type: Boolean, required: false, default: false }) horizontal !: boolean;
@Prop({ type: Boolean, required: false, default: false }) disabled !: boolean;
@Prop({ type: String, required: false, default: '' }) labelPosition !: string;
@Emit()
input(newValue: PrivacyType) {
return newValue
}
get selectedPrivacyType() {
return PrivacyList.find(value => value.privacyType === this.value)
}
get privacyList() {
return PrivacyList
}
}
</script>
47 changes: 32 additions & 15 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const messages = {
confirmPasswordPlaceHolder: 'Re-enter password',
rememberMe: 'Remember Me',
profilePhoto: 'profile photo',
coverPhoto: 'cover photo'
coverPhoto: 'cover photo',
privacy: 'Privacy',
},
cancel: 'Cancel',
save: 'Save',
Expand Down Expand Up @@ -95,6 +96,21 @@ const messages = {
notFound: 'Page not found',
},

profile: {
card: {
info: {
title: 'Account Info',
verifyButton: 'Verify Email',
updatePasswordButton: 'Update Password',
mailVerified: 'Email is verified',
mailNotVerified: 'Email is not verified',
},
linkedAccounts: {
title: 'Linked Accounts',
},
},
},

notification: {
verifyMailSent: 'Verification mail has been sent to {email}',
verifyMailNotSent: 'Verification mail can not sent to {email}',
Expand Down Expand Up @@ -147,20 +163,6 @@ const messages = {
},
},

card: {
user: {
title: 'Account Info',
providers: 'Providers',
verifyButton: 'Verify Email',
updatePasswordButton: 'Update Password',
mailVerified: 'Email is verified',
mailNotVerified: 'Email is not verified',
},
linkedAccounts: {
title: 'Linked Accounts:',
},
},

provider: {
label: {
password: 'Password',
Expand Down Expand Up @@ -197,6 +199,7 @@ const messages = {
},
},
},

image: {
crop: {
preview: 'Preview',
Expand All @@ -205,6 +208,20 @@ const messages = {
dragAndDropButton: 'Drop your files here or click to upload',
},
},

privacy: {
private: {
title: 'Private',
subtitle: 'No one can see',
description: 'No one can see any data of you',
},
public: {
title: 'Public',
subtitle: 'Everyone can see',
description: 'The authenticated users can see your non-sensitive data like name, username, profile and cover photo',
},
notSelected: 'Select visibility',
},
}

export default messages
45 changes: 30 additions & 15 deletions src/i18n/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const messages = {
confirmPasswordPlaceHolder: 'Parolanizi tekrar giriniz',
rememberMe: 'Beni Hatirla',
profilePhoto: 'Profil fotografi',
coverPhoto: 'Kapak fotografi'
coverPhoto: 'Kapak fotografi',
privacy: 'Gizlilik',
},
cancel: 'Iptal',
save: 'Kaydet',
Expand All @@ -48,6 +49,21 @@ const messages = {
logout: 'Cikis Yap',
},

profile: {
card: {
info: {
title: 'Hesap Bilgileri',
verifyButton: 'E-posta Dogrula',
updatePasswordButton: 'Parolayi guncelle',
mailVerified: 'E-posta dogrulandi',
mailNotVerified: 'E-posta dogrulanmadi',
},
linkedAccounts: {
title: 'Bagli Hesaplar',
},
},
},

page: {
home: {
title: 'Anasayfaya hosgeldiniz',
Expand Down Expand Up @@ -146,20 +162,6 @@ const messages = {
},
},

card: {
user: {
title: 'Hesap Bilgileri',
providers: 'Saglayicilar',
verifyButton: 'E-posta Dogrula',
updatePasswordButton: 'Parolayi guncelle',
mailVerified: 'E-posta dogrulandi',
mailNotVerified: 'E-posta dogrulanmadi',
},
linkedAccounts: {
title: 'Bagli Hesaplar:',
},
},

provider: {
label: {
password: 'Password',
Expand Down Expand Up @@ -202,6 +204,19 @@ const messages = {
dragAndDropButton: 'Dosya yuklemek icin tikla veya surukle&birak',
},
},
privacy: {
private: {
title: 'Gizli',
subtitle: 'Kimse goremez',
description: 'Kimse size ait her hangi bir bilgiye ulasamaz',
},
public: {
title: 'Herkese Acik',
subtitle: 'Herkes gorebilir',
description: 'Giris yapmis kullanicilar, kisisel olmayan bilgilerinize gorebilir. ornegin isim, kullanici adi, profil ve kapak fotografi',
},
notSelected: 'Gizliligi belirle',
},
}

export default messages
Loading

0 comments on commit b33b647

Please sign in to comment.