Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract modal state #2162

Merged
merged 17 commits into from Jun 30, 2020
Merged

Extract modal state #2162

merged 17 commits into from Jun 30, 2020

Conversation

askvortsov1
Copy link
Sponsor Member

Fixes Part of #1821, #2144

Changes proposed in this pull request:

  • Move modal state out from modal manager component

Reviewers should focus on:

  • Anything I missed?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).

Copy link
Member

@clarkwinkelmann clarkwinkelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few observations from a quick reading.

Something additional: I would suggest already renaming every "prop" to "attrs" in the new and renamed classes to prepare for Mithril new naming. (like modalProps, directly name it modalAttrs). Not sure what @datitisev things about this. This would also apply to the other PRs

js/src/common/states/ModalState.js Outdated Show resolved Hide resolved
js/src/common/states/ModalState.js Outdated Show resolved Hide resolved
js/src/common/components/Modal.js Outdated Show resolved Hide resolved
@askvortsov1
Copy link
Sponsor Member Author

Should app.modal.show require a ModalState object? It would be more in line with what we're doing for Alerts, but would also require a bunch more imports...

@dsevillamartin
Copy link
Member

Not sure if I like having getClass and getAttrs methods (instead of directly accessing them), but we could perhaps add a method to the ModalState to check for the class prototype instance of (as it's used in a few places).

Copy link
Member

@clarkwinkelmann clarkwinkelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok for going ahead with this version of the PR.

I think we should regard ModalState as internal/private API for now. We can still rework the internal later if necessary.

@askvortsov1
Copy link
Sponsor Member Author

In later versions, I anticipate "ModalState" staying relatively constant, just that it wouldn't be stored in "ModalManagerState". That being said, the only change I'd make at this point is rename it to just "Modal" and put it in an instances directory (or some other naming) as per Franz's comment, don't have the link to that though.

@askvortsov1 askvortsov1 force-pushed the as/frontend-rewrite-modal-state branch from 96b3730 to cc5c4ce Compare June 19, 2020 21:46
@franzliedke franzliedke force-pushed the as/frontend-rewrite-modal-state branch from cc5c4ce to 75728f5 Compare June 26, 2020 17:19
- No more weird events
- State only has show() and close()
- The ModalManager handles Bootstrap's DOM events and signals
  corresponding state changes to the Modal component and the
  state.
- The Modal component triggers the animations at the right time
  using Mithril's lifecycle hooks.

TODO:
- Remove debug output
- Ensure that calling close() followed by show() works correctly
- Document props
@franzliedke franzliedke force-pushed the as/frontend-rewrite-modal-state branch from e515714 to 1cc02e9 Compare June 26, 2020 22:45
@askvortsov1 askvortsov1 merged commit 44376ce into master Jun 30, 2020
@askvortsov1 askvortsov1 deleted the as/frontend-rewrite-modal-state branch June 30, 2020 23:59
franzliedke added a commit to flarum/emoji that referenced this pull request Jul 24, 2020
franzliedke added a commit that referenced this pull request Aug 14, 2020
Regression from #2162.
askvortsov1 added a commit that referenced this pull request Aug 16, 2020
* Fix closing the composer with ESC key

Regression from #2161.

* Remove obsolete method

Regression from #2162.

* Mark method as protected

* Fade in posts in post stream using CSS

This also avoids a double-fade from the JavaScript code, which was
probably introduced in #2160.

* Fix fadeIn for post stream items

Co-authored-by: Alexander Skvortsov <sasha.skvortsov109@gmail.com>
franzliedke added a commit to flarum/mentions that referenced this pull request Sep 4, 2020
franzliedke added a commit to flarum/mentions that referenced this pull request Sep 4, 2020
franzliedke added a commit to flarum/mentions that referenced this pull request Sep 4, 2020
askvortsov1 added a commit that referenced this pull request Sep 6, 2020
* Fix closing the composer with ESC key

Regression from #2161.

* Remove obsolete method

Regression from #2162.

* Mark method as protected

* Fade in posts in post stream using CSS

This also avoids a double-fade from the JavaScript code, which was
probably introduced in #2160.

* Fix fadeIn for post stream items

Co-authored-by: Alexander Skvortsov <sasha.skvortsov109@gmail.com>
askvortsov1 pushed a commit to flarum/emoji that referenced this pull request Mar 11, 2022
askvortsov1 pushed a commit to flarum/mentions that referenced this pull request Mar 11, 2022
askvortsov1 pushed a commit to flarum/mentions that referenced this pull request Mar 11, 2022
askvortsov1 pushed a commit to flarum/mentions that referenced this pull request Mar 11, 2022
askvortsov1 pushed a commit to flarum/emoji that referenced this pull request May 10, 2022
askvortsov1 pushed a commit to flarum/mentions that referenced this pull request May 10, 2022
askvortsov1 pushed a commit to flarum/mentions that referenced this pull request May 10, 2022
askvortsov1 pushed a commit to flarum/mentions that referenced this pull request May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants