|
@@ -1,71 +1 @@
|
|
|
-const { UIPlugin } = require('@uppy/core')
|
|
|
-const { Provider } = require('@uppy/companion-client')
|
|
|
-const { ProviderViews } = require('@uppy/provider-views')
|
|
|
-const { h } = require('preact')
|
|
|
-
|
|
|
-const locale = require('./locale')
|
|
|
-
|
|
|
-module.exports = class OneDrive extends UIPlugin {
|
|
|
- static VERSION = require('../package.json').version
|
|
|
-
|
|
|
- constructor (uppy, opts) {
|
|
|
- super(uppy, opts)
|
|
|
- this.id = this.opts.id || 'OneDrive'
|
|
|
- Provider.initPlugin(this, opts)
|
|
|
- this.title = this.opts.title || 'OneDrive'
|
|
|
- this.icon = () => (
|
|
|
- <svg aria-hidden="true" focusable="false" width="32" height="32" viewBox="0 0 32 32">
|
|
|
- <g fill="none" fillRule="evenodd">
|
|
|
- <rect className="uppy-ProviderIconBg" width="32" height="32" rx="16" fill="#0262C0" />
|
|
|
- <g fill="#FFF" fillRule="nonzero">
|
|
|
- <path d="M24.157 22s1.492-.205 1.79-1.655a2.624 2.624 0 0 0 .03-.878c-.22-1.64-1.988-2.01-1.988-2.01s.307-1.765-1.312-2.69c-1.62-.925-3.1 0-3.1 0S18.711 13 16.366 13c-3.016 0-3.519 3.448-3.519 3.448S10 16.618 10 19.14c0 2.523 2.597 2.86 2.597 2.86h11.56z" />
|
|
|
- <path d="M9.421 19.246c0-2.197 1.606-3.159 2.871-3.472.44-1.477 1.654-3.439 4.135-3.439H16.445c1.721 0 2.79.823 3.368 1.476a3.99 3.99 0 0 1 1.147-.171h.01l.03.002C21.017 13.5 20.691 10 16.757 10c-2.69 0-3.639 2.345-3.639 2.345s-1.95-1.482-3.955.567c-1.028 1.052-.79 2.669-.79 2.669S6 15.824 6 18.412C6 20.757 8.452 21 8.452 21h1.372a3.77 3.77 0 0 1-.403-1.754z" />
|
|
|
- </g>
|
|
|
- </g>
|
|
|
- </svg>
|
|
|
- )
|
|
|
-
|
|
|
- this.provider = new Provider(uppy, {
|
|
|
- companionUrl: this.opts.companionUrl,
|
|
|
- companionHeaders: this.opts.companionHeaders,
|
|
|
- companionCookiesRule: this.opts.companionCookiesRule,
|
|
|
- provider: 'onedrive',
|
|
|
- pluginId: this.id,
|
|
|
- })
|
|
|
-
|
|
|
- this.defaultLocale = locale
|
|
|
-
|
|
|
- this.i18nInit()
|
|
|
- this.title = this.i18n('pluginNameOneDrive')
|
|
|
-
|
|
|
- this.onFirstRender = this.onFirstRender.bind(this)
|
|
|
- this.render = this.render.bind(this)
|
|
|
- }
|
|
|
-
|
|
|
- install () {
|
|
|
- this.view = new ProviderViews(this, {
|
|
|
- provider: this.provider,
|
|
|
- })
|
|
|
-
|
|
|
- const { target } = this.opts
|
|
|
- if (target) {
|
|
|
- this.mount(target, this)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- uninstall () {
|
|
|
- this.view.tearDown()
|
|
|
- this.unmount()
|
|
|
- }
|
|
|
-
|
|
|
- onFirstRender () {
|
|
|
- return Promise.all([
|
|
|
- this.provider.fetchPreAuthToken(),
|
|
|
- this.view.getFolder(),
|
|
|
- ])
|
|
|
- }
|
|
|
-
|
|
|
- render (state) {
|
|
|
- return this.view.render(state)
|
|
|
- }
|
|
|
-}
|
|
|
+export { default } from './OneDrive.jsx'
|