This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 816
Poll history: detail screen #10172
Merged
Merged
Poll history: detail screen #10172
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2c791ea
basic navigation to focused poll
ca130f0
add tooltip
5456698
drill permalinkCreator down to poll history
2a168a9
render poll tile and link to timeline
ac2b24e
tidy and lint
0983cea
unit test poll detail
61854d8
Merge branch 'develop' into psg-1042/poll-history-detail-screen
58d5ef2
Merge branch 'develop' into psg-1042/poll-history-detail-screen
9688076
add view poll link to ended pollliste item
a673eeb
Merge branch 'develop' into psg-1042/poll-history-detail-screen
1c9af42
strict fix
d6b0e6d
pr improvements
95cca0a
Merge branch 'develop' into psg-1042/poll-history-detail-screen
b88c5f9
pass room as prop
21360db
permalinkcreator ts assertion
b8fa1b8
Merge branch 'develop' into psg-1042/poll-history-detail-screen
822f0b8
Merge branch 'develop' into psg-1042/poll-history-detail-screen
506a0eb
Merge branch 'develop' into psg-1042/poll-history-detail-screen
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 hidden or 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
27 changes: 27 additions & 0 deletions
27
res/css/components/views/dialogs/polls/_PollDetailHeader.pcss
This file contains hidden or 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 @@ | ||
/* | ||
Copyright 2023 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
.mx_PollDetailHeader { | ||
// override accessiblebutton style | ||
font-size: $font-15px !important; | ||
} | ||
|
||
.mx_PollDetailHeader_icon { | ||
height: 15px; | ||
width: 15px; | ||
margin-right: $spacing-8; | ||
vertical-align: middle; | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,89 @@ | ||
/* | ||
Copyright 2023 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React from "react"; | ||
import { Poll } from "matrix-js-sdk/src/matrix"; | ||
|
||
import { _t } from "../../../../languageHandler"; | ||
import dispatcher from "../../../../dispatcher/dispatcher"; | ||
import { Action } from "../../../../dispatcher/actions"; | ||
import { ViewRoomPayload } from "../../../../dispatcher/payloads/ViewRoomPayload"; | ||
import { RoomPermalinkCreator } from "../../../../utils/permalinks/Permalinks"; | ||
import { MediaEventHelper } from "../../../../utils/MediaEventHelper"; | ||
import AccessibleButton, { ButtonEvent } from "../../elements/AccessibleButton"; | ||
import MPollBody from "../../messages/MPollBody"; | ||
|
||
interface Props { | ||
poll: Poll; | ||
requestModalClose: () => void; | ||
permalinkCreator: RoomPermalinkCreator; | ||
} | ||
|
||
const NOOP = (): void => {}; | ||
|
||
/** | ||
* Content of the PollHistoryDialog when a specific poll is selected | ||
*/ | ||
export const PollDetail: React.FC<Props> = ({ poll, permalinkCreator, requestModalClose }) => { | ||
// link to end event for ended polls | ||
const eventIdToLinkTo = poll.isEnded ? poll.endEventId! : poll.pollId; | ||
const linkToTimeline = permalinkCreator.forEvent(eventIdToLinkTo); | ||
|
||
const onLinkClick = (e: ButtonEvent): void => { | ||
if ((e as React.MouseEvent).ctrlKey || (e as React.MouseEvent).metaKey) { | ||
// native behavior for link on ctrl/cmd + click | ||
return; | ||
} | ||
// otherwise handle navigation in the app | ||
e.preventDefault(); | ||
dispatcher.dispatch<ViewRoomPayload>({ | ||
action: Action.ViewRoom, | ||
event_id: eventIdToLinkTo, | ||
highlighted: true, | ||
room_id: poll.roomId, | ||
metricsTrigger: undefined, // room doesn't change | ||
}); | ||
|
||
requestModalClose(); | ||
}; | ||
return ( | ||
<> | ||
<MPollBody | ||
mxEvent={poll.rootEvent} | ||
permalinkCreator={permalinkCreator} | ||
onHeightChanged={NOOP} | ||
onMessageAllowed={NOOP} | ||
// MPollBody doesn't use this | ||
// and MessageEvent only defines it for eligible events | ||
// should be fixed on IBodyProps types | ||
// cheat to fulfil the type here | ||
mediaEventHelper={{} as unknown as MediaEventHelper} | ||
/> | ||
<br /> | ||
<div> | ||
<AccessibleButton | ||
kind="link_inline" | ||
element="a" | ||
href={linkToTimeline} | ||
onClick={onLinkClick} | ||
rel="noreferrer noopener" | ||
> | ||
{_t("View poll in timeline")} | ||
</AccessibleButton> | ||
</div> | ||
</> | ||
); | ||
}; |
This file contains hidden or 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,36 @@ | ||
/* | ||
Copyright 2023 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React from "react"; | ||
|
||
import { Icon as LeftCaretIcon } from "../../../../../res/img/element-icons/caret-left.svg"; | ||
import { _t } from "../../../../languageHandler"; | ||
import AccessibleButton from "../../elements/AccessibleButton"; | ||
import { PollHistoryFilter } from "./types"; | ||
|
||
interface Props { | ||
filter: PollHistoryFilter; | ||
onNavigateBack: () => void; | ||
} | ||
|
||
export const PollDetailHeader: React.FC<Props> = ({ filter, onNavigateBack }) => { | ||
return ( | ||
<AccessibleButton kind="content_inline" onClick={onNavigateBack} className="mx_PollDetailHeader"> | ||
<LeftCaretIcon className="mx_PollDetailHeader_icon" /> | ||
{filter === "ACTIVE" ? _t("Active polls") : _t("Past polls")} | ||
</AccessibleButton> | ||
); | ||
}; | ||
richvdh marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.