Commit Graph
160 Commits
Author SHA1 Message Date
Jarek RadoszandGitHub 5308a42ab2 DEV: Replace remaining uses of query helper (#30019) 2025-01-22 00:25:03 +01:00
David TaylorandGitHub fc0e1f109d DEV: Run prettier correctly for bundled-plugin test directories (#30338) 2024-12-18 12:02:28 +00:00
Jarek RadoszandGitHub 09bfc5ec71 DEV: Finish qunit-dom hasText migration (#30017) 2024-12-01 14:00:48 +01:00
Jarek RadoszandGitHub 2ae246e9ad DEV: Extensively use qunit-dom's hasText (#30012) 2024-11-30 16:44:51 +01:00
Jarek RadoszandGitHub 9d517c8118 DEV: Fix no-loose-assertions lint (#29965)
and enable some of qunit lints
2024-11-28 11:22:27 +01:00
ead4819fe4 DEV: lint poll test (#29937)
Co-authored-by: David Taylor <[email protected]>
2024-11-26 16:22:33 +01:00
Joffrey JAFFEUXandGitHub 912ea9ed84 DEV: ensures poll-test is correctly linted (#29936)
Broken in https://github.com/discourse/discourse/commit/83cdff37b3ca9f3254bca8d8d1deae949ccaa3df
2024-11-26 14:18:30 +01:00
RobertandGitHub 83cdff37b3 FIX: Poll: ensure it is not possible to vote with all abstentions in Ranked Choice (#29601)
Make sure Cast Vote button is disabled when all abstain and remove any historic data that fails new zero rank vote validation
2024-11-26 20:16:22 +08:00
David TaylorandGitHub 49cc33b355 DEV: Consolidate i18n import paths (#29804)
Enables our new eslint rules which enforce consistent i18n imports. For more info, see https://github.com/discourse/lint-configs/commit/0d58b40cd7d170a9f70bcef5c173f95eeb498298
2024-11-19 20:45:18 +00:00
Jarek RadoszandGitHub 6c5ab2c6ec DEV: Use qunit-dom's isDisabled/isEnabled (#29675) 2024-11-10 02:24:58 +01:00
Jarek RadoszandGitHub b3d4b1050a DEV: Replace count with qunit-dom (#29674) 2024-11-10 02:06:03 +01:00
Jarek RadoszandGitHub 906f24b93c DEV: Convert all uses of exists to qunit-dom (#29667) 2024-11-10 01:30:33 +01:00
Jarek RadoszandGitHub 2910c9acf5 DEV: Convert assert.true(exists()) to qunit-dom (#29638) 2024-11-08 20:27:32 +01:00
RobertandGitHub 5ba6d8cd77 FIX: poll ranked choice results not showing on first vote (#28542)
Currently (for Ranked Choice only) a javascript exception is raised on very first vote, preventing the results from being rendered requiring a browser refresh (which doesn't error).

Resolves: TypeError: this.args.rankedChoiceOutcome.round_activity is undefined with simple addition of optional chaining operator.
2024-11-05 09:29:07 +08:00
RobertandGitHub 5e0ca6c17a FIX: poll ranked choice voter expansion should append additional voters (#28432)
Currently, for Ranked Choice results and voter list expansion, the code is replacing the voter list with the newly fetched page of voters instead of appending to the existing voter list. This is resolved in this PR and brings it in line with regular polls.

See: https://meta.discourse.org/t/ranked-choice-poll-does-not-reflect-change-of-votes-in-outcome/321227/18
2024-11-05 09:28:32 +08:00
Jarek RadoszandGitHub 0c207c8bad DEV: Update more asserts to qunit-dom (#29326)
regex find&replace + removing now-unused imports + manually fixing incorrect css selectors (that now got flagged 😌) + manually updating selectors that relied on jq
2024-10-22 11:34:23 +02:00
Jarek RadoszandGitHub a5a92152cc DEV: Convert more test assertions to qunit-dom (#29214)
the PR is sponsored by vscode's regex support in find-and-replace 😉
2024-10-15 17:11:20 +02:00
0d3b9f247e DEV: remap all core icons for fontawesome 6 upgrade (#28715)
Followup to 30ac4e8bb2

Co-authored-by: David Taylor <[email protected]>
2024-09-13 16:50:52 +01:00
David TaylorandGitHub be28589cc0 DEV: Remove widget wrapper from poll plugin (#28666)
- Uses `helper.renderGlimmer` with GJS to render the `<Poll` component without any widgets

- Moves some logic into component, so that only `@post`, `@poll` and `@titleHTML` need to be passed into the component (no more 'attrs')

- Updates `modifyClass` calls to modern syntax

- Replaces observer in `Post` model with a native setter & tracked property

- Replaced Poll EmberObject instances with TrackedObject

- Updated component tests with new arguments

- Updated some tests to qunit-dom

- Fixed up core `repliesBelow` and `repliesAbove` logic to create post models properly. Previously it was passing 'transformed' versions of posts into the model, which doesn't make sense.
2024-09-04 09:38:22 +01:00
Joffrey JAFFEUXandGitHub 9d894fcf57 UX: explain choices priorities (#28574)
This commit will add `highest priority` to first choice and `lowest priority` to the last choice to make it more explicit to the user.
2024-08-27 13:03:48 +02:00
RobertandGitHub d851e0ad66 FIX: make poll voter list expansion persistent (#28352)
* FIX: voter list expansion

* naming improvement

* extend and refine test
2024-08-19 15:55:22 +10:00
RobertandGitHub 9501c90dce FIX: poll when config is on_close only show results when poll is closed (#28299)
See: https://meta.discourse.org/t/cant-edit-topic-with-poll-bug-occurs/320845?u=merefield

When the Poll is set to "results ON_CLOSE", vote numbers for each option are only streamed to the browser when the vote is Closed. It is therefore not possible to render the Results.

The current issue is that when you refresh the page, for those that have voted the default view is results. For this type of poll this should NOT happen. The Results view in this mode should not be possible to see until closure, even for the Author.

Because the votes are not yet serialised when this kind of poll remains open, an attempt to display results causes a JavaScript exception and in any case does not make logical sense.

So the fix here is making sure the default view, for Polls that have results on close, is the voting view until the Poll is Closed.

I've added a test to cover this scenario.

Additionally, this requires a refresh of the page when the poll admin actions a Close to ensure the results are serialized in.
2024-08-13 09:29:16 +02:00
RobertandGitHub f66ce4db03 FIX: poll ranked choice voter list corrupting on expand (#28315)
Initially, the poll results display a maximum of 25 voters per option. If the number of voters exceeds this limit, a button allows users to load additional pages of voters.

When this button is clicked, a method is called to retrieve the additional voter information. However, there was a bug where the local tracked object was not properly updated for ranked choice voters. This is due to the existence of two attributes per option: one indicating whether new data is currently loading, and the other containing the list of voters.

Instead of updating the entire option key with the voters list, the fix requires updating the voters attribute only.

This is a small but critical change. The pull request also includes a new test that significantly increases coverage, addressing this issue and beyond.
2024-08-13 09:28:28 +02:00
锦心andGitHub a3946acc0e FEATURE: Absolute Numbers in Poll (#28240)
What does this add?
===================

This PR adds an extra button to the poll to show the absolute number of
people who voted for each option. This button will only be added for
the single/multi-select bar chart.

Related meta topic: https://meta.discourse.org/t/absolute-numbers-in-polls/32771
2024-08-07 11:46:29 +02:00
RobertandGitHub 90577a9caa DEV: poll flakey spec 2024-08-06 08:39:03 +02:00
RobertandGitHub 73c676b41d FIX: update voter information upon remote change (#28168)
Fixes issue with polls not being fully updated by remote vote contributions in (semi-) real-time.

This was down to too great a focus on tracking local state and not accommodating a more data down approach with responsive getters.

This is now implemented.

I've tried hard to minimise the changes whilst making sure the paradigm is properly followed through.
2024-08-02 08:50:33 +02:00
Jarek RadoszandGitHub 5d8ddf8f4b DEV: Clean up imports (#28060)
* `@ember/owner` instead of `@ember/application`
* `discourse-i18n` instead of `I18n`
* `{ service } from "@ember/service"` instead of `inject as service`
2024-07-25 15:09:06 +02:00
b1b3744fbe FEATURE: Add Ranked Choice Voting
using Instant Run-off Voting algorithm to Poll Plugin (Part 2 add Ranked Choice)

---------

Co-authored-by: Joffrey JAFFEUX <[email protected]>
Co-authored-by: Jarek Radosz <[email protected]>
2024-07-17 11:49:14 +02:00
RobertandGitHub 959c98c565 FIX: Poll: Show gear button only when there is more than one dropdown item (#27775)
During migration of Poll plugin from widget basis to glimmer, some functionality was inadvertently dropped:

- A single button should appear instead of the dropdown menu when there is only one valid "poll admin" action
- No button should appear when there are no valid "poll admin" actions for current user

This PR restores the original behaviour and adds test coverage (that didn't exist prior to migration, partly why it wasn't caught earlier)

relates to #27204

related meta topic:  https://meta.discourse.org/t/what-is-the-gear-button-under-the-poll-for/315477/2
2024-07-11 11:19:04 +08:00
241399bba9 DEV: Check for poll element presence (#27765)
Fixes a flaky test. `afterUpdate` from chart.js is not integrated with the runloop and component lifecycle, as a result we have no guarantee on when it will happen. The easiest change we can do for now is ensuring we actually have the DOM we expect to have, and if not, we exit early.


Co-authored-by: Joffrey JAFFEUX <[email protected]>
Co-authored-by: merefield <[email protected]>
2024-07-08 13:58:35 +02:00
Alan Guo Xiang TanandGitHub 309ad24963 DEV: Skip flaky polls acceptance test (#27757)
Example of flakiness: https://github.com/discourse/discourse/actions/runs/9831645793/job/27139325323
2024-07-08 09:11:38 +08:00
RobertandGitHub 2c264970ed FIX: Allow safe html in poll options (#27741) 2024-07-07 15:08:00 +02:00
RobertandGitHub 5d564b8335 FIX: Poll: critical display issue when results are only shown upon vote (#27732) 2024-07-05 10:55:14 +02:00
Alan Guo Xiang TanandGitHub 45429d0e4e DEV: Skip flaky poll QUnit acceptance tests (#27728)
The skipped tests have become flaky after
674db4d059, skip those tests for now while
we sort things out.
2024-07-05 10:59:51 +08:00
RobertandGitHub 2440d5e119 FIX: Poll: do not attempt to show voter list on private polls (#27714)
* FIX: avoid attempting to enrich results with undefined voters
2024-07-04 18:20:37 +02:00
RobertandGitHub 674db4d059 FEATURE: Add Instant Run-off Voting to Poll Plugin (Part 1: migrate existing plugin to Glimmer only) (#27204)
The "migration to Glimmer" has been broken out here from #27155 to make the review process less onerous and reduce change risk: 

* DEV: migrates most of the widget code to Glimmer in prep for IRV additions
* NB This already incorporates significant amounts of review and feedback from the prior PR.
* NB because there was significant additional feedback relating to older Poll code that I've improved with feedback, there are some additional changes here that are general improvements to the plugin and not specific to IRV nor Glimmer!
* There should be no trace of IRV code here.

Once this is finalised and merged we can continue to progress with #27155.
2024-07-04 13:34:48 +02:00
Jarek RadoszandGitHub 4e72f78874 DEV: Convert some tests to qunit-dom (#27577)
(and fix two test bugs)
2024-06-23 22:34:15 +02:00
Martin BrennanandGitHub cc9fa6039a DEV: Move core plugin TL -> group settings (#25355)
* DEV: Change poll_minimum_trust_level_to_create to group based setting

New setting is poll_create_allowed_groups

c.f. https://meta.discourse.org/t/changes-coming-to-settings-for-giving-access-to-features-from-trust-levels-to-groups/283408

* DEV: Move styleguide_admin_only to group based setting

Not exactly a TL -> group change, but still part of the
overall effort here:

https://meta.discourse.org/t/changes-coming-to-settings-for-giving-access-to-features-from-trust-levels-to-groups/283408

New setting is styleguide_allowed_groups
2024-01-23 11:35:14 +10:00
David TaylorandGitHub a32f754b08 FEATURE: Configure poll 'public' default via site setting (#24348)
Followup to 7afebcd78e
2023-11-13 18:54:21 +00:00
David TaylorandGitHub 7afebcd78e UX: Create polls with public=true by default (#24332)
In the vast majority of cases, people want poll voters to be public. Previously, the checkbox for this was hidden behind the 'show advanced' settings in the poll builder UI.

This commit makes three changes to improve the experience:

1. Add `public=true|false` to poll markup (previously it would only be added when true

2. Bring the 'public' switch outside the 'show advanced' section for improved visibility

3. Change the default to 'true'
2023-11-13 09:07:51 +11:00
Godfrey ChanandGitHub 3995dab9a1 DEV: Rename I18n imports to discourse-i18n (#23915)
As of #23867 this is now a real package, so updating the imports to
use the real package name, rather than relying on the alias. The
name change in the package name is because `I18n` is not a valid
name as NPM packages must be all lowercase.

This commit also introduces an eslint rule to prevent importing from
the old I18n path.

For themes/plugins, the old 'i18n' name remains functional.
2023-10-18 11:07:09 +01:00
David Taylor b3015f51ca DEV: Sort imports
Automatically generated by `eslint --fix` to satisfy the updated configuration
2023-10-10 21:46:54 +01:00
Alan Guo Xiang TanandGitHub f04e3e0064 DEV: Improve addToolbarPopupMenuOptionsCallback plugin api (#23769)
Why this change?

Previously just using the `addToolbarPopupMenuOptionsCallback` plugin
API itself was insufficient because it required the return object to
include an `action` key which only accepted a name of the action
function as a string. This was highly problematic because the action
function had to be defined on the `composer` service which means using
the `modifyClass` API to add the action function. This made the API
awkward to use leading to poor developer experiencec.

What does this change do?

This commit introduces a couple of improvemnts to the API.

1. First the API has been renamed to `addComposerToolbarPopupMenuOption` because
   the API no longer accepts a callback function which was quite
   redundant. Instead, it now accepts an Object. The
   `addToolbarPopupMenuOptionsCallback` API function is deprecated and
   will be dropped in Discourse 3.3. Note that passing the API a
   function is still supported but will be dropped when the `addToolbarPopupMenuOptionsCallback`
   is removed.

2. The `action` key in the Object passed to the function can now be a
   function and is passed the `toolbarEvent` object when called.

3. The `condition` on key in the Object passed to the function can now be a
   function and is passed the `composer` service when called.
2023-10-06 07:43:40 +08:00
Jarek RadoszandGitHub 1e9b95607e DEV: Fix poll-results tests (#23518)
`/t/-/load-more-poll-voters` is not a valid app path

(valid ones would be `/t/load-more-poll-voters/134` or `/t/-/134`)
2023-09-12 07:41:56 +08:00
Jarek RadoszandGitHub 54fe8ab586 DEV: Fix setting-on-hash deprecation (#23506)
```
deprecate-shim.js:33 DEPRECATION: You set the 'hasSavedVote' property on a {{hash}} object. Setting properties on objects generated by {{hash}} is deprecated. Please update to use an object created with a tracked property or getter, or with a custom helper. [deprecation id: setting-on-hash]
```
2023-09-11 16:15:44 +02:00
KrisandGitHub 0905132550 REFACTOR: improve poll info layout (#22353) 2023-07-05 12:20:18 -04:00
David TaylorandGitHub c7172ab9eb DEV: Convert poll modals to new component-based API (#22164) 2023-07-04 15:25:34 +01:00
David Taylor 880f469982 DEV: Modernize poll JS directory structure and colocate components 2023-06-16 18:16:31 +01:00
David TaylorandGitHub e6c30937c8 DEV: Load plugin CSS in tests (#18668) 2022-10-19 18:10:06 +01:00
Jarek RadoszandGitHub 159640237a DEV: Modernize controller unit tests (#17412)
Aligns controller tests with the Ember standard, by using `module` and `setupTest` instead of our custom `discourseModule`)
2022-10-14 13:15:58 +02:00