Skip to content
This repository was archived by the owner on Nov 23, 2026. It is now read-only.
This repository was archived by the owner on Nov 23, 2026. It is now read-only.

Sharing logic between extensions #3301

Closed

Description

@LukasHirt

As nicely pointed out by @dschmidt in #3294, since some extensions are closely tied together they soon become sharing some logic which at the moment leads mostly to duplicate code. An example is the loading of a folder as seen in the mentioned PR. Currently, we tried to tackle this via store but that is getting slightly out of hand. I'd see a few possible approaches:

1. Keep using store

We might consider still using the store for this but that would mean that we'd keep abusing it in a way it wasn't really intended to (logic not directly related to state). Also, this would probably mean some cleanup works in the store.

2. Use owncloud-sdk

Extending owncloud-sdk could also be an option. However, I am not sure if this would be the right place for this. In this case, we need to keep in mind that any Vue related logic can't live there and that extending the SDK with logic like this would probably be undesired.

3. Core plugin

This would allow us to easily reuse the logic and also would be the easiest for keeping the Vue functionality. The problem here is that we'd kind of make core dependent on the extensions which shouldn't happen. Also, this would declare the logic globally and it would be loaded every time even when it's not needed so having some bigger logic would be an anti-pattern.

4. Mixins

At the moment, we can't access mixins from different extensions but we might consider making this a new extension point. Extensions could than declare helpers/plugins which other extensions could reuse. From all of the approaches, this seems like the one with the most effort and TBH I am not sure at all if we want to create and maintain such an extension point.

I'll be super happy for any input, ideas, ... @dschmidt @PVince81 @kulmann @DeepDiver1975

Activity

  1. DeepDiver1975 commented on Apr 8, 2020

    @DeepDiver1975
    Contributor

    What I'm fighting for a long time - again only explanations - team decides on next steps
    In an ideal world we are builing one SPA for one purpose and keep this a self-contained codebase.
    This goes into the old discussion of micro frontends.

    So there is one SPA - e.g. the files management - anything which is related to files should live in this one SPA - with this you can use all powers of given components and frontend logic.

    So in case of displaying images: is this part of the files app? yes -> move the logic into the files SPA.

    In case one thinks displaying files is more the task of a gallery SPA we need a new SPA specialiced in displaying media including exif information, time and tag based sorting and so on ....

    Extending the files SPA is a necessity for very specific tasks - e.g. having an additional sidebar for one file - we use this to mixing customer specific logic. (Which by today is questionable if this has to be done at runtime - it is anyhow a custom build phoenix as of today)

  2. dschmidt commented on Apr 8, 2020

    @dschmidt
    Member

    Even if we have an external gallery SPA, that would also need to be able to load a folder or specific files - probably also public link folders, favorites, whatever.
    Loading of that folder or file should not be more complicated than passing in some route params into a function (if at all).

    At least noone should need to replicate a function like this in their own code, especially not with all those magic public-files and favorites strings:
    https://github.com/owncloud/phoenix/blob/9ac4081d15f88bac8274ef9b37b05692170bae87/apps/files/src/store/actions.js#L325-L386

    It's a bit unfortunate that the context is now the routeName and nothing more formalized than that.

    Moreover we should handle passwords (asking for them) in a standardized way.

  3. DeepDiver1975 commented on Apr 8, 2020

    @DeepDiver1975
    Contributor

    Loading a File from any location (Public Link, Users own Files, favorites ....) Should bei reflected in a path(or graph or namespace).
    In this Case No Logic has to be duplicated

  4. dschmidt commented on Apr 8, 2020

    @dschmidt
    Member

    Yes, but that's currently not the case, right?

    There's no universal path that all involved components understand, right?
    (We chatted about that already the other day, just to document it here)

    That's why this overcomplicated loadFolder method exists probably. So yes, a universally valid URL would do the trick or some kind of namespace. That would be no different than the routeName we currently use, just not bound to the frontend routeName but something formalized in the data layer? Or is there already an existing namespace concept you are referring to?

  5. DeepDiver1975 commented on Apr 8, 2020

    @DeepDiver1975
    Contributor

    There is a long discussion about the namespace in the ocis/reva working group @butonic

  6. dschmidt commented on Dec 7, 2022

    @dschmidt
    Member

    I have a feeling, it's finally time to close this!

    My main complaint was about having to implement folder loading in apps. For quite some time we have the appDefaults composable in web-pkg which is shared among extensions and solves my initial problem and handles even quite a bit more by now.
    Whether it uses the store, the sdk or some other implementation doesn't matter to me at this point.

    Core plugin is rather unspecific as a proposal and probably just obsolete now. Mixins are dead, long live composables!

    The drive alias pr introduced a proper concept for urls and basically made spaces the namespaces we've been talking about here.

    As a nice bonus even password handling is now happening in a standard way, since we merged the auth context pr.

    We've come a long way...

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions