Skip to content

OCP namespaces for JS code #17610

Closed
Closed

Description

@PVince81

So far the JS code doesn't have any difference between public and private namespace.

We should introduce a "OCP" namespace and rewire/wrap functions/classes to their corresponding private counterparts.

Please note that Javascript doesn't have the concept of interfaces.

In some cases it might be enough to just alias a class or object, for example:

    OCP.Myclass = OC.Myclass;

In more complex cases, a wrapper class can be used. Functions can be aliased one by one, or wrapped in other functions.

The first steps would be to identify what APIs are already used by apps, like the OC namespace.

  • OCP for the main OC namespace
  • OCP.Util for OC.Util
  • OCP.Files for OC.Files (for Web UI uses Webdav instead of ajax/* calls #16902)
  • OCP.Files.FileActions to register file actions: already used by viewer apps
  • OCP.Files.FileList to be able to extend the file list class (ex: sharing overview, etc)
  • OCP.EventSource

This will significantly increase the number of Javascript files, so we might want to solve the module loading / JS dependencies problem first: #17169

If we don't it means an app developer might have to add a lot of extra files with addScript in the correct order (private first, then public) to make sure the wrapping is done properly.

This ticket is to discuss and brainstom how to do this in the future.

@MorrisJobke @Raydiation @rullzer @oparoz @icewind1991 @schiesbn @karlitschek @DeepDiver1975

Activity

  1. added this to the backlog milestone on Jul 13, 2015
  2. PVince81 commented on Jul 13, 2015

    @PVince81
    ContributorAuthor

    Hmm, remember that we also have the "OCA" namespace for apps. So file list related stuff might need to stay in "OCA". We don't have public namespaces for OCA either on the PHP side.

  3. oparoz commented on Jul 13, 2015

    @oparoz
    Contributor

    Hmm, remember that we also have the "OCA" namespace for apps

    Indeed! Might be a good idea to try and sort that one out as well. oC can't tell devs to not have inter-app communication and then only offer some APIs via OCA.Files, even if I understand that Files is a special app. There is also the problem that different methods have to be called depending on whether the Files app is reached via a private or a public URL.

    On the PHP side, we don't need to call any Files methods afaik, everything is available via the public framework or OCP.

  4. DeepDiver1975 commented on Jul 13, 2015

    @DeepDiver1975
    Contributor

    OCP namespace sounds reasonable for any logic/code which is provided by core (outside the scope of any app).

    Big question to me: which functionality would this be?

    Almost anything listed above is related to giving apps the possibility to be extended by other apps.
    (e.g. hooking up file actions)

    Based on the idea to have apps isolated and not depend on each other this is a rather tricky topic.

  5. PVince81 commented on Jul 13, 2015

    @PVince81
    ContributorAuthor

    We could have some kind of service provider in core and apps can register their service providers there. I believe we might have a similar discussion already for the PHP side.

    As for FileActions alone, we could move this to core. I think any app might be interested to get access to file viewers (ex: opening an attachment from the mail app) without having to resort to the files app (which is a file list app). But this requires all file viewers to follow a specific API and not assume that there is a file list present and just embed themselves. See #13414

  6. karlitschek commented on Jul 13, 2015

    @karlitschek
    Contributor

    makes a lot of sense IMHO. Should help to avoid a lot of strange inter app dependency bugs.

  7. th3fallen commented on Jul 13, 2015

    @th3fallen
    Contributor

    like the idea but i agree #17169 should be resolved before hand. imho

  8. oparoz commented on Aug 13, 2015

    @oparoz
    Contributor

    OCP.EventSource (JS) is missing for apps builders #12800
    In Gallery, a different polyfill is being used, but other apps may want to use the one provided in core.

  9. PVince81 commented on Aug 13, 2015

    @PVince81
    ContributorAuthor

    @oparoz added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions