Skip to content

Conversation

@nizarmah
Copy link
Contributor

@nizarmah nizarmah commented Nov 29, 2020

This makes it possible to install new tinymce plugins through the environment settings.

This PR is responsible for adding the tinymce plugin settings to the tinymce javascript configuration.

JIRA tickets: SE-3381, SE-3247, OSPR-5263, OSPR-5264

Dependencies:

Sandbox URL:

Testing instructions:

  1. Login to Studio using staff@example.com/edx
  2. Create a new Unit with an HTML Text
  3. Make sure that the ADSK Link shows in the toolbar
  4. Create a link and make sure you can preview it, and see it on the LMS

Author Notes and Concerns:

  1. This is a limited implementation, it does not support custom stylesheets in the TinyMCE plugins.
  2. The reason behind that is that no plugin currently requires any stylesheets to be included into Studio and LMS.

Reviewers

Settings

EDXAPP_CMS_ENV_EXTRA:
  JS_ENV_EXTRA_CONFIG:
    TINYMCE_ADDITIONAL_PLUGINS:
    - name: adsklink
      toolbar: true
      extra_settings:
        linktypes:
        - download
        - offer
        filetypes:
        - PDF
        - zip
        - Video
        - Design
        orientations:
        - Vertical
        - Horizontal
        styles:
        - Primary
        - Normal
        - Secondary

TINYMCE_ADDITIONAL_PLUGINS_LIST:
- repo: https://gitlab.com/nizarmah/tinymce-adsk-plugin
  name: adsklink
  plugin_path: "/adsklink"

edx_ansible_source_repo: "https://github.com/open-craft/configuration.git"
configuration_version: "nizar/tinymce_plugins_role"
edx_platform_commit: "nizar/tinymce_plugins_combined_dependencies_master"

@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U labels Nov 29, 2020
@openedx-webhooks
Copy link

Thanks for the pull request, @nizarmah! I've created OSPR-5264 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@natabene
Copy link
Contributor

natabene commented Dec 1, 2020

@nizarmah Thank you for your contribution. Please let me know once it is ready for a review.

@nizarmah
Copy link
Contributor Author

nizarmah commented Dec 1, 2020

@natabene small note by the way, I know I have a bunch of pull requests open at the moment. I just wanted to let you know that even if I haven't made any changes on a pull request, I haven't abandoned any of them.

I'm keeping good track of them, and switching between them depending on the work's priority internally. 👍

@openedx-webhooks openedx-webhooks added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed needs triage labels Dec 2, 2020
@nizarmah nizarmah force-pushed the nizar/tinymce-easy-plugin-modification branch 8 times, most recently from 1b56061 to e6fc4de Compare December 5, 2020 19:14
@nizarmah
Copy link
Contributor Author

nizarmah commented Dec 5, 2020

Apparently, all it took to fix the python build was 2 commits, rasied to the power of 3 🙂

Copy link
Contributor

@pkulkark pkulkark left a comment

Choose a reason for hiding this comment

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

LGTM 👍

  • I tested this: verified the new tinymce plugin is installed correctly as described in the testing instructions
  • I read through the code

@bradenmacdonald
Copy link
Contributor

@nizarmah Could you please include documentation about this new extension point in extension_points.rst ? That will also notify people watching for changes that improve platform extensibility.

@nizarmah
Copy link
Contributor Author

Alright, so what has been addressed is the following:

  • Added information about the limitation of the solution in the pull request description
  • Changed the method of passing the additional tinymce plugins configuration:
    • Now each plugin is passed as a dictionary, instead of a key
    • Each plugin has a toolbar key in order to indicate whether it should be added to the toolbar
    • Each plugin has extra_settings in order to hold its extra settings
  • Also @bradenmacdonald I have added a brief mention of the TinyMCE plugins in the extension_points.rst. But I have not created an actual doc to include in edX's documentation. Would you prefer that I create one and link to it, instead of linking to this pull request?

@nizarmah
Copy link
Contributor Author

@bradenmacdonald sorry, I'll need you to hold slightly on reviewing this ticket. There's something that I should've checked for, and if this PR would break Multiple App Servers.

The reason is, that we're doing changes to edit.js which would be reflected in the bundled common.js, and if there's a slight sorting issue due to passing the JS_ENV_EXTRA_CONFIG, then they'll break.

So I'll be building multiple app servers to verify that the hash is identical 👍🏼

@bradenmacdonald
Copy link
Contributor

No problem @nizarmah, just let me know.

@natabene can I take this as a core committer?

@natabene
Copy link
Contributor

@bradenmacdonald Sure.

@nizarmah
Copy link
Contributor Author

@bradenmacdonald thanks a lot for being patient with me 😄 I ended up creating 5 different servers and made sure that the bundled commons.js is generated consistently among the different servers, without any single change (content hashes were identical on all machines 🥳)

So now that I've verified the change doesn't affect multiple app server support, this is ready for your review again 👍🏼

@bradenmacdonald
Copy link
Contributor

@nizarmah Unfortunately there seems to be an error on the sandbox - the visual editor is not displaying:

Screen Shot 2020-12-18 at 1 14 20 PM

static_root_lms=static_root_lms,
static_root_cms=static_root_cms
static_root_cms=static_root_cms,
js_env_extra_config=js_env_extra_config
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: please add a trailing comma, to get nicer diffs in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeap, sorry about missing that 👍🏼 This should be addressed now 😃

@openedx-webhooks openedx-webhooks removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Dec 27, 2020
@nizarmah
Copy link
Contributor Author

nizarmah commented Jan 1, 2021

@bradenmacdonald this is ready for your review again.

Sorry about the problem you faced earlier! I added some explanation about it in the changes you requested 👍🏼

Please note that there seems to be a problem with one of the builds on the whole edX platform, so the currently failing python test isn't a result of the changes I did in this pull request.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this return a string or a decoded JSON object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This returns a string, since it changes the True values to true which would be invalid in a Python object.

I'll update the docstring to mention it in a better way. 👍🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed 👍🏼

Updated to

        :return: json string value of the django setting

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that here js_env_extra_config_setting is a string right? So "string" or {} seems like inconsistent typing - should it be js_env_extra_config_setting or "{}" ? Or is js_env_extra_config_setting an object already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

js_env_extra_config_setting is a string, yes.

You're right, it is inconsistent. I'll update this to js_env_extra_config_setting or "{}". In addition, I'll update the tests too, I added comments to address those changes 👍🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed 👍🏼

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

Thanks for your patience and diligence here, refining this approach and documenting it!

👍 if you address these last questions, rebase and squash into a single commit with a clear commit message.

Please also do a quick test to make sure that this doesn't introduce any problems when the setting is not set (i.e. default values everywhere).

  • I tested this: on the sandbox
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This returns a string, since it changes the True values to true which would be invalid in a Python object.

I'll update the docstring to mention it in a better way. 👍🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

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

js_env_extra_config_setting is a string, yes.

You're right, it is inconsistent. I'll update this to js_env_extra_config_setting or "{}". In addition, I'll update the tests too, I added comments to address those changes 👍🏼

@nizarmah nizarmah force-pushed the nizar/tinymce-easy-plugin-modification branch from 6360185 to 1c3b8bf Compare January 8, 2021 04:43
@edx-status-bot
Copy link

Your PR has finished running tests. There were no failures.

@nizarmah
Copy link
Contributor Author

nizarmah commented Jan 8, 2021

@bradenmacdonald It's my pleasure! Your comments are something I look forward to, because I always end up learning something new, whether about the edX platform or on a personal level 😃

I addressed the comments you raised, and I also squashed the commits.

Regarding testings, I deployed two new sandboxes:

I have tested both sandboxes, and the TinyMCE editors are running great on both 👍🏼
Please note that the sandboxes are running the following:

@ormsbee ormsbee merged commit 1e872d4 into openedx:master Jan 11, 2021
@openedx-webhooks
Copy link

@nizarmah 🎉 Your pull request was merged!

Please take a moment to answer a two question survey so we can improve your experience in the future.

@nizarmah nizarmah deleted the nizar/tinymce-easy-plugin-modification branch January 11, 2021 17:00
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

nizarmah added a commit to open-craft/openedx-platform that referenced this pull request Jan 20, 2021
0x29a pushed a commit to open-craft/openedx-platform that referenced this pull request Feb 15, 2021
0x29a pushed a commit to open-craft/openedx-platform that referenced this pull request Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants