Commit graph

67 commits

Author SHA1 Message Date
Jeferson S. Brito
012e625c7c
Add Preact root fragment implementation replacement for replaceNode (#19673)
* feat: add preat-root-fragment implementation of replaceNode

* refact: replace render third argument with root fragment

* chore: reorder preact root imports

* fix: root createRootFragment implementation

* chore: fix base.jsx import order

* fix: add specs for preact-root-fragment

* fix: test ci audit issues

* fix: add insert/append methods specs for root-fragment
2023-07-25 10:11:41 -04:00
Fernando Valverde
60319212ce
Fix jest datetime tests with regex (#18347) 2022-08-17 11:12:09 -04:00
Ridhwana
ffa5e023bb
Implementing validation for the Multi Input Crayons Component (#18185)
* WIP: add the validation

* feat/WIP: set the color of the button to red

* feat: change color temporarily

* feat: add accessibility for validation

* feat: add the styling changes for the multi input

* feat: add focus visible styling as well

* fix: add comma to scss file to separate attributes

* chore: rename regex to inputRegex

* refactor: move out validation into a function

* chore: rename regex to inputRegex

* feat: add a validation Regex as a prop

* feat: update the text description

* chore: update spelling oops

* feat: remove comment

* remove comments

* rename error

* feat: add showLabel and labelText to the stories component

* cater for when we don't pass in a validationRegex

* some small tweaks

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-07-22 12:51:06 +01:00
Suzanne Aitchison
817db3e6f8
keyboard shortcuts in comment text area (#18117) 2022-07-18 12:01:48 -04:00
Arit Amana
750d379807
Allow ModRole & Admin to Suspend & Unsuspend User (#17946)
* gotta commit at some point

* out of gas

* IT'S WORKING NOW! 💥

* Cypress tests

* fix Travis failures

* incorporate PR review suggestions

* fix one failing Cypress test

* update API call

* add Unsuspend flow; fix Travis failures

* add tests for unsuspend flow

* remove unnecessary atrribute

* add article_policy spec

* fix failing Travis

* nudge Travis

* fix apparent typo  o o 🤷

* refactor a bunch of duplication

* nudge Travis

* fix Cypress failure related to authorizing moderator for user_status action

* rename modal partial

* remove unnecessary button-exists check

* address PR review suggestions

* hide suspend user btn after action

* toggle btn based on author suspension status

* add data-testids

* use data-testids

* controller refactor
2022-06-27 12:45:35 -04:00
Ridhwana
abeff25ec0
BETA version 2 of the Storybook Multi Input (Editing and Accessibility) (#17894)
* refactor: use the DefaultSelectionTemplate to list out the items

* refactor: rename function so that we map it to the deselect item event

* feat: first pass of adding edit functionality

* feat: update the name of the function from clearSelection to clearInput

* feat: setup the edit state by ensuring that we set the editValue and the inputPosition and then use useEffect to monitor changes

* chore: remove the old method in favour of a shared component

* feat: set the order of the items

* refactor: rename handleBlur function name to handleInputBlur

* feat: ensure that the edit field gets resized according to its current input

* feat: oops add inputSizerRef

* feat: when an item is being edited we need to ensure that it gets set back into the correct position and that we clear the previous state

* feat: handle the actual resizing fo the field on an input edit

* feat: use a shared DefaultSelectionTemplate for both the multiautocomplete and the multiinput component

* feat: make the defaultSelectionTemplate customizable based on the variant adn the classname

* feat: pressing backspace will start editing a previous selection if there is one

* feat: read out the selected items as its removed or edited

* feat: pass the regex through as a prop

* feat: move the functions around

* feat: add screen-reader only class

* Update app/javascript/crayons/MultiInput/__stories__/MultiInput.stories.jsx

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update app/javascript/crayons/MultiInput/MultiInput.jsx

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* feat: add the props to JSDoc

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-06-23 15:41:45 +02:00
Suzanne Aitchison
eae8557cf1
Admin member index: update responsive layouts (#17124)
* add an xl breakpoint and use in member index view

* expand search controls at medium breakpoint

* tweak small screen layout options per breakpoint, add overflow button

* small fix

* switch where role appears depending on breakpoint

* adjust for smallest layout

* tweaks for medium layout

* tweaks for large layout

* tweaks for XL table
2022-04-07 14:36:43 +01:00
Miguel Nieto A
148f242892
Replace listings tag component (#16855)
* wip

* feat:  Use MultiSelectAutocomplete for Tags

* feat:  Add additional tags for listings

* refactor: ♻️ Use preact/hooks and refactor propTypes

* fix: 🐛 Fix addiional tags support depending on the selected category

- Add slug to returned array in select_options_for_categories helper
- Differentiate the fields categoryId and categorySlug

* fix: 🐛 Adjust propTypes

* test: 🚨 Change test for select_options_for_categories helper

* refactor: ♻️ Apply requested changes

* refactor: ♻️ Remove border prop - default is true

* test: 🚨 Add test suite for ListingTagsField component

* refactor: ♻️ Apply requested changes

* refactor: ♻️ Remove unnecessary forEach + Improve code legibility

* docs: 📚 Remove topTags from hook documentation

* refactor: ♻️ Use the alias for crayons folder + Use loclaCompare in sort

* test: 🚨 Clean up mock response

* fix: 🐛 Reorder styles

* style: 🎨 Add comment to TagAutocompleteOption/Selection components
2022-03-30 16:51:40 +01:00
Suzanne Aitchison
222ce06f0f
Add new tag autocomplete to editor (#16025)
* add default placeholder, remove focus on first load

* fix some bugs re autofocus and mouse click to select

* allow custom selected styles to be passed in

* operate on objects with name property rather than plain strings

* WIP main functionality in place

* set default selections, allow a max to be placed on selections

* switch help context

* bug fixes to edit mode, static suggestions

* make sure suggestion resumes when edit begins

* cleanup and docs

* update existing form test

* add component tests

* add more component test cases

* refactor max selections flow, ensure default tag data only loads once

* stop removing combobox properties now the input stays visible

* add max selections test

* refactor

* make sure input refocus happens after blur event

* update cypress tests

* some small renames and doc changes

* only fetch exact matches from added tags

* fix test, update dark theme background

* set a max height on the popover, and ensure options can be scrolled into view

* woops - max height

* Update app/javascript/article-form/components/TagsField.jsx

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* refactors

* stop dropdown from flickering

* use ButtonNew

* remove redundant variant

* nudge PR checks

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2022-01-21 08:58:05 +00:00
Nick Taylor
6b21fe2bac
Fixed test that breaks once upgraded to Node 16. (#15621) 2021-12-01 09:24:03 -06:00
Suzanne Aitchison
89faac306a
treat cmd and ctrl key shortcuts separately on macOS (#15265)
* treat cmd and ctrl key shortcuts differently on macOS

* consolidate shortcut key string into Runtime helper
2021-11-03 11:54:15 +00:00
Michael Kohl
6753bd90c1
Fix tag dropdown (#14867) 2021-10-12 11:58:29 +07:00
Papu Kumar(ReX)
33742e7907
Fix PropTypes Error Create New Post Page (#14969) 2021-10-11 09:48:24 -04:00
Suzanne Aitchison
b0b2b995c5
dont show rules for top tags (#14878) 2021-10-01 16:16:00 -04:00
Suzanne Aitchison
58e3d6efd5
Suggest top tags when tag search is empty (#14817)
* show top tags when search is empty

* add cypress tests

* nudge travis

* tweak to e2e test

* show a 'top tags' heading

* only suggest tags that are supported

* Add supported scope to Tag

Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-09-30 09:41:20 +01:00
dependabot[bot]
f0700b2588
Bump jest from 26.6.3 to 27.2.0 (#14722)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-09-14 11:20:15 -04:00
Suzanne Aitchison
dcecc8bf00
Log prop-types warnings to console in development (#14635)
* enable debug for warnings in dev env

* remove preact/devtools call no longer needed

* fix majority of proptype errors on home page

* sweep up proptype errors from listings page

* fix article form error
2021-09-01 09:27:58 +01:00
Nick Taylor
e0ee5e71f4
Some eslint fixes. (#14605) 2021-08-27 08:37:09 +01:00
Hariharan Sampath
208d788672
Fix feed navigation shortcuts when first article is not 100% visible (#11874)
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
Co-authored-by: Hariharan <hariharan.s@samsung.com>
2021-04-13 22:35:50 -04:00
Michael Kohl
5406b0576e
Split Settings::Authentication from SiteConfig (#13095)
* Split Settings::Authentication from SiteConfig

* Move specs

* Sort fields

* Update settings usages

* Update recaptcha usages

* Add data update script

* Update spec

* Rename SiteConfigParams concern

* Fixes, new route, new controller

* Controller and service refactoring

* More controller and service updates

* Spec updates

* More spec fixes

* Move file

* Fix FeedbackMessagesController

* Update admin/configs_spec

* Fix remaining specs in admin/configs_spec

* Fix configs API

* Formatting

* Clean up old service object

* Various fixes

* Update DUS

* Add model argument to admin_config_label

* Fix key name

* Fix specs

* Add distinct request caches for settings classes

* Fix e2e tests

* Fix remaining system spec

* Make DUS idempotent

* Move routes block

* Cleanup

* Switch to ActiveSupport::CurrentAttributes

* Pinned rails-settings-cached

* Update e2e test

* Update lib/data_update_scripts/20210316091354_move_authentication_settings.rb

Co-authored-by: rhymes <rhymes@hey.com>

* Add guard to DUS

* Temporarily re-add two SiteConfig fields

* Fix config show view

Co-authored-by: rhymes <rhymes@hey.com>
2021-04-12 09:41:09 +02:00
Nick Taylor
86deddbb75
Fixed Reading List on Mobile + Small Improvements (#12755)
* Some div soup to semantic markup.

* Small refactor to inline mapping of available tags.

* Renamed <ItemListTags /> component to <TagList />.

* Now a select is used for picking a tag to filter on.

* Added custom Cypress command to create an article.

* Added documentation for the create article custom command.

* Removed unnecesary properties from payload to create an article.

* reading list mobile view wip.

* Reworked styles in <TagList />.

* Reworked reading list to use <MediaQuery /> component.

* Removed bottom padding from reading list header.

* styling tweaks if there are no available tags.

* Added some E2E tests.

* Removed reading list component test in favour of e2e test.

* Made breakpoint values numbers.

* Added some padding and more grid gap to filter on small screens.

* Adjusted jest coverage thresholds as we're moving some tests to e2e tests.

* Reverting a VS Code setting change caused by one of my extensions.

* First pass for E2E tests for the reading list.

* Added some more grid gap.

* Fixed load next page to send tags properly.

* Added some more tests.

* Improved label and placeholder for text filter in reading list.

* Added more tests

* Fixed media queries so it works in Chrome as well.

* Removed aside as tag filters are not complimentary information.

* Update app/javascript/readingList/components/TagList.jsx

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Update docs/tests/e2e-tests.md

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Turned off deprecated rule in jsx-a11y eslint plugin.

* Reverted to links instead of radio buttons.

* Added an all tags link and select option.

* Fixed relayout issue.

* Fixed View Archive button size.

* Fixed styling of the load more button.

* Fixed empty list issue toggling between archive and reading list.

* Fixed request changes from PR review.

* Removed CSS change that is no longer required.

* Trigger Build

* Fixed centering of items in top fieldset.

* Fixed issue with search text field resetting reading list.

* Fixed component tests for the reading list.

* Fixed empty state popping up between search queries.

* Fixed casing of fixture filenames.

* Update app/javascript/readingList/readingList.jsx

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Reverted change in reading list component test.

* Added missing JSDoc comment.

* Now links are in an unordered list.

* Promoted some CSS classes from the <nav /> to the <ul /> for spacing.

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-04-08 12:53:43 +01:00
Andrew Bone
58499cefb3
Update shortcut code with best practices (#13026)
* Update with best practices

* Remove useCallback

* Update app/javascript/shared/components/useKeyboardShortcuts.js

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Fill out JSDoc

* Follow Prettier rules

* Resolve conflict

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-03-24 14:03:45 +00:00
Nick Taylor
0beacb19c9
[15 Minute Fix] Added the prefer-const eslint rule (#13098) 2021-03-23 16:29:56 -04:00
Nick Taylor
d90e5662ef
Created the <MediaQuery /> component and useMediaQuery hook. (#12809)
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-02-25 14:28:44 -05:00
Suzanne Aitchison
5bed8f56d4
improve keyboard accessibility of modals 12427 10610 (#12511)
* adds focusTrap wrapper to preact Modal component

* add view specific code for focus trap in admin add nav link

* add script to return a focustrap toggle, use in add nav link modal partial

* add trap to edit nav link modal

* add handlers for sign up modal

* update modal controller for admin section, update nav link modals to use

* update other admin modals with new data values for trap

* remove unneeded erb script file

* remove unneeded target

* refactor to remove extra unneeded param

* remove duplicate code, store getFocusTrapToggle in window

* trap focus in comment and bookmark showModal instances for not logged in user

* remove need for activator id

* clean up id refs no longer needed

* remove custom code and re-use focsu-trap lib

* update storybook docs

* update default export in focusTrap

* prevent close button click triggering a modal toggle twice

* ensure if user navigates from a modal the trap is deactivated

* add jsdoc comments and add dynamic import

* ensure admin controller modal traps are cleaned up on disconnect

* update sign up modal to use crayons

* update modal controller and admin nav links modals to use preact modal

* update profile fields modals for new controller

* tweak styling of sign up and admin modals to match previous

* update listings modal to use crayons modal, adapt focus trap to work with click outside

* memoize deactivate callback to ensure modal can be presented on first page load

* add missed focustrap changes

* fix focus trap issues in onboarding flow

* refactor onboarding focus trap, remove getFocusTrapToggle

* tweaks for styling and article modal toggle

* add click outside tests to modal

* add cypress tests for the login modal

* update liquid tag tests affected by change

* refactors to address review comments

* fix issue with login modal presented twice on comment add

* change ids to selectors in admin modals

* small pr comment refactors

* add listings e2e tests

* add nav link modal tests

* fix issue with help modal

* tweak to fix ui bug from merge

* remove context from showLoginModal

* rename toggleModal

* rename state property for clarity

Co-authored-by: Nick Taylor <nick@dev.to>
2021-02-24 16:01:10 +00:00
Katie Davis
76453b41fb
Updates ESLint rules to error on default imports (#12512)
* add rule

* add named imports

* more missed files

* so many files
2021-02-02 10:24:03 -05:00
Rafi
335957edd5
Adding focus trap to trap focus within the modal (#12366)
* Adding focus trap to focus trap in the modal

* Adding yarn lock

* Removing Fragment

* Fixing focus trap casing

* Adding waitFor
2021-01-28 10:18:21 +01:00
Ben Halpern
b8ff9a4565
Small clean ups in post form (#12113) 2021-01-05 08:52:36 -05:00
Nick Taylor
bf7780cd2c
Ran prettier on *.js, *.jsx and *.md files. (#11586) 2020-11-23 20:45:50 -05:00
rhymes
f9506affb5
Use faster JS selection methods (#11409)
* Add JS tips section to frontend documentation

* Replace document.getElementsByTagName('body') with document.body

* Replace querySelectorAll with faster selecting methods where appropriate

* Replace querySelector with faster selecting methods where appropriate

* Fix typo

* Fix forEach and getElementsByClassName

* Change querySelector* to faster methods in erb files

* Change querySelector* to faster methods in ruby files

* Fix runkit tag

* Various fixes

* Update app/assets/javascripts/initializers/initializeEllipsisMenu.js

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Update app/assets/javascripts/utilities/slideSidebar.js

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Commenting out flaky spec

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2020-11-16 17:35:50 +01:00
Robin Gagnon
27a3df7d73
A11y: Add keyboard navigation to article feed (#10468)
Co-authored-by: Andrew Bone <AndrewB05@gmail.com>
Co-authored-by: Nick Taylor <nick@dev.to>
2020-11-10 22:38:15 -05:00
Nick Taylor
af58e7c1a9
Set default timeout to 0 ms for keyboard shortcuts. (#11363) 2020-11-10 18:32:29 -05:00
Andrew Bone
75bec9b705
Add chaining to shortcuts (#11113)
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
2020-11-10 09:21:39 -05:00
Andrew Bone
b7dfb2495a
Allow keyboard shortcuts (#10713)
* Create keyboardShortcuts.jsx

Add handler for keyboard shortcuts

* Match github's hotkey style

Makes objects clearer.

* Update keyboardShortcuts.jsx

* Allow single character shortcuts

update to allow single character shortcuts/hotkeys

* Add component documentation

Add inline documentation for the component.

* Fix example typo

* Move keyboardShortcuts to a hook

* Fixed useKeyboardShortcuts example

* Rename keyboardShortcuts.jsx to useKeyboardShortcuts.jsx

* Rebuild

* Move isFormField outside render cycle

Move the isFormField function outside of the render cycle.

* Prevent event listener on empty object

Don't add an event listener if the shortcuts property is an empty object or is null

* Add tests for useKeyboardShortcuts

Initial pass for adding tests to useKeyboardShortcuts

* Missed unmount

Missed a whole word...

* Fix typos

* Convert function type

* Add new test cases.

* Missing brackets

* Typo

* Update useKeyboardShortcuts.test.jsx

* Move event listener to document

* Update tests

* Use testing-library/user-event

* Correct fireEvent

* Update keyDown

* Slight tidy

* Change order, just in case

* Swap to render

* Make function async

* Rerun travis

* Add rerender

* Fix render function

* check event.key for fallback
2020-10-22 13:45:42 +02:00
Robin Gagnon
2c10fb0417
[deploy] fix: Clear chat input after Enter key submit (#10487)
* fix: Clear chat input after Enter key submit

* fix: Rename Composer component

* test: Add integration tests for input value

* After pressing Enter
* After clicking Send
* After clicking Save edit
* After clicking Close edit
2020-10-08 14:51:36 -04:00
ludwiczakpawel
90d04a73db
Crayonsification of Listings form (#10429)
* i dont know how to test

* fix i guess

* layout update

* layout updates

* edit

* edit listing

* fix

* tags field

* specs|

* Update app/javascript/listings/__tests__/ContactViaConnect.test.jsx

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
2020-09-30 09:14:48 +02:00
Rafi
ea74a3d390
Using global util function for displaying date in listing dashboard (#10244)
* Common date util function for listing dashboard

* Making dateTime required

* Fixing typo

* Fixing tests

* Fixing deletion of function in globalThis
2020-09-09 09:35:05 +02:00
Jacob Herrington
cc6a79ad57
[deploy] Fix tag input patterns (#9363)
* Fix tag input patterns

* Trigger build

* Increase JS test coverage for CI
2020-07-20 08:06:36 -05:00
Jacob Herrington
9e08ae6f1f
[deploy] Restrict tags input regex (#9172) 2020-07-16 12:28:03 -04:00
Nick Taylor
6542395b38
Upgraded to preact testing library 2.0.0 (#9103) 2020-07-06 14:53:10 -04:00
Jacob Herrington
83ba6b64c9
Stop allowing accented characters in tags (#9006)
* Stop allowing accented characters in tags

This commit will add strict frontend and backend validation for tags
disallowing accented characters.

* Update tags validation error message

* Add more character sets to tag validation spec
2020-07-01 11:48:25 +02:00
Nick Taylor
30bfe1adfd
More frontend lint fixes (#8931) 2020-06-29 08:19:13 -04:00
Nick Taylor
09bb730f9d
Added a11y tests to frontend tests that were missing them (#8873) 2020-06-24 14:38:39 -04:00
Nick Taylor
653ec12300
Upgrade to Preact 10.4.4 (#8739)
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2020-06-18 10:07:17 -04:00
ludwiczakpawel
a161d3ce31
[deploy] Redesign article editor (#7524) 2020-05-29 11:59:37 -04:00
Nick Taylor
530b13e8c7
made all frontend unit tests uniform by preffering it(...) over test(...) (#8113) 2020-05-28 17:18:15 +02:00
Michael Kohl
7f75f99560
[deploy] Rename classified listings (#7910)
* Change models and related files

* Update controllers and specs

* More renaming

* Seek and destroy, I mean search and replace

* Round up the stragglers

* Ground control to Major Travis...

* More fixes

* PR feedback

* Various fixes

* Rename view

* Fix list query builder

* Unify request specs

* Fix some API spec errors

* Fix remaining API specs

* Make spec conform to API

* Fix leftover problems

* Fix JS tests

* Fix column name in select

* Fix API specs

* Fix search specs

* Paging Mr. Travis
2020-05-27 13:35:09 +00:00
Nick Taylor
03ff779ca3
Moved src/utils out of src/ folder to utilities/ folder. (#7875) 2020-05-15 10:07:42 -04:00
Alex
cecddf3097
[deploy] Add name to tags component (#6802)
* Add name to tags component

* Remove old form field

* Update Jest snapshots

* Put form field back in

* Remove explicit name from form field

* Add comment explaining keeping tag_list form field

* Typo - faciliate --> facilitate
2020-04-07 09:50:45 -04:00
Manda Putra
6310dba783
Remove debouncing from Tags component to fix glitching in autocompletion (#6598) [deploy]
* fix: glicth when using writing tags

* Revert "fix: glicth when using writing tags"

This reverts commit f3c7b44b51698921e621dde491aee28477a6d03d.

* fix: glitch when typing uncommon tags
2020-03-20 18:18:05 +01:00