-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(landingPage): Add list of members to the landing page
Show list of members on landing page if it's not a public share. Signed-off-by: Jonas <jonas@freesources.org>
- Loading branch information
Showing
6 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<template> | ||
<div class="landing-page-widgets"> | ||
<MembersWidget v-if="!isPublic" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapGetters } from 'vuex' | ||
import MembersWidget from './LandingPageWidgets/MembersWidget.vue' | ||
export default { | ||
name: 'LandingPageWidgets', | ||
components: { | ||
MembersWidget, | ||
}, | ||
computed: { | ||
...mapGetters([ | ||
'isPublic', | ||
]), | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.landing-page-widgets { | ||
margin: auto; | ||
padding-left: 12px; | ||
max-width: 670px; | ||
} | ||
</style> |
126 changes: 126 additions & 0 deletions
126
src/components/Page/LandingPageWidgets/MembersWidget.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<template> | ||
<div class="members-widget"> | ||
<WidgetHeading :title="t('collectives', 'Collective members')" /> | ||
<div class="members-widget-members"> | ||
<NcAvatar v-for="member in trimmedMembers" | ||
:key="member.singleId" | ||
:user-id="member.userId" | ||
:display-name="member.displayName" | ||
:is-no-user="isNoUser(member)" | ||
:icon-class="iconClass(member)" | ||
:disable-menu="true" | ||
:tooltip-message="member.displayName" | ||
:size="44" /> | ||
<NcButton v-if="showMoreButton" | ||
type="secondary" | ||
:aria-label="t('collectives', 'Show all members of the collective')" | ||
@click="openCollectiveMembers()"> | ||
<template #icon> | ||
<DotsHorizontalIcon :size="20" /> | ||
</template> | ||
</NcButton> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapActions, mapGetters, mapMutations } from 'vuex' | ||
import { NcAvatar, NcButton } from '@nextcloud/vue' | ||
import DotsHorizontalIcon from 'vue-material-design-icons/DotsHorizontal.vue' | ||
import { GET_CIRCLE_MEMBERS } from '../../../store/actions.js' | ||
import { circlesMemberTypes } from '../../../constants.js' | ||
import WidgetHeading from './WidgetHeading.vue' | ||
const SHOW_MEMBERS_COUNT = 3 | ||
export default { | ||
name: 'MembersWidget', | ||
components: { | ||
DotsHorizontalIcon, | ||
NcAvatar, | ||
NcButton, | ||
WidgetHeading, | ||
}, | ||
computed: { | ||
...mapGetters([ | ||
'circleMembersSorted', | ||
'circleMemberType', | ||
'currentCollective', | ||
'isCollectiveAdmin', | ||
'recentPagesUserIds', | ||
]), | ||
sortedMembers() { | ||
return this.circleMembersSorted(this.currentCollective.circleId) | ||
.slice() | ||
.sort(this.sortLastActiveFirst) | ||
}, | ||
trimmedMembers() { | ||
return this.sortedMembers | ||
.slice(0, SHOW_MEMBERS_COUNT) | ||
}, | ||
isNoUser() { | ||
return function(member) { | ||
return this.circleMemberType(member) !== circlesMemberTypes.TYPE_USER | ||
} | ||
}, | ||
iconClass() { | ||
return function(member) { | ||
return this.isNoUser(member) ? 'icon-group-white' : null | ||
} | ||
}, | ||
showMoreButton() { | ||
return this.isCollectiveAdmin(this.currentCollective) | ||
|| this.sortedMembers.length > SHOW_MEMBERS_COUNT | ||
}, | ||
}, | ||
beforeMount() { | ||
this.dispatchGetCircleMembers(this.currentCollective.circleId) | ||
}, | ||
methods: { | ||
...mapActions({ | ||
dispatchGetCircleMembers: GET_CIRCLE_MEMBERS, | ||
}), | ||
...mapMutations([ | ||
'setMembersCollectiveId', | ||
]), | ||
openCollectiveMembers() { | ||
this.setMembersCollectiveId(this.currentCollective.id) | ||
}, | ||
/** | ||
* @param {object} m1 First member | ||
* @param {string} m1.userId First member user ID | ||
* @param {object} m2 Second member | ||
* @param {string} m2.userId Second member user ID | ||
*/ | ||
sortLastActiveFirst(m1, m2) { | ||
if (this.recentPagesUserIds.includes(m1.userId) && this.recentPagesUserIds.includes(m2.userId)) { | ||
return this.recentPagesUserIds.indexOf(m1.userId) > this.recentPagesUserIds.indexOf(m2.userId) | ||
} else if (this.recentPagesUserIds.includes(m1.userId)) { | ||
return -1 | ||
} else if (this.recentPagesUserIds.includes(m2.userId)) { | ||
return 1 | ||
} | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.members-widget-members { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 12px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<div class="widget-heading"> | ||
{{ title }} | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'WidgetHeading', | ||
props: { | ||
title: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.widget-heading { | ||
padding: 30px 0 12px 0; | ||
font-size: 20px; | ||
font-weight: bold; | ||
color: var(--color-text-maxcontrast); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters