Commit Graph

215 Commits

Author SHA1 Message Date
Krzysztof Kotlarek 9062fd9b7a
FIX: improvements for download local dates (#14588)
* FIX: do not display add to calendar for past dates

There is no value in saving past dates into calendar

* FIX: remove postId and move ICS to frontend

PostId is not necessary and will make the solution more generic for dates which doesn't belong to a specific post.

Also, ICS file can be generated in JavaScript to avoid calling backend.
2021-10-14 09:22:44 +11:00
David Taylor 837bd5a6e5
FIX: Fix local-dates in non-post contexts, and in long topics (#14565)
- Stop looking up the topic title from the DOM. On long topics, the topic title may not be present. Instead, we can store the topic title in a data-title attribute during decorateCookedElement, and then access it later. This approach would also allow us to add customize titles per-local-date in future. If there is no topic title available (e.g. when local dates are used elsewhere in the UI), we use the site name to build a sensible default

- Don't require a postId for creating calendar events. We don't have postIds in non-post contexts. At the moment, the 'download ICS' function will fail without a valid postId, so that will need to be fixed in a future commit.
2021-10-08 20:22:52 +01:00
Krzysztof Kotlarek 4285706d97
FIX: local date trim when no time available (#14525)
When there is a blank space in the end of date, moment is returning a different value:

```javascript
  console.log(moment.tz("2021-09-09 ", "Australia/Sydney").toISOString());
  // 2021-09-09T00:00:00.000Z
  console.log(moment.tz("2021-09-09", "Australia/Sydney").toISOString());
  // 2021-09-08T14:00:00.000Z
```
2021-10-06 16:18:32 +11:00
Krzysztof Kotlarek cb5b0cb9d8
FEATURE: save local date to calendar (#14486)
It allows saving local date to calendar.
Modal is giving option to pick between ics and google. User choice can be remembered as a default for the next actions.
2021-10-06 14:11:52 +11:00
Jarek Radosz 62b27ea9f3
DEV: Fix moment warnings (#14482)
When start/end was missing the time component the string passed to `moment()` would have a space at the end. This was causing these warnings:

```
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
```
2021-09-30 22:07:48 +02:00
Mark VanLandingham c9e7b64a64
DEV: Add toolbar button when chat in installed (#14422) 2021-09-22 13:46:06 -05:00
Joffrey JAFFEUX e28a2735bc
FIX: correctly defines data-attributes used by local-dates (#14418)
This was previously relying on data-* being allowed by other initialisers which could cause bugs if local dates ends up being used in other contexts.
2021-09-22 16:49:45 +02:00
Krzysztof Kotlarek 38c3a44bf9
FIX: return empty array when no parent for range (#14386)
If parent element for range does not exists, range calculator should
return empty array. In that case duration calculations will stop because
of:

```
if (_rangeElements(element).length === 2) {
  opts.duration = _calculateDuration(element);
}
```
2021-09-20 16:03:02 +10:00
Krzysztof Kotlarek 82b7e34f30
FEATURE: local dates range on click (#14355)
This PR is introducing 2 changes.
1. Date popup is displayed on click instead on hover
2. If the range is given then the whole range is always displayed for both startDate and endDate
3. For range, short time is displayed for end if the range is < 24 hours
2021-09-20 09:23:18 +10:00
Robin Ward 09764291b1 FIX: In test mode, initializers were modifying classes over and over
This adds a new property, `pluginId` which you can pass to `modifyClass`
which prevent the class from being modified over and over again.

This also includes a fix for polls which was leaking state between tests
which this new functionality exposed.
2021-09-02 11:22:01 -04:00
Joffrey JAFFEUX 4ca34940d3
DEV: ensures container is not destroyed before showing tooltip (#13992)
In fast tests it could results in an error.
2021-08-10 11:48:31 +02:00
Joffrey JAFFEUX 11668ee85b
PERF: generates dates tooltip on demand (#13944) 2021-08-04 16:28:07 +02:00
Joffrey JAFFEUX d23c0c06c3
PERF: reduces rendering time of local-dates (#13931)
- prefers insertAdjacentHTML over innerHTML as it's much faster in this case (about 5x)
- memoizes tz.guess()
- memoizes list of timezones
- inlines template
- applies main element class in one pass

All in all for a very edge case of about 80 dates it should be faster of about 15/20ms.
2021-08-04 08:27:22 +02:00
Jarek Radosz aa56e2a758
DEV: Don't use the Ember global (#13535) 2021-06-29 19:54:18 +02:00
Josh Soref 59097b207f
DEV: Correct typos and spelling mistakes (#12812)
Over the years we accrued many spelling mistakes in the code base. 

This PR attempts to fix spelling mistakes and typos in all areas of the code that are extremely safe to change 

- comments
- test descriptions
- other low risk areas
2021-05-21 11:43:47 +10:00
Joffrey JAFFEUX d53307b141
UX: correctly shows outline around focused input time (#12833) 2021-04-26 11:05:46 +02:00
Kris f1d5d2b134
REFACTOR: Convert buttons to flexbox (#11785) 2021-01-27 16:17:08 -05:00
Joffrey JAFFEUX 49f4c75080
FIX: recurring was not working for some cases (eg: hours and unit > 1) (#11657) 2021-01-07 12:21:51 +01:00
Joffrey JAFFEUX 8af6e72675
FIX: ensures recurring works when setting a start date in future (#11587) 2020-12-29 20:11:18 +01:00
Roman Rizzi 142e0ae062
Revert "Revert "DEV: Wrap `Ember.run.debounce`. (#11352)"" (#11509)
* Revert "Revert "DEV: Wrap `Ember.run.debounce`. (#11352)" (#11465)"

This reverts commit aa0d4ea764.

* Correctly debounce onScroll function
2020-12-18 10:18:52 -03:00
Roman Rizzi aa0d4ea764
Revert "DEV: Wrap `Ember.run.debounce`. (#11352)" (#11465)
This reverts commit 8b426431a4.
2020-12-10 16:48:25 -03:00
Roman Rizzi 8b426431a4
DEV: Wrap `Ember.run.debounce`. (#11352)
We want to wrap the `Ember.run.debounce` function and internally call `Ember.run` instead when running tests.

This commit changes discourseDebounce to work the same way as `Ember.run.debounce`.

Now that `discourseDebounce` works exactly like `Ember.run.debounce`, let's replace it and only use `DiscourseDebounce` from now on.

Move debounce to discourse-common to be able to reuse it in different bundles

Keep old debounce file for backwards-compatibility
2020-12-10 11:01:42 -03:00
Robin Ward 76b04afca3
FIX: Local dates showed incorrect timezones with extra whitespace (#11408)
You might wonder why this matters. It turns out in some locales like
French, we replace quotation marks with « and » -- this should likely
not happen before BBCode is parsed but that is not the case for this
plugin. The plugin has code to handle this situation, but it means extra
spaces are inserted around the time zone which breaks it.

This fix allows us to supply extra whitespace and will show the correct
time zone.
2020-12-08 10:57:18 +11:00
Roman Rizzi bbe5d8d5cf
DEV: Sort imports alphabetically (#11382) 2020-12-01 15:31:26 -03:00
Krzysztof Kotlarek dbec3792b7
FIX: pretty text allow list (#10977)
Reword whitelist to allowlist in pretty-text.
This library is used by plugins so we need deprecation notice.
2020-10-28 13:22:06 +11:00
Joffrey JAFFEUX b6492356cb
FIX: removes duplicate “ and adds ‘ and ’ (#11010) 2020-10-23 10:35:43 +02:00
Joffrey JAFFEUX 6811902a70
FIX: converts “ and ” to " in local dates (#10987) 2020-10-21 17:16:36 +02:00
Joffrey JAFFEUX f4842ae283
FIX: attempts to convert french quotes to regular quotes in dates (#10986) 2020-10-21 16:36:51 +02:00
Joffrey JAFFEUX 7b34433fc2
REVERT: revert change from action + mut to mut (#10844)
* Revert "FIX: fixes regression where wizard dropdown couldn't update (#10838)"

This reverts commit e3b2fc6074.

* Revert "DEV: replaces unecessary (action (mut .*)) by (mut .*) (#10822)"

This reverts commit c0350dc362.
2020-10-06 23:50:05 +02:00
Joffrey JAFFEUX c0350dc362
DEV: replaces unecessary (action (mut .*)) by (mut .*) (#10822) 2020-10-06 17:17:45 +02:00
Joffrey JAFFEUX e6821fbaae
DEV: fixes linting of hbs files in core plugins (#10820) 2020-10-05 14:42:36 +02:00
Joffrey JAFFEUX 2b254f4305
FIX: removes time from date in calendar range at midnight (#10751) 2020-09-28 10:39:21 +02:00
Joffrey JAFFEUX bf88410126
DEV: apply coding standards to plugins (#10594) 2020-09-04 13:51:53 +02:00
Joffrey JAFFEUX 4f7a9802e7
FIX: prefer timezones over timezone for previews (#10506)
eg:

timezone="America/Detroit"
timezones="US/Eastern"

Before this commit we would show America/Detroit in previews and not US/Eastern, given US/Eastern and America/Detroit are equivalent.

After this commit, we will display the date with America/Detroit but show US/Eastern in the previews.
2020-08-21 16:31:50 +02:00
Penar Musaraj 14eec43889
DEV: Use CSS custom properties for colors in core plugins 2020-08-04 11:14:33 -04:00
Joffrey JAFFEUX b2a2e4f1e5
FIX: ensures seconds are displayed when used with dates (#10170) 2020-07-06 09:26:31 +02:00
Jarek Radosz 26260d50b1
DEV: Import `I18n` in standard plugins (#10098) 2020-06-22 02:36:45 +02:00
Joffrey JAFFEUX e990d8adce
FIX: ensures preview is correctly computing timezone for current user (#9758)
This also fixes a related bug with timezones on displayed date when in calendar range.
2020-05-12 12:30:41 -07:00
Joffrey JAFFEUX 1dd9df9cd0
REFACTOR: removes overwritten properties and duplicates fn (#9686) 2020-05-07 16:39:53 +02:00
Joffrey JAFFEUX 2f714c7412
FIX: end date of ranges in html preview was incorrect (#9654)
This commit also remove an unused block of code as previewedTimezones can't be empty anymore.
2020-05-06 17:16:36 +02:00
Joffrey JAFFEUX 6171141211
UX: displays full date time when displaying ranges (#9386) 2020-04-08 10:44:06 +01:00
Joffrey JAFFEUX 6d0ba74b98
UX: Ensures timezone is used over localTimezone when displaying dates 2020-04-08 10:43:47 +01:00
Joffrey JAFFEUX 66d375cb1d
UX: display zones without prefix to reduce noise (#9383) 2020-04-08 11:02:00 +02:00
Joffrey JAFFEUX 25f95af418
REFACTOR: local dates to improve reliability with DST and recurrence (#9379)
This commit improves testing and separates local-date generation from dates with zone manipulations.
2020-04-08 08:53:21 +02:00
Joffrey JAFFEUX 6c2717eda0
UX: ensures esc key is correctly working when in dates form (#9299)
1 esc close modal focus date button in toolbar
2 esc reduces composer
2020-03-30 17:59:25 +02:00
Joffrey JAFFEUX 6102c287f7
FIX: prevents i18n helper to return a SafeString (#9191)
For convenience the i18n helper has been made returning a SafeString, but when used with other helpers, a String is expected and will cause unexpected behaviors.

This is the root cause of the initial bug fixed in d2bb127e2c

This commit is kept as it's a better security in case of unexpected behavior.
2020-03-12 16:50:20 +01:00
Joffrey JAFFEUX 4e0b2ae294
DEV: defines a constant for INPUT_DELAY (#9169) 2020-03-11 15:28:16 +01:00
Robin Ward a3f0543f99
Support for transpiling `.js` files (#9160)
* Remove some `.es6` from comments where it does not matter

* Use a post processor for transpilation

This will allow us to eventually use the directory structure to
transpile rather than the extension.

* FIX: Some errors and clean up in confirm-new-email

It would throw an error if the webauthn element wasn't present.
Also I changed things so that no-module is not explicitly
referenced.

* Remove `no-module`

Instead we allow a magic comment: `// discourse-skip-module` to prevent
the asset pipeline from creating a module.

* DEV: Enable babel transpilation based on directory

If it's in `app/assets/javascripts/dicourse` it will be transpiled
even without the `.es6` extension.

* REFACTOR: Remove Tilt/ES6ModuleTranspiler
2020-03-11 09:43:55 -04:00
Joffrey JAFFEUX 683cb28099
DEV: enforces ember-template-lint: no-triple-curlies (#9165)
This pr replaces `{{{ }}}` usage by a {{html-safe}} helper. While it doesn't solve the underlying issue, it gives us a path forward without risking breaking too much existing behavior.

Also introduces an htmlSafe computed macro:

```
import { htmlSafe } from "discourse/lib/computed";

htmlDescription: htmlSafe("description")
```

Overtime {{html-safe}} usage should be removed and moved to components properties or specialized components/helpers.
2020-03-11 09:23:10 +01:00
romanrizzi f795c1b8e8 Revert "DEV: enforces ember-template-lint: no-triple-curlies (#9150)"
This reverts commit d436b600fb.

Triple curlies are still necessary for some raw templates.
2020-03-10 15:00:12 -03:00
Joffrey JAFFEUX d436b600fb
DEV: enforces ember-template-lint: no-triple-curlies (#9150)
This pr replaces `{{{ }}}` usage by a {{html-safe}} helper. While it doesn't solve the underlying issue, it gives us a path forward without risking breaking too much existing behavior.

Also introduces an htmlSafe computed macro:

```
import { htmlSafe } from "discourse/lib/computed";

htmlDescription: htmlSafe("description")
```

Overtime {{html-safe}} usage should be removed and moved to components properties or specialized components/helpers.
2020-03-10 16:46:57 +01:00
Joffrey JAFFEUX f1bb1db354
DEV: enforces ember-template-lint: no-unbound (#9147)
From ember-template-lint documentation (https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-unbound.md):

```
{{unbound}} is a legacy hold over from the days in which Ember's template engine was less performant. Its use today is vestigial, and it no longer offers performance benefits.

It is also a poor practice to use it for rendering only the initial value of a property that may later change.
```

Co-Authored-By: Jarek Radosz <jradosz@gmail.com>
2020-03-09 15:28:31 +01:00
Jarek Radosz 48ba65f406
DEV: Clean up Ember imports (#8979)
Includes:
* Import `computed` helpers
* Import `@ember/application`
* Import `isBlank` from `@ember/utils`
* Import `A` from `@ember/array`
* Import `EmberArray` from `@ember/array`
* Import `ArrayProxy` from `@ember/array/proxy`
* Import `warn` from `@ember/debug`
* Import `EmberObject` from `@ember/object`
* Import `Application` from `@ember/application`
* Import `EmberRouter` from `@ember/routing/router`
* Import `isPresent` from `@ember/utils`
* Import `computed` from `@ember/object`
* Import `guidFor` from `@ember/object`
* Import `isArray` from `@ember/array`
* Import `TextField` from `@ember/component`
* Import `TextArea` from `@ember/component`
* Import `Promise` from `rsvp`
* Import `Evented` from `@ember/object/evented`
* Replace deprecated `ember-addons/ember-computed-decorators` imports
2020-03-06 23:49:28 +01:00
Penar Musaraj 6be685ac67 DEV: Find/replace deprecated decorators 2020-02-19 11:49:56 -05:00
Kris de559f3fe3 FIX: Remove border-box from modal-body to avoid iOS fixed position bug 2020-02-19 11:08:15 -05:00
Joffrey JAFFEUX 0431942f3d
DEV: select-kit 2 (#7998)
This new iteration of select-kit focuses on following best principales and disallowing mutations inside select-kit components. A best effort has been made to avoid breaking changes, however if you content was a flat array, eg: ["foo", "bar"] You will need to set valueProperty=null and nameProperty=null on the component.

Also almost every component should have an `onChange` handler now to decide what to do with the updated data. **select-kit will not mutate your data by itself anymore**
2020-02-03 14:22:14 +01:00
Jarek Radosz fe588cc7f8
DEV: Fix function prototype deprecations (#8681)
* DEV: Fix the function prototype observers deprecation

DEPRECATION: Function prototype extensions have been deprecated, please migrate from function(){}.observes('foo') to observer('foo', function() {}). [deprecation id: function-prototype-extensions.observes] See https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-observes for more details.

* DEV: Fix the function prototype event listeners deprecation

DEPRECATION: Function prototype extensions have been deprecated, please migrate from function(){}.on('foo') to on('foo', function() {}). [deprecation id: function-prototype-extensions.on] See https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-on for more details.

* DEV: Simplify `default as` imports

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2020-01-16 18:56:53 +01:00
Joffrey JAFFEUX cfa6ec8034
FIX: improves recurring by ensuring DST is computed correctly (#8410) 2019-11-25 23:32:24 +01:00
Joffrey JAFFEUX c498780479
FIX: prevents exception and more duplicates (#8396) 2019-11-22 19:43:37 +01:00
Joffrey JAFFEUX a40bc1e92b
FIX: prevents timezone to show duplicated zones in preview
It could happen if you have Etc/UTC in default settings, and timezone="UTC" on date, the equality check is now more strict.
2019-11-22 17:14:27 +01:00
Joffrey JAFFEUX 3d1b6b6729
FIX: handle german quotes in discourse local-dates (#8386)
https://meta.discourse.org/t/insert-date-timezone-is-always-utc-my-timezone-is-ignored/126307
2019-11-21 11:43:35 +01:00
Joffrey JAFFEUX e6442a2d2f
FIX: we don't need to refresh dates so often (#8367) 2019-11-18 10:04:07 +01:00
Joffrey JAFFEUX 45648e46ba
FIX: attempts to be correct about dst when using recurrence (#8366) 2019-11-18 10:02:58 +01:00
Robin Ward da04c602ba REFACTOR: Remove `debounce` to `discourseDebounce`
Otherwise it can be confused with the ember debounce
2019-11-11 13:34:01 -05:00
Kris b066a4128d Adding a text-overflow: ellipsis; mixin and related cleanup 2019-11-06 14:00:29 -05:00
Jarek Radosz d43e7354ec
DEV: Convert <button> tags to {{d-button}} components (#8224)
* DEV: Convert <button> tags to {{d-button}}

* Fixes
2019-11-04 11:23:54 +01:00
Robin Ward 90f934a660 REFACTOR: Use a module for `Ember.isEmpty` 2019-11-01 13:50:15 -04:00
Robin Ward 8d34f4bbd9 Revert "Revert Ember.run refactors"
This reverts commit fcb1ca52f9.
2019-10-30 09:48:24 -04:00
Robin Ward fcb1ca52f9 Revert Ember.run refactors
This reverts commit 5ca60fcb6b.
2019-10-29 17:10:47 -04:00
Robin Ward 5ca60fcb6b REFACTOR: Use imports for `Ember.run` 2019-10-29 15:31:56 -04:00
Robin Ward a8a76198b1 REFACTOR: Remove `Ember.Component` global variable
Use imports instead.
2019-10-23 12:30:52 -04:00
Joffrey JAFFEUX bf05a8da96
FEATURE: adds countdown attribute to [date] (#8037)
When used, dates will be displayed as a countdown in a human friendly way.
2019-08-24 11:39:20 -05:00
Joffrey JAFFEUX f4543ff02a
FIX: ensures pikaday picker is showing in UTC (#7968) 2019-08-06 08:41:38 +02:00
Gerhard Schlager a68d8de72f UX:UX: Use shorter weekday labels in local-dates plugin 2019-08-05 14:21:59 +02:00
Joe a0df4c3757
UX: prevents cooked dates from wrapping (#7954) 2019-07-30 14:04:30 +08:00
Joffrey JAFFEUX 32cd9ba59b
FIX: ensures local-dates modal is not taking full height on mobile (#7772) 2019-06-16 08:48:07 +02:00
Robin Ward c322cccd53 FIX: Memory Leaks when decorating posts (#7749)
* Remove long-deprecated method

* FIX: Memory Leaks when decorating posts

Previously we'd keep creating mixins dynamically when decorating the
same class.

This code changes the API to recommend an `id` parameter for each
decorator which will avoid leaks. All plugins should be updated to
include this parameter, although if they don't in the meantime it'll
just mean a warning in the console (and a continued leak.)
2019-06-11 17:21:23 +02:00
Régis Hanol 84e5d58a0d DEV: make prettier 💅 happy 2019-06-06 12:28:41 +02:00
Régis Hanol c131903e56 FIX: clone dateTime before changing timezone 2019-06-06 11:16:58 +02:00
Joffrey JAFFEUX bfea922167
DEV: global s/this.get\("(\w+)"\)/this.$1 (#7592) 2019-05-27 10:15:39 +02:00
Joffrey JAFFEUX f3a346464e
FIX: allTimezonesd was mistakenly removed (#7513) 2019-05-09 10:22:54 +02:00
Joffrey JAFFEUX 5c8213ffd3
removes debugging statement (#7362) 2019-04-11 15:02:38 +02:00
Joffrey JAFFEUX 7dd684744c
UX: sets min date on calendar when initial date is set (#7361) 2019-04-11 14:37:39 +02:00
Joffrey JAFFEUX 46dc38e5a5
UX: minor local-dates form improvements (#7360) 2019-04-11 14:03:53 +02:00
Joffrey JAFFEUX 7226240df3
UX: full revamp of local-dates form (#7357) 2019-04-11 11:14:34 +02:00
Joffrey JAFFEUX ad5edc8bb1
UX: copy and formating improvements to local-dates form (#7343) 2019-04-09 10:33:01 +02:00
Joffrey JAFFEUX 5e68c5f851
UX: moves local-dates from popupMenu to toolbar (#7335) 2019-04-08 15:52:09 +02:00
Joffrey JAFFEUX b360d4289e
UX: get rid of preview_for (#7314) 2019-04-03 10:09:25 +02:00
Joffrey JAFFEUX 02d8931425
UX: more compact local-dates preview (#7305) 2019-04-02 14:39:20 +02:00
Joffrey JAFFEUX d81f3ee2c2
FIX: improves DST support of dates when recurrence is used (#7297) 2019-04-01 12:19:09 +02:00
Joffrey JAFFEUX 9a56b398a1
UX: improves local-dates form (#7268) 2019-03-28 16:34:56 +01:00
Joffrey JAFFEUX 4874cf742b
FIX: better styling with popover (#7259) 2019-03-26 16:34:27 +01:00
Joffrey JAFFEUX 52332ccd72
FIX: uses aria-label instead of title as it's useless with popover (#7258) 2019-03-26 16:31:48 +01:00
Joffrey JAFFEUX 8fb63b2706
FEATURE: unified popover implementation (#7244) 2019-03-26 15:43:27 +01:00
Robin Ward 34b871a86c Missing translation key 2019-03-19 12:51:10 -04:00
Penar Musaraj 9bf11a7c02
FEATURE: Add localized timezone names (#7004)
Uses github.com/discourse/moment-timezone-names-translations to translate timezone names.
Plugins can also provide their own timezone name translations.
2019-02-25 14:40:02 -05:00
Joffrey JAFFEUX c08b2ddecf
FIX: stricter matching on local-dates (#7023) 2019-02-18 22:39:45 +01:00
Penar Musaraj ba5e17a7a9 FIX: IE11 layout glitches
IE11 requires a unit on the third parameter (flex-basis) of the flex property
2019-01-21 13:40:55 -05:00
Penar Musaraj 78730062de Fix prettier offence in local-dates plugin 2019-01-17 14:22:35 -05:00
Joffrey JAFFEUX 9703fa2abc
UX: improves dates display in emails (#6805) 2019-01-16 12:53:41 +01:00