-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Show who voted for what in poll results #28305
Open
timvahlbrock
wants to merge
19
commits into
element-hq:develop
Choose a base branch
from
timvahlbrock:poll-votes
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+998
−255
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4c90e47
Show Profile Pictures according to Votes on Poll Options
timvahlbrock f6f0fe2
Show vote face pile only if there are less than five members in the room
timvahlbrock aa46664
Fix winner icon and votes text
timvahlbrock fa76ae6
Revert "Enable React StrictMode (#28258)"
timvahlbrock a5fdd41
Add dialog to display detailed votes
timvahlbrock baabfbc
Refactor PollResultsDialog
timvahlbrock b739f23
Move styling of results dialog to css
timvahlbrock 653be23
Show text using i18n and modify existing usages
timvahlbrock 6b92c92
Merge branch 'element-hq:develop' into poll-votes
timvahlbrock 2083213
Fix existing tests but 3
timvahlbrock 22729f4
Fix remaining existing tests
timvahlbrock 3730cb4
Move poll option styling to css file
timvahlbrock c53fea0
Add test that dialog is opened when totalVotes are clicked
timvahlbrock dc03851
Reapply "Enable React StrictMode (#28258)"
timvahlbrock df7eea6
Merge branch 'develop' into poll-votes
timvahlbrock ffd0e2d
Merge branch 'develop' into poll-votes
timvahlbrock e55c9a1
Merge remote-tracking branch 'origin/develop' into poll-votes
timvahlbrock ebbdf80
Add e2e test for detailed poll results
timvahlbrock 03f092a
Merge remote-tracking branch 'origin/develop' into poll-votes
timvahlbrock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
24 changes: 24 additions & 0 deletions
24
res/css/components/views/dialogs/polls/_PollResultsDialog.pcss
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,24 @@ | ||
.mx_AnswerEntry:not(:last-child) { | ||
margin-bottom: $spacing-8; | ||
} | ||
|
||
.mx_AnswerEntry_Header { | ||
display: flex; | ||
align-items: center; | ||
margin-bottom: $spacing-8; | ||
} | ||
|
||
.mx_AnswerEntry_Header_answerName { | ||
font-weight: bolder; | ||
flex-grow: 1 | ||
} | ||
|
||
.mx_VoterEntry { | ||
display: flex; | ||
align-items: center; | ||
margin-left: $spacing-16; | ||
} | ||
|
||
.mx_VoterEntry_AvatarWrapper { | ||
margin-right: $spacing-8; | ||
} |
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,82 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd. | ||
Copyright 2021, 2022 The Matrix.org Foundation C.I.C. | ||
|
||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only | ||
Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
import { PollAnswerSubevent, PollStartEvent } from "matrix-js-sdk/src/extensible_events_v1/PollStartEvent"; | ||
import { RoomMember } from "matrix-js-sdk/src/matrix"; | ||
import React from "react"; | ||
|
||
import { _t } from "../../../languageHandler"; | ||
import Modal from "../../../Modal"; | ||
import MemberAvatar from "../avatars/MemberAvatar"; | ||
import { UserVote } from "../messages/MPollBody"; | ||
import BaseDialog from "./BaseDialog"; | ||
|
||
interface IProps { | ||
pollEvent: PollStartEvent; | ||
votes: Map<string, UserVote[]>; | ||
members: RoomMember[]; | ||
} | ||
|
||
export default function PollResultsDialog(props: IProps): JSX.Element { | ||
return ( | ||
<BaseDialog | ||
title={props.pollEvent.question.text} | ||
onFinished={() => Modal.closeCurrentModal()} | ||
className="mx_PollResultsDialog" | ||
> | ||
{ | ||
props.pollEvent.answers.map((answer) => { | ||
const votes = props.votes.get(answer.id) || []; | ||
if (votes.length === 0) return; | ||
|
||
return <AnswerEntry | ||
key={answer.id} | ||
answer={answer} | ||
members={props.members} | ||
votes={votes} | ||
/>; | ||
}) | ||
} | ||
</BaseDialog> | ||
); | ||
} | ||
|
||
function AnswerEntry(props: { | ||
answer: PollAnswerSubevent; | ||
members: RoomMember[]; | ||
votes: UserVote[]; | ||
}): JSX.Element { | ||
const { answer, members, votes } = props; | ||
return ( | ||
<div key={answer.id} className="mx_AnswerEntry"> | ||
<div className="mx_AnswerEntry_Header"> | ||
<span className="mx_AnswerEntry_Header_answerName">{answer.text}</span> | ||
<span className="mx_AnswerEntry_Header_voteCount">{_t("poll|result_dialog|count_of_votes", { count: votes.length })}</span> | ||
</div> | ||
{votes.length === 0 && <div>No one voted for this.</div>} | ||
{votes.map((vote) => { | ||
const member = members.find(m => m.userId === vote.sender); | ||
if (member) return <VoterEntry | ||
key={vote.sender} | ||
vote={vote} | ||
member={member} | ||
/>; | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
function VoterEntry(props: { vote: UserVote; member: RoomMember }): JSX.Element { | ||
const { vote, member } = props; | ||
return <div key={vote.sender} className="mx_VoterEntry"> | ||
<div className="mx_VoterEntry_AvatarWrapper"> | ||
<MemberAvatar member={member} size="36px" aria-hidden="true" /> | ||
</div> | ||
{member.name} | ||
</div>; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wrote this file, the copyright is yours.