Problem/Motivation

Installation of the jsTree library requires additional steps, downloading, renaming, etc. This is not very convenient especially for projects that are managed by the composer and don't store any contribs under VCS. The solution with composer.libraries.json is fine but still requires additional actions.

Proposed resolution

According to the official docs jsTree can be installed with CDNJS, example:

https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.10/themes/default/style.min.css
https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.10/jstree.min.js

So we can just update the media_directories_ui.libraries.yml file and connect library files directly from CDN. media_directories_ui_requirements() have to be removed because the library will be always available by default. The solution doesn't require any additional actions for an upgrade path, it will work for all with the new version of the module.

Comments

afi13 created an issue. See original summary.

rang501’s picture

Hi!
Thanks for the idea. I do agree that initial setup should be as easy as possible.
CDN could be used as default, but the option to use local files should remain, there may be use cases where content security policy settings doesn't allow external sources, the site is a intranet instance (with no access to outside network), security requirements and so on.

Most likely there should be a setting to control this.

ytsurk’s picture

Status: Active » Needs work

Agree with rang501 - we can provide a CDN library which can be enabled in settings.

ytsurk’s picture

Title: Manage jsTree dependencie via CDN » Manage jsTree dependency via CDN
ytsurk’s picture

Assigned: afi13 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new9.38 KB

There you go

ytsurk’s picture

StatusFileSize
new6.51 KB

Thinking twice made me just use the CDN if the library is not installed.
So the module needs one step less after installation.

A warning is shown on the status report if served from CDN. It's kind of my personal preference, maybe information would be enough?

ytsurk’s picture

Title: Manage jsTree dependency via CDN » Serve jsTree from CDN if no library is installed
Issue tags: +UX

  • ytsurk committed ac05f5f on 2.x
    Issue #3179504 by ytsurk: Serve jsTree from CDN if no library is...
ytsurk’s picture

Status: Needs review » Fixed

I hate reviewing myself, and even more talking to myself.

dom.’s picture

Status: Fixed » Needs review
StatusFileSize
new87.22 KB
new87.02 KB
new1.3 KB

Sorry, the patch #6 introduces a regression: try moving a media to a folder, you will get a red cross while the operation is actually permitted.
Before patch

The reason is because jsTree library is added AFTER this module JS files. But media_directories.jstree.js introduces global bindings because of #3176332: Drag and Drop Parent Folder into Subfolder see comment #13. Theses global bindings runs the binded methods in the order of bindings, thus we must run our code AFTER the library default code.

The patch is simple: it just changes the order of library inclusions.
after patch:
After patch

  • ytsurk committed f241f5e on 2.x authored by Dom.
    Issue #3179504 by ytsurk, Dom.: (Regression) Serve jsTree from CDN if no...
ytsurk’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.