Commit Graph
123 Commits
Author SHA1 Message Date
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
David TaylorandGitHub 3ca517d629 FIX: Ensure poll type toggle buttons function correctly (#18540)
Followup to 249d8c49d6
2022-10-11 11:20:18 +01:00
Jarek RadoszandGitHub 918dade319 DEV: Consistently use response helper (#17627) 2022-07-25 02:31:52 +02:00
Jarek RadoszandGitHub e22bd45102 DEV: Always await for publishToMessageBus (#17626)
(+ typos)
2022-07-24 19:55:58 +02:00
Jarek RadoszandGitHub 49af4e0743 DEV: Fix pretender in poll tests (#17587) 2022-07-21 10:53:21 +02:00
Jarek RadoszandGitHub 5ffaf419d1 DEV: Remove most of jQuery usage from tests (#17474) 2022-07-13 19:29:19 +02:00
Jarek RadoszandGitHub 25275daca9 DEV: Modernize component tests (#17368)
* Use QUnit `module` instead of `discourseModule`
* Use QUnit `test` instead of `componentTest`
* Use angle-bracket syntax
* Remove jQuery usage
* Improve assertions (and actually fix some of them)
2022-07-11 12:29:44 +02:00
8c7d70a665 DEV: Update linting setup and fix issues (#17345)
Re-lands #16119 and #17298

* Update eslint-config-discourse
* Update linting workflow
* Prettier-ignore stuff
* Update template-lint config
* Auto-fix template issues
* Fix various template issues
  Mostly incorrect attributes and unused templates
* Prettier js files
* Fix template auto-fix regressions
* Small css tweak

Co-authored-by: Peter Wagenet <[email protected]>
2022-07-06 10:37:54 +02:00
Alan Guo Xiang Tan 676b4d4bc4 FIX: Disable cast votes button for multiple polls with no min.
Multiple polls can be created without the min attribute but that means
the attribute defaults to 1. A default of 0 does not make any sense
because it is equivalent to saying that a user is not casting any votes.
2022-01-10 10:03:17 +08:00
Jarek RadoszandGitHub e2ff41c70f DEV: Fix linting issues in core plugins (#14916) 2021-11-13 15:31:42 +01:00
Jarek RadoszandGitHub 1618979936 DEV: Remove .es6 extensions from core (#14912)
Still supported in plugins though.
2021-11-13 12:51:53 +01:00
Jarek RadoszandGitHub 10dc717473 DEV: Replace equal() with strictEqual() (#14827) 2021-11-08 10:26:28 +01:00
Bianca NenciuandGitHub dbc558ee99 FIX: Disable Show results if nobody voted (#14528) 2021-10-06 17:51:46 +03:00
Bianca NenciuandGitHub f08f912bd4 FEATURE: Allow users to remove their vote (#14459)
They can use the remove vote button or select the same option again for
single choice polls.

This commit refactor the plugin to properly organize code and make it
easier to follow.
2021-10-05 11:38:49 +03:00
Martin BrennanandGitHub daa8e67226 FEATURE: Topic-level bookmarks (#14353)
Allows creating a bookmark with the `for_topic` flag introduced in https://github.com/discourse/discourse/commit/a9f5db41b0a49020d96f240c0dc8e0ef779471b3 set to true. This happens when clicking on the Bookmark button in the topic footer when no other posts are bookmarked. In a later PR, when clicking on these topic-level bookmarks the user will be taken to the last unread post in the topic, not the OP. Only the OP can have a topic level bookmark, and users can also make a post-level bookmark on the OP of the topic.

I had to do some pretty heavy refactors because most of the bookmark code in the JS topics controller was centred around instances of Post JS models, but the topic level bookmark is not centred around a post. Some refactors were just for readability as well.

Also removes some missed reminderType code from the purge in https://github.com/discourse/discourse/commit/6fc2b10adf67638044f964b1bf479a00ecd46518
2021-09-21 08:45:47 +10:00
Bianca NenciuandGitHub 6a9c7d119f FEATURE: Let users select flair (#13587)
User flair was given by user's primary group. This PR separates the
two, adds a new field to the user model for flair group ID and users
can select their flair from user preferences now.
2021-07-08 10:46:21 +03:00
Bianca NenciuandGitHub da775f1079 DEV: Do not skip pages when loading polls (#13649)
In some conditions, pages were skipped. This was implemented in the past
in d853592, but then reverted in c10282f, because sometimes it was stuck
reloading the first page.

The code that loads more results was simplified and a lot of duplicate
code was removed. The logic to remove users who changed their vote was
also introduced again, but just for the regular polls.
2021-07-07 13:06:08 +03:00
Régis HanolandGitHub c10282fd58 FIX: Poll wasn't showing all voters (#13620)
Partially revert d853592398 because we aren't able to
load more than the initially preloaded voters.

We were always trying to load the 1st page of voters.

Also removed the "remove users who changed their vote" logic as it was not properly working in multiple choices polls.

cc @nbianca
2021-07-05 13:52:17 +03:00
Alan Guo Xiang TanandGitHub be1a512d0f FEATURE: Add last visit indication to topic view page. (#13471)
This PR also removes grey old unread bubble from the topic badges by
dropping `TopicUser#highest_seen_post_number`.
2021-07-05 14:17:31 +08:00
Robin Ward 06329654bd DEV: Allow plugin tests to run in Ember CLI qunit 2021-06-24 10:13:35 -04:00
Bianca NenciuandGitHub d853592398 FIX: Do not display twice a user who changed vote (#13284)
* FIX: Fetch last page again if incomplete

The next fetched page number used to increase continuously even if the
last page was incomplete and fetching it again could have new voters.

* FIX: Do not display twice a user who changed vote

A user could appear under two voting options when they changed their
vote because pressing the Load More Voters button updated only the
current option.
2021-06-18 18:56:54 +03:00
Robin WardandGitHub 32d3b4ead2 FIX: count is not defined lint error (#13347) 2021-06-09 11:26:26 -04:00
Robin WardandGitHub 378903d2a3 FIX: Lots of plugin tests were using old, non-Ember compat CLI APIs (#13320) 2021-06-09 10:58:55 -04:00
Jarek RadoszandGitHub 5fdab8598d DEV: Clean up QUnit tests (#13328)
* DEV: Use `query` helper instead of `queryAll()[0]`
* DEV: Replace `queryAll().length` w/ `exists()`/`count()`
* DEV: Use `exists()` instead of `count() > 0`, `count() === 0`
* DEV: Use `count()`/`exists()` instead of `find().length`
2021-06-08 17:54:12 +02:00
Bianca NenciuandGitHub 8a062b15e2 UX: Improve poll builder UI (#12549)
* Improve poll validation

* Redesign poll builder

* Group all advanced settings under a new section
2021-04-12 19:48:01 +03:00
0c974352c8 DEV: Migrate to Ember CLI (#11932)
This encompasses a lot of work done over the last year, much of which
has already been merged into master. This is the final set of changes
required to get Ember CLI running locally for development.

From here on it will be bug fixes / enhancements.

Co-authored-by: Jarek Radosz <[email protected]>
Co-authored-by: romanrizzi <[email protected]>

Co-authored-by: Jarek Radosz <[email protected]>
Co-authored-by: romanrizzi <[email protected]>
2021-02-03 14:22:20 -05:00
Andrew PrigorshnevandGitHub a5aeabbe9b FIX: polls extending in post reply histories (#11837)
* Add an acceptance test

* FIX: polls extending in post reply histories
2021-01-26 10:29:49 -05:00
Roman RizziandGitHub 8be7c97a7c DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
Roman RizziandGitHub 1f306826ae DEV: Tidy up imports. (#11364)
Only allow one import definition per file and add a new eslint rule to enforce it.
2020-11-27 11:30:16 -03:00
Robin Ward fb76995f33 FIX: Tests were using jQuery selectors
For the most part `querySelectorAll` will work with jQuery selectors,
but the big exception is `:eq(0)` and similar. Those needed to be
replaced.
2020-11-23 11:36:07 -05:00
Jarek RadoszandGitHub fc946bbf80 DEV: De-arrowify tests (#11068)
Using arrow functions changes `this` context, which is undesired in tests, e.g. it makes it impossible to setup things like pretender (`this.server`) in `beforeEach` hooks.

Ember guides always use classic functions in examples (e.g. https://guides.emberjs.com/release/testing/test-types/), and that's what it uses in its own test suite, as do various addons and ember apps.

It was also already used in Discourse where `this` was required. Moving forward, it will be needed in more places as we migrate toward ember-cli.

(I might later add a custom rule to eslint-discourse-ember to enforce this)
2020-10-30 17:37:32 +01:00
Robin Ward 7fe35bde38 REFACTOR: Replace global find with queryAll
In newer Embers jQuery is removed. There is a `find` but it only returns
one element and not a jQuery selector. This patch migrates our code to a
new helper `queryAll` which allows us to remove the global.
2020-10-29 14:45:51 -04:00
Robin Ward dc0b017174 REFACTOR: Test assertions should be imported.
Previously they were global functions.
2020-10-28 11:39:06 -04:00
Robin Ward 538f69c645 REFACTOR: All remaining acceptance tests converted to new format
Also contains fixes to leaky state in pretender.
2020-10-23 09:28:13 -04:00
Robin Ward f5c325f248 REFACTOR: Move test setup to a module
This is long overdue. We had a lot of (not linted) code to initialize
our test suite as part of the Ruby `test_helper.js` bundle.

This refactor moves that out to a `setup-tests` module, which imports
all the modules properly, rather than using `require`.

It also removes the global `server` variable which some tests were using
for pretender. Those tests are fixed, and in the case of widget tests,
support for a `pretend()` was added, which mimics our acceptance tests.

One problematic test was removed, which overwrites `/posts` - this could
break tons of other tests depending on order.
2020-10-08 15:11:51 -04:00
Jarek RadoszandGitHub 0d7e3d8f9c FIX: Correctly render title-less poll widgets (#10837)
`RawHtml` does not like receiving undefined values as `html`.
2020-10-06 19:27:03 +02:00
Robin Ward d87a3747f6 REFACTOR: Move javascript tests inside discourse app
This is where they should be as far as ember is concerned. Note this is
a huge commit and we should be really careful everything continues to
work properly.
2020-10-02 11:29:36 -04:00
Martin BrennanandGitHub 818a69fa3f FEATURE: Remove user topic timers and migrate to bookmarks with reminders (#10474)
This PR removes the user reminder topic timers, because that system has been supplanted and improved by bookmark reminders. The option is removed from the UI and all existing user reminder topic timers are migrated to bookmark reminders.

Migration does this:

* Get all topic_timers with status_type 5 (reminders)
* Gets all bookmarks where the user ID and topic ID match
* Loops through the found topic timers
  * If there is no bookmark for the OP of the topic, then we just create a bookmark with a reminder
  * If there is a bookmark for the OP of the topic and it does **not** have a reminder set, then just 
update it with the topic timer reminder
  * If there is a bookmark for the OP of the topic with a reminder then just discard the topic timer
* Cancels all outstanding user reminder topic timers
* **Trashes (not deletes) all user reminder topic timers**

Notes:

* For now I have left the user reminder topic timer job class in place; this is so the jobs can be cancelled in the migration. It and the specs will be deleted in the next PR.
* At a later date I will write a migration to delete all trashed user topic timers. They are not deleted here in case there are data issues and they need to be recovered.
* A future PR will change the UI of the topic timer modal to make it look more like the bookmark modal.
2020-09-14 11:11:55 +10:00