Showcase: File as expense extensions
Closed, ResolvedPublic

Description

A simple extensions consisting of:

  • A button in the mail view "File as Expense"
  • When clicked it forwards the email to some hardcoded email address.

The whole thing must be an external plugin that is dynamically loaded.

Related Objects

cmollekopf triaged this task as Normal priority.

This has now been implemented and is available from develop. The mechanism consists of two parts:

The extension point in MailViewer.qml:

Row {
    Kube.ExtensionPoint {
        extensionPoint: "extensions/mailview"
        context: {"mail": footer.mail, "subject": footer.subject, "accountId": currentAccount}
    }
}

The ExtensionPoint in the positioner (it's a repeater on top of an extension loading model).
The ExtensionPoint will simply instantiate any components that are installed in the relevant location (as defined by extensionPoint).
The context contains all information that the extension ultimately has available to work with.

Extension implementation in main.qml:

import QtQuick 2.7
import org.kube.framework 1.0 as Kube
import org.kube.extensionapi 1.0

Kube.Button {
    property variant context: {}
    visible: true
    activeFocusOnTab: false

    text: qsTr("File as Expense")
    onClicked: {
        ExtensionApi.forwardMail({mail: context.mail, to: ["test1@kolab.org"], subject: "Expense: " + context.subject, accountId: context.accountId})
    }
}

The extensions main Component must be called main.qml (by convention, otherwise it won't be found).
The extensionapi plugin exposes a dedicated ExtensionApi that we can use to:

  • make extension development as easy as possible for the intended purposed
  • ensure that we have an API that we could choose to keep stable (instead of requiring the same for everything of org.kube.framework).

Arguably the use of Kube.Button is therefore also not ideal. We could instead separate that into org.kube.controls and declare that ok, or somehow expose the controls through the extension plugin as well (not sure how that would work exactly).

cmollekopf moved this task from Backlog to Misc on the Kube board.Dec 26 2018, 9:30 PM
cmollekopf lowered the priority of this task from Normal to Wishlist.
cmollekopf closed this task as Resolved.
cmollekopf claimed this task.