Commit Graph

734 Commits

Author SHA1 Message Date
Kevin Ansfield
b402b1643e Prevented throwing errors unnecessarily in editor plus menu and link toolbar
closes sentry Admin-423

- there may be times when the mousemove event handler fires when the document is not in a ready state resulting in an attempt to get a document position that doesn't exist
- should fix `Could not find parent section from element node` errors
2022-12-14 11:57:54 +00:00
Sanne de Vries
9b819698e8 Fixed title attributes on headings in editor toolbar
No ref
2022-12-09 10:10:34 +07:00
Kevin Ansfield
d4ea9c877d Fixed editor key commands throwing errors when range has no section
closes Sentry ADMIN-CC8
closes Sentry ADMIN-DDM
closes Sentry ADMIN-C9F

- there are situations where the editor range when key commands are triggered does not have a head section which then throws errors due to the commands assuming there will always be a section present
- added a guard to key commands that use the head section to abort early and fall back to default Mobiledoc behaviour when the section is missing
2022-11-25 08:56:38 +00:00
Kevin Ansfield
ef71d52ec0 Fixed Cannot read properties of null (reading 'offsetHeight') errors in markdown card
closes sentry ADMIN-CAV

- the mobile nav element is not always displayed so we should assume we can read it's `offsetHeight` property
2022-11-24 12:52:16 +00:00
Kevin Ansfield
3a9209b6a8 Fixed some minor formatting issues
no issue

- indented conditional template code
- grouped tracked properties together
2022-11-22 13:15:08 +00:00
Kevin Ansfield
f25cc00236 Fixed product card throwing "Cannot read properties of undefined (reading 'url')" errors
closes https://github.com/TryGhost/Team/issues/2295

Problem:
- `<GhUploader>` is not yet converted to an Octane component so it's arguments are not read-only
- when a file is selected it sets it's `files` property which in turn updates the tracked `files` property that was passed in, and then again updates it to an empty file list when the input field is cleared
- that tracked property was never cleared once the product image was uploaded resulting in a "re-upload" attempt with an empty file list every time the product card was put back into edit mode

Fix:
- added a guard in `<GhUploader>` so it doesn't try to upload an empty file list if one is passed in as an attribute
- added a reset of the tracked `files` property in the product card once the image upload is complete
2022-11-22 13:13:42 +00:00
Kevin Ansfield
9bdb25d184
Fixed hosting management screen not loading after sign-in process (#15763)
refs https://github.com/TryGhost/Team/issues/2110

- dynamically defined properties on the config service did not have
autotracking set up properly if they were accessed in any way before the
property was defined, this caused problems in a number of areas because
we have both "unauthed" and "authed" sets of config and when not logged
in we had parts of the app checking for authed config properties that
don't exist until after sign-in and subsequent config re-fetch
- renamed `config` service to `configManager` and updated to only
contain methods for fetching config data
- added a `config` instance initializer that sets up a `TrackedObject`
instance with some custom properties/methods and registers it on
`config:main`
- uses application instance initializer rather than a standard
initializer because standard initializers are only called once when
setting up the test suite so we'd end up with config leaking across
tests
- added an `@inject` decorator that when used takes the property name
and injects whatever is registered at `${propertyName}:main`, this
allows us to use dependency injection for any object rather than just
services or controllers
- using `application.inject()` in the initializer was initially used but
that only works for objects that extend from `EmberObject`, the
injections weren't available in native-class glimmer components so this
decorator keeps the injection syntax consistent
  - swapped all `@service config` uses to `@inject config`
2022-11-03 11:14:36 +00:00
Kevin Ansfield
7b443d4b63 Removed need for .get() with config service
no issue

The `config` service has been a source of confusion when writing with modern Ember patterns because it's use of the deprecated `ProxyMixin` forced all property access/setting to go via `.get()` and `.set()` whereas the rest of the system has mostly (there are a few other uses of ProxyObjects remaining) eliminated the use of the non-native get/set methods.

- removed use of `ProxyMixin` in the `config` service by grabbing the API response after fetching and using `Object.defineProperty()` to add native getters/setters that pass through to a tracked object holding the API response data. Ember's autotracking automatically works across the native getters/setters so we can then use the service as if it was any other native object
- updated all code to use `config.{attrName}` directly for getting/setting instead of `.get()` and `.set()`
- removed unnecessary async around `config.availableTimezones` which wasn't making any async calls
2022-10-07 16:14:57 +01:00
Kevin Ansfield
63b1e4e8ad
Resolved power-select related deprecation warnings for loading components by string (#15466)
no issue

- in many places we were passing a string as an argument to a `<PowerSelect>` related component that referred to a component name, that was throwing deprecation warnings because those strings were used dynamically with `{{component}}` later on which isn't statically analyzable
- switched to passing a component explicitly with `{{component}}`
- https://github.com/embroider-build/embroider/blob/main/REPLACING-COMPONENT-HELPER.md#when-youre-passing-a-component-to-someone-else
2022-09-24 17:00:05 +02:00
Kevin Ansfield
a934481f45 Fixed @sentry/browser imports
no issue

- needed for embroider compatibility
- the package we have installed is `@sentry/ember` not `@sentry/browser` so the imports fail when built by webpack
2022-09-24 13:28:35 +02:00
Kevin Ansfield
9bbafc3ccf Deleted unused files
no issue

- files were left over from earlier development and not being used anywhere
2022-09-24 13:27:54 +02:00
Kevin Ansfield
a2f0ccc981 Added audio/x-m4a to allowed mime types in audio card
refs b12400577a

- additional mime type was added to the API's allowed list but was missed in Admin's allowed list
2022-09-14 09:04:58 +01:00
renovate[bot]
1b8dbb132f
Update Test & linting packages (#15338)
* Update Test & linting packages
* Fixed new `no-quoteless-attributes` template lint errors

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
2022-09-13 09:19:14 +01:00
James Morris
dd65c99104 Made longer URLs scrollable on hover for Email CTA and Button modules in the editor
no issue
2022-09-02 18:39:41 +01:00
Sanne de Vries
a2fc31aa0a Cleaned up icon styles
Refs https://www.notion.so/ghost/Unify-icons-across-Admin-7e3d124d5db34c63beccca029af595e7

- Reduced duplicate plus icons
- Replaced fill trash, info and pen icons by stroke icons
- Removed fill styles from default button classes
- Removed launch-wizard css
2022-09-02 16:56:02 +01:00
Kevin Ansfield
0152eeb600 Added capture of product card image width/height
refs https://github.com/TryGhost/Team/issues/1873

- the code for storing the image width/height in the card payload was commented out
- uncommented and renamed to match the payload attr names
2022-09-02 14:44:37 +01:00
Kevin Ansfield
9335b57741 🐛 Fixed line breaks not persisting when used inside email cards
no issue

- we allowed line breaks to be created in the text-replacement html input used inside email cards but they were removed as soon as the card's edit mode was left
- fixed the clean-text-replacement-html routine so `<br>` atoms aren't stripped
- added the soft-return parser to the `<KoenigTextReplacementHtmlInput>` editor options so the `<br>` elements are correctly parsed back into atoms when entering edit mode
2022-08-16 16:56:40 +01:00
arsereg
182a7ea07c
💡 Upgraded Tenor API to v2 (#15087)
closes: https://github.com/TryGhost/Ghost/issues/14980
refs: cc276486f0

- Tenor is now operated by Google, and the old v1 Tenor API has been decommissioned
- At present anyone with a pre-configured tenor integration will get intermittent errors, whilst it is impossible to setup a new tenor API integration
- Sadly old keys do not work with the new API, and new keys do not work with the old API, so there is no happy path forward.
- After this lands, everyone will need to go and get a new Google API Key for Tenor, update their config, and then the integration will work properly again.
- This particular change renames the API key from `publicReadOnlyApiKey` to `googleApiKey` to reflect that the key itself changes in type and behaviour

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
2022-08-05 12:13:27 +01:00
arsereg
cc276486f0 Updated Tenor API to v2 (#2418)
refs: https://github.com/TryGhost/Ghost/issues/14980
refs: https://github.com/TryGhost/Ghost/pull/15087

- The Tenor v1 API has been decommissioned https://developers.google.com/tenor/guides/migrate-from-v1
- Updated the API to v2, but there are some differences we have to account for 
- Swapped from using the old "trending" API to the new "featured" API, which at present seem to be the same thing
- Added a new client_key, which identifies the integration using the google API key, as google API keys can be used for multiple APIs and projects
-  Fixed up the error handling to support Google's error format, and also caught and replaced the error that everyone with old keys will see to make it clearer. This includes adding an htmlError property so that we can output HTML safely in the frontend.

There is still an active TODO with the naming of the config key, but we will resolve this after merging admin into the monorepo.

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
2022-08-03 14:11:55 +01:00
Kevin Ansfield
90a080e0b8 Update dependency eslint-plugin-ghost to v2.14.0 (#2441)
no issue

- bumped dependency
- fixed all new lint failures
- removed deprecated `ember-cli-eslint`
  - it was tying us to an old version of `eslint` resulting in missing rule definition errors when linting was run as part of `yarn dev` and `ember test`
  - we run linting separately in CI so we don't need linting to run _again_ on each of our ember test runs
2022-08-03 12:21:16 +01:00
Peter Elmers
26e6d459cb Put plus menu button on the screen on mobile (#2417)
Fix the right positioning and size of the icon for mobile display
Addresses https://github.com/TryGhost/Ghost/issues/14948
2022-07-27 11:29:33 +02:00
Kevin Ansfield
242106d596 Migrated code card to Octane syntax
refs https://github.com/TryGhost/Ghost/issues/14101

- applying boyscout rule and upgrading/cleaning up when touching files
- nothing out of the ordinary to report with this migration
2022-07-14 17:32:44 +01:00
Kevin Ansfield
aab02f0f4c 🐛 Fixed code card not correctly saving language when changing
closes https://github.com/TryGhost/Team/issues/1662

- the on-blur action for the language input was modifying the language property in the payload object directly which meant that the mobiledoc `save` call was missing and all the associated editor behaviour for serializing and saving the update was lost
- switched to modern action syntax and a proper action on the backing component so we're saving the change correctly
2022-07-14 17:30:05 +01:00
Kevin Ansfield
508af14460 Fixed linting
refs 3f9c019bc0
2022-05-27 15:24:30 +01:00
Kevin Ansfield
3f9c019bc0 Fixed editor error when using blockquote text expansion in product/toggle card content
no issue

- `<KoenigBasicHtmlTextarea>` has no UI or keyboard shortcut support for blockquotes but the markdown text expansion for quotes was left in despite the code required for it not existing, this meant any time `> text` was typed the editor would throw errors due to missing actions
2022-05-27 15:21:54 +01:00
Kevin Ansfield
cab7f2cd74 🐛 Fixed paste into product card descriptions not stripping header formatting
closes https://github.com/TryGhost/Ghost/issues/14018

- product card descriptions and toggle card content both use `<KoeingBasicHtmlTextarea>` which is a stripped down Koenig editor with basic formatting support where heading sections are not expected
- when pasting into or updating the content in `<KoeingBasicHtmlTextarea>`, convert any headings, blockquotes, or other markerable section types to standard paragraphs so the content formatting matches what is possible through the editing interface
2022-05-27 15:11:08 +01:00
Kevin Ansfield
8fee5f155b Standardized on non-jQuery file dialog triggers
no issue

- we had a mix of legacy jQuery triggers and native triggers for file input clicks and jQuery hasn't been required to do this in our target browsers for quite a long time now so it made sense to update all click triggers to avoid old patterns being replicated
- cleaned up some conditionals with optional-chaining
- removed use of `run.bind(this)` for methods that use `@action` because the binding is already handled for us
2022-05-26 11:05:14 +01:00
Kevin Ansfield
1130b609c3 Fixed linter errors in <KoenigCardProduct> template
refs https://github.com/TryGhost/Ghost/issues/14101
2022-05-26 10:09:00 +01:00
Simon Backx
bc1aa493fa 🐛 Fixed unreliable paid members enabled checks (#2405)
refs https://github.com/TryGhost/Team/issues/1650

- Some places only checked for Stripe being connected via the 'connect' method and ignored the 'direct' method
- Updated (where possible) admin to use the new calculated `paid_members_enabled` setting
2022-05-24 16:53:03 +02:00
Kevin Ansfield
94c192041d Added guards for missing codemirror elements when destroying markdown cards
no issue

- if a markdown card is created and destroyed before the simplemde+codemirror instance is fully initialised we could throw errors due to simplemde calling methods on objects that don't yet exist during teardown
- we also had issues with the `_applyToolbarStyles()` method being called async by event handlers after the component was destroyed
2022-05-24 13:12:22 +01:00
Djordje Vlaisavljevic
61a459ac2e Fixed linting error 2022-05-20 12:26:01 +02:00
Djordje Vlaisavljevic
f3b56d092a Fixed text overflow in the input field 2022-05-20 12:09:41 +02:00
Kevin Ansfield
4aa9d4554e Dropped ember-useragent dependency
no issue

We made very limited use of the `ua-parser-js` sub-dependency that `ember-useragent` pulls in so it didn't seem worth having the fairly large 17KB import or the associated sub-dependency version resolutions.

- switched the two iOS and Safari detections to use associated Regexes on `navigator.userAgent`
- dropped the "Microsoft Edge not supported" message in the editor
  - old Edge is still not supported but it was been replaced with a Chromium-based version that is supported a while back
  - we can re-introduce a warning if we get any significant reports (there is nothing showing in Sentry for this alert in the last 14 days)
2022-03-07 10:06:35 +00:00
Kevin Ansfield
7e3565d71f Resolved linter errors in koenig-toolbar.hbs
refs https://github.com/TryGhost/Ghost/issues/14101

- switched from the deprecated `{{action}}` helper to the `{{on}}` modifier
2022-02-15 13:46:49 +00:00
Kevin Ansfield
f253228d94 🐛 Fixed "Header two" formatting toolbar button not working
closes https://github.com/TryGhost/Ghost/issues/14146
refs https://github.com/TryGhost/Admin/pull/2251

- an action rename was missed when converting the toolbar component to native class syntax
- added test for the h3 toolbar button working
  - fixed `<KoenigEditor>` not assigning the test property that gives tests access to the underlying mobiledoc `editor` instance
2022-02-15 13:23:37 +00:00
Gabriel Csapo
d51f2bcf23 [chore] migrate to eslint@8 and run --fix (#2256)
closes https://github.com/TryGhost/Admin/pull/2107

- updated related babel dependencies
- bumped eslint
- ran `yarn lint:js --fix`
- added eslint ignore comments for some required non-camel-case properties
2022-02-10 10:41:36 +00:00
Kevin Ansfield
8cc4c6c4a1 Dropped ember-concurrency-decorators dependency
no issue

- since `ember-concurrency@2.0` it's possible to use the standard imports as decorators removing the need for the extra `ember-concurrency-decorators` dependency and imports
2022-02-09 10:49:38 +00:00
Gabriel Csapo
f75d88cb2c [chore] migrates koenig-editor files to native classes (#2251)
refs https://github.com/TryGhost/Ghost/issues/14101

- continuing migration to native classes with use of `@classic` decorator
2022-02-09 09:19:45 +00:00
Kevin Ansfield
c55084eeb4 🐛 Fixed Ctrl+Enter-to-edit keyboard shortcut not working on Windows for some editor cards
no issue

- Callout, Email, Email CTA, Header, Product, and Toggle cards all had the same typo in the Ctrl/Cmd+Enter keyboard handling
2022-02-07 16:55:01 +00:00
Kevin Ansfield
c44766e8d3 Collapsed @service injection definitions to single-line style
no issue

- find+replace to make service injection style consistent and take up much less space at the top of files that used multi-line syntax
2022-02-03 19:04:43 +00:00
Kevin Ansfield
1be7dd1770 Ran native classes codemod for lib/koenig-editor/addon/components
refs https://github.com/TryGhost/Ghost/issues/14101

- ran native classes codemod for koenig-editor in-repo-addon components
- added `ember-classic-decorator` to addon's package.json to fix errors when importing

Some files failed to convert automatically:
```
❯ grep -rL "@classic\|default class" lib/koenig-editor/addon/components/**/*.js
lib/koenig-editor/addon/components/koenig-alt-input.js
lib/koenig-editor/addon/components/koenig-card-image.js
lib/koenig-editor/addon/components/koenig-editor.js
lib/koenig-editor/addon/components/koenig-toolbar.js
```
2022-02-03 18:57:21 +00:00
Gabriel Csapo
f22a758a3b [chore] run the no-implicit-this codemod (#2244)
refs https://github.com/TryGhost/Admin/pull/2238

Follow up to #2238, this should remove the existing no-implicit-this lint errors and any new violations should be flagged right away.

* run the no-implicit-this codemod
* updated todos
2022-02-02 17:09:02 +00:00
Kevin Ansfield
5e7c98fb46 Fixed template linting error in koenig-card-email.hbs
refs cc257f8576

- template change triggered a linting rule
- fixed and ran `yarn lint:hbs --update-todo`
2022-02-02 16:48:09 +00:00
Kevin Ansfield
cc257f8576 Fixed noreferer typos
no issue

- should be `noreferrer`, caused duplication by ember-template-lint auto fixing
2022-02-02 16:20:01 +00:00
Gabriel Csapo
beb5ae1737 [chore] adds ember-template-lint and fixes all fixable issues (#2238)
no issue

- This will help with the octane migration and you can still run the lint rules even when they are todos. (Checkout the docs at 158b119667/docs/todos.md) The good news is any new code will be checked against the recommended config.
- I fixed all the auto fixable things we could get in this PR as well
2022-02-02 16:09:43 +00:00
Kevin Ansfield
c9aa43e5a5 Added infobox to matches list for callout card
no issue

- extra term for matching the callout card so you can start typing `/infobox` and get the card you were looking for
2022-01-31 13:46:07 +00:00
Kevin Ansfield
fa4f8221d5 🎨 Made /-menu card searching case-insensitive
no issue

- allows typing "Button" to match the "button" card
- useful on mobile where words can be auto-capitalized
2022-01-31 13:37:25 +00:00
Kevin Ansfield
e0fa64a56b 🐛 Fixed editor cards not being usable by contributors
no issue

- a recent Ember upgrade has slightly changed behaviour for template conditionals meaning helpers used in the right-hand side of a conditional can be called when the conditional evaluates to falsy
- this caused an error to be thrown by the editor when creating cards as a contributor because the `{{fn}}` helper is called with a null/undefined `saveCardAsSnippetIfPossible` function which will throw an error
- wrapped the function in the `{{optional}}` helper (https://github.com/DockYard/ember-composable-helpers#optional) which will return a "noop" function allowing the template to evaluate without errors
2022-01-31 13:28:26 +00:00
Peter Zimon
3a3b2f7fb4 Remove alpha flag for Editor settings panel (#2230) 2022-01-31 13:33:59 +01:00
Kevin Ansfield
f56b52b8a1 Cleaned up headerCard labs flag
refs https://github.com/TryGhost/Team/issues/1258

- removed labs flag and conditionals as feature is GA
2022-01-04 14:58:19 +00:00