Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Drop
install
entry point and replace it with an Vue Plugin
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
- Loading branch information
Showing
7 changed files
with
89 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { DefineComponent, Directive, PluginObject } from 'vue' | ||
|
||
import * as NcComponents from './components/index.js' | ||
import * as NcDirectives from './directives/index.js' | ||
|
||
/** | ||
* Install all Nextcloud Vue components and directives globally | ||
* @example | ||
* ```js | ||
* import { NextcloudVuePlugin } from '@nextcloud/vue' | ||
* import Vue from 'vue' | ||
* | ||
* // ... | ||
* | ||
* Vue.use(NextcloudVuePlugin) | ||
* new Vue({ | ||
* // options | ||
* }) | ||
* ``` | ||
*/ | ||
export const NextcloudVuePlugin: PluginObject<never> = { | ||
install(Vue) { | ||
// Install components | ||
Object.entries(NcComponents as { [key: string]: DefineComponent }).forEach(([name, component]) => { | ||
Vue.component(component.name || name, component) | ||
}) | ||
|
||
// Install directives | ||
Object.entries(NcDirectives as { [key: string]: Directive }).forEach(([name, directive]) => { | ||
Vue.directive(name, directive) | ||
}) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @copyright Copyright (c) 2023 Ferdinand Thiessen <opensource@fthiessen.de> | ||
* | ||
* @author Ferdinand Thiessen <opensource@fthiessen.de> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
import { NextcloudVuePlugin } from '../../src/plugin' | ||
import { createLocalVue, mount } from '@vue/test-utils' | ||
|
||
describe('Nextcloud Vue Plugin', () => { | ||
'use strict' | ||
|
||
it('can be installed', () => { | ||
const localVue = createLocalVue() | ||
localVue.use(NextcloudVuePlugin) | ||
const wrapper = mount({ render: (h) => h('NcButton') }, { localVue }) | ||
expect(wrapper.vm.$el.tagName).toBe('BUTTON') // If it could no be installed it would be 'NCBUTTON' | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters