Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#10651 main #455

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/components/InitialsAvatar/InitialsAvatar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,29 @@ export default {
};

export const Default = {
args: {givenName: 'Ramiro', familyName: 'Vaca'},
};

export const GivenNameOnly = {
args: {givenName: 'Daniel'},
args: {initials: 'RV'},
};

export const IsSecondary = {
args: {givenName: 'David', familyName: 'Buskins', isSecondary: true},
args: {initials: 'DB', isSecondary: true},
};

export const IsWarnable = {
args: {givenName: 'Aisla', familyName: 'McCrae', isWarnable: true},
args: {initials: 'AG', isWarnable: true},
};

export const IsDisabled = {
args: {
givenName: 'Adela',
familyName: 'Gallego',
initials: 'AG',
isSecondary: true,
isDisabled: true,
},
};

export const UndefinedName = {
export const UndefinedInitials = {
args: {},
};

export const SmallIcon = {
args: {givenName: 'Paul', familyName: 'Hudson', shrink: true},
args: {initials: 'PH', shrink: true},
};
19 changes: 5 additions & 14 deletions src/components/InitialsAvatar/InitialsAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
import {computed} from 'vue';
import Icon from '../Icon/Icon.vue';
const props = defineProps({
/** User's given name */
givenName: {
type: String,
required: true,
},
/** User's family name */
familyName: {
type: String,
default: '',
},
/** If the background should use primary color (blue) */
isPrimary: {
type: Boolean,
Expand All @@ -44,10 +34,11 @@ const props = defineProps({
type: Boolean,
default: false,
},
});

const initials = computed(() => {
return `${props.givenName?.charAt(0) || ''}${props.familyName?.charAt(0) || ''}`.toUpperCase();
/** Initials to display */
initials: {
type: String,
required: true,
},
});

const classes = computed(() => ({
Expand Down
9 changes: 1 addition & 8 deletions src/components/UserAvatar/UserAvatar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ export default {

export const Default = {
args: {
userFullName: 'Nama Sampan-Nirmal Lengkap',
userId: 136,
},
};

export const Arabic = {
args: {
userFullName: 'خالد محمود الفارسي',
initials: 'NL',
userId: 136,
},
};
9 changes: 2 additions & 7 deletions src/components/UserAvatar/UserAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@

<script setup>
import {computed} from 'vue';
import {useParticipant} from '@/composables/useParticipant';

const {getUserAvatarInitialsFromName} = useParticipant();
const props = defineProps({
sizeVariant: {
required: false,
type: String,
default: () => 'large',
validator: (prop) => ['large', 'small'].includes(prop),
},
userFullName: {type: String, required: true},
/** Initials to display */
initials: {type: String, required: true},
userId: {type: Number, required: true},
});

Expand All @@ -48,8 +47,4 @@ const initialsClasses = computed(() => {
props.sizeVariant === 'large' ? 'text-2xl-bold' : 'text-lg-bold';
return [textSizeClass];
});

const initials = computed(() => {
return getUserAvatarInitialsFromName(props.userFullName);
});
</script>
15 changes: 0 additions & 15 deletions src/composables/useParticipant.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,7 @@ export function useParticipant() {
];
}

function getUserAvatarInitialsFromName(fullName) {
const fullNameParts = fullName.split(' ');

return fullNameParts
.map((part) => {
const partTrimmed = part.trim();
if (partTrimmed.length) {
return partTrimmed[0].toUpperCase();
}
return '';
})
.join('')
.substring(0, 3);
}
return {
getUserAvatarInitialsFromName,
getEditorRoleIds,
};
}
29 changes: 0 additions & 29 deletions src/composables/useParticipant.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/managers/ParticipantManager/ParticipantManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div>
<UserAvatar
:user-id="participant.id"
:user-full-name="participant.fullName"
:initials="participant.displayInitials"
></UserAvatar>
</div>
<div class="ms-2 flex flex-col justify-center">
Expand Down
1 change: 1 addition & 0 deletions src/managers/ParticipantManager/participantManagerStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const useParticipantManagerStore = defineComponentStore(
roleId: stageAssignment.stageAssignmentUserGroup.roleId,
userGroupId: stageAssignment.stageAssignmentUserGroup.id,
recommendOnly: stageAssignment.recommendOnly,
displayInitials: participant.displayInitials,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<UserAvatar
size-variant="small"
:user-id="reviewAssignment.id"
:user-full-name="String(reviewAssignment.reviewerFullName)"
:initials="String(reviewAssignment.reviewerDisplayInitials)"
/>
</template>
<ReviewActivityIndicatorPopover
Expand Down
Loading