Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove deprecated extension point for adding quick actions #10223

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Change: Remove deprecated extension point for adding quick actions

BREAKING CHANGE for developers: The old way of registering quick actions via the `quickaction` property of an app has been removed. Quick actions should be registered as extension via our extension registry. They need to be of type `action` and have the `files.quick-action` scope.

https://github.com/owncloud/web/pull/10102
https://github.com/owncloud/web/pull/10223
14 changes: 0 additions & 14 deletions packages/web-app-files/tests/__fixtures__/fileActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,13 @@ export const editors = [
}
]

const sideBars = [
{
app: 'details',
enabled: jest.fn(),
icon: 'information'
},
{
app: 'actions',
enabled: jest.fn(),
icon: 'information'
}
]

export const apps = {
customFileListIndicators: [],
file: {
edit: false,
path: ''
},
fileEditors: editors,
fileSideBars: sideBars,
newFileHandlers: editors,
meta
}
Expand Down
12 changes: 0 additions & 12 deletions packages/web-pkg/src/apps/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ export interface ApplicationQuickAction {
displayed?: (...args) => boolean | boolean
}

/**
* ApplicationQuickActions describes a map of application actions that are used in the runtime
*
* @deprecated Quick actions should be registered as extension via the `files.quick-action` scope.
*/
export interface ApplicationQuickActions {
[key: string]: ApplicationQuickAction
}

export type AppConfigObject = Record<string, any>

export interface ApplicationMenuItem {
Expand All @@ -64,7 +55,6 @@ export interface ApplicationInformation {
isFileEditor?: boolean
extensions?: any[]
defaultExtension?: string
fileSideBars?: any[]
Copy link
Member

Choose a reason for hiding this comment

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

thanks for cleaning those up as well 🙈

applicationMenu?: ApplicationMenuItem
}

Expand All @@ -83,8 +73,6 @@ export interface ClassicApplicationScript {
store?: Module<unknown, unknown>
routes?: ((...args) => RouteRecordRaw[]) | RouteRecordRaw[]
navItems?: ((...args) => AppNavigationItem[]) | AppNavigationItem[]
/** @deprecated Quick actions should be registered as extension via the `files.quick-action` scope. */
quickActions?: ApplicationQuickActions
translations?: ApplicationTranslations
extensions?: Ref<Extension[]>
initialize?: () => void
Expand Down
25 changes: 1 addition & 24 deletions packages/web-runtime/src/container/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import { ApiError } from '@ownclouders/web-pkg'
import { get, isEqual, isObject, isArray, merge } from 'lodash-es'
import { Module, Store } from 'vuex'
import { App, Component, h } from 'vue'
import {
ApplicationQuickActions,
ApplicationTranslations,
AppNavigationItem
} from '@ownclouders/web-pkg'
import { ApplicationTranslations, AppNavigationItem } from '@ownclouders/web-pkg'
import type { Language } from 'vue3-gettext'

/**
Expand Down Expand Up @@ -121,23 +117,6 @@ const announceTranslations = (
})
}

/**
* inject application specific quickActions into runtime
*
* @param store
* @param quickActions
*/
const announceQuickActions = (
store: Store<unknown>,
quickActions: ApplicationQuickActions
): void => {
if (!isObject(quickActions)) {
throw new ApiError("quickActions can't be blank")
}

store.commit('ADD_QUICK_ACTIONS', quickActions)
}

/**
* inject application specific store into runtime
*
Expand Down Expand Up @@ -258,8 +237,6 @@ export const buildRuntimeApi = ({
announceNavigationItems(applicationId, store, navigationItems),
announceTranslations: (appTranslations: ApplicationTranslations): void =>
announceTranslations(supportedLanguages, gettext, appTranslations),
announceQuickActions: (quickActions: ApplicationQuickActions): void =>
announceQuickActions(store, quickActions),
announceStore: (applicationStore: Module<unknown, unknown>): void =>
announceStore(applicationName, store, applicationStore),
announceExtension: (extension: { [key: string]: unknown }): void =>
Expand Down
3 changes: 1 addition & 2 deletions packages/web-runtime/src/container/application/classic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ class ClassicApplication extends NextApplication {
}

initialize(): Promise<void> {
const { routes, navItems, translations, quickActions, store } = this.applicationScript
const { routes, navItems, translations, store } = this.applicationScript
const { globalProperties } = this.app.config
const _routes = typeof routes === 'function' ? routes(globalProperties) : routes
const _navItems = typeof navItems === 'function' ? navItems(globalProperties) : navItems

routes && this.runtimeApi.announceRoutes(_routes)
navItems && this.runtimeApi.announceNavigationItems(_navItems)
translations && this.runtimeApi.announceTranslations(translations)
quickActions && this.runtimeApi.announceQuickActions(quickActions)
store && this.runtimeApi.announceStore(store)

return Promise.resolve(undefined)
Expand Down
7 changes: 1 addition & 6 deletions packages/web-runtime/src/container/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { Module, Store } from 'vuex'
import { Router, RouteRecordRaw } from 'vue-router'
import { App, Component } from 'vue'
import {
AppNavigationItem,
ApplicationQuickActions,
ApplicationTranslations
} from '@ownclouders/web-pkg'
import { AppNavigationItem, ApplicationTranslations } from '@ownclouders/web-pkg'

/** shim configuration for now, should be typed in a later step */
export type RuntimeConfiguration = any
Expand All @@ -15,7 +11,6 @@ export interface RuntimeApi {
announceRoutes: (routes: RouteRecordRaw[]) => void
announceNavigationItems: (navigationItems: AppNavigationItem[]) => void
announceTranslations: (appTranslations: ApplicationTranslations) => void
announceQuickActions: (quickActions: ApplicationQuickActions) => void
announceStore: (applicationStore: Module<unknown, unknown>) => void
announceExtension: (extension: { [key: string]: unknown }) => void
requestStore: () => Store<unknown>
Expand Down
6 changes: 1 addition & 5 deletions packages/web-runtime/src/store/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const state = {
messages: [],
quickActions: {}
messages: []
}

const actions = {
Expand Down Expand Up @@ -58,9 +57,6 @@ const mutations = {
},
REMOVE_MESSAGE(state, item) {
state.messages.splice(state.messages.indexOf(item), 1)
},
ADD_QUICK_ACTIONS(state, quickActions) {
state.quickActions = Object.assign(state.quickActions, quickActions)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ export const defaultStoreMockOptions = {
state: {
fileEditors: [],
meta: {}
},
getters: {
fileSideBars: jest.fn(() => [])
}
},
External: {
Expand Down