-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* main: @uppy/google-drive: refactor to ESM (#3683) meta: harden linter rule for JSX/ESM validation (#3681) meta: harden linter rules for ESM/CJS validation (#3674)
- Loading branch information
Showing
13 changed files
with
201 additions
and
168 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable react/react-in-jsx-scope */ | ||
import Uppy from '@uppy/core' | ||
// eslint-disable-next-line no-unused-vars | ||
import React from 'react' | ||
import { Dashboard } from '@uppy/react' | ||
|
||
import '@uppy/core/dist/style.css' | ||
import '@uppy/dashboard/dist/style.css' | ||
|
||
export default App | ||
|
||
function App () { | ||
// Ideally we test with the `useUppy` hook, | ||
// as that's how it should be used. | ||
// But that results in breaking the rules of hooks errors? | ||
const uppy = new Uppy() | ||
|
||
return <Dashboard uppy={uppy} /> | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-disable react/react-in-jsx-scope */ | ||
import ReactDOM from 'react-dom' | ||
import App from './App.jsx' | ||
|
||
ReactDOM.render(<App />, document.getElementById('app')) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { UIPlugin } from '@uppy/core' | ||
import { Provider } from '@uppy/companion-client' | ||
import { h } from 'preact' | ||
|
||
import packageJson from '../package.json' | ||
import DriveProviderViews from './DriveProviderViews.js' | ||
import locale from './locale.js' | ||
|
||
export default class GoogleDrive extends UIPlugin { | ||
static VERSION = packageJson.version | ||
|
||
constructor (uppy, opts) { | ||
super(uppy, opts) | ||
this.id = this.opts.id || 'GoogleDrive' | ||
this.title = this.opts.title || 'Google Drive' | ||
Provider.initPlugin(this, opts) | ||
this.title = this.opts.title || 'Google Drive' | ||
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" | ||
fill="#4285F4" | ||
width="32" | ||
height="32" | ||
rx="16" | ||
/> | ||
<path | ||
d="M25.216 17.736L19.043 7h-6.086l6.175 10.736h6.084zm-11.275.896L10.9 24h11.723l3.04-5.368H13.942zm-1.789-10.29l-5.816 10.29L9.38 24l5.905-10.29-3.132-5.369z" | ||
fill="#FFF" | ||
/> | ||
</g> | ||
</svg> | ||
) | ||
|
||
this.provider = new Provider(uppy, { | ||
companionUrl: this.opts.companionUrl, | ||
companionHeaders: this.opts.companionHeaders, | ||
companionKeysParams: this.opts.companionKeysParams, | ||
companionCookiesRule: this.opts.companionCookiesRule, | ||
provider: 'drive', | ||
pluginId: this.id, | ||
}) | ||
|
||
this.defaultLocale = locale | ||
|
||
this.i18nInit() | ||
this.title = this.i18n('pluginNameGoogleDrive') | ||
|
||
this.onFirstRender = this.onFirstRender.bind(this) | ||
this.render = this.render.bind(this) | ||
} | ||
|
||
install () { | ||
this.view = new DriveProviderViews(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('root', '/'), | ||
]) | ||
} | ||
|
||
render (state) { | ||
return this.view.render(state) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,85 +1 @@ | ||
const { UIPlugin } = require('@uppy/core') | ||
const { Provider } = require('@uppy/companion-client') | ||
const { h } = require('preact') | ||
const DriveProviderViews = require('./DriveProviderViews') | ||
|
||
const locale = require('./locale') | ||
|
||
module.exports = class GoogleDrive extends UIPlugin { | ||
static VERSION = require('../package.json').version | ||
|
||
constructor (uppy, opts) { | ||
super(uppy, opts) | ||
this.id = this.opts.id || 'GoogleDrive' | ||
this.title = this.opts.title || 'Google Drive' | ||
Provider.initPlugin(this, opts) | ||
this.title = this.opts.title || 'Google Drive' | ||
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" | ||
fill="#4285F4" | ||
width="32" | ||
height="32" | ||
rx="16" | ||
/> | ||
<path | ||
d="M25.216 17.736L19.043 7h-6.086l6.175 10.736h6.084zm-11.275.896L10.9 24h11.723l3.04-5.368H13.942zm-1.789-10.29l-5.816 10.29L9.38 24l5.905-10.29-3.132-5.369z" | ||
fill="#FFF" | ||
/> | ||
</g> | ||
</svg> | ||
) | ||
|
||
this.provider = new Provider(uppy, { | ||
companionUrl: this.opts.companionUrl, | ||
companionHeaders: this.opts.companionHeaders, | ||
companionKeysParams: this.opts.companionKeysParams, | ||
companionCookiesRule: this.opts.companionCookiesRule, | ||
provider: 'drive', | ||
pluginId: this.id, | ||
}) | ||
|
||
this.defaultLocale = locale | ||
|
||
this.i18nInit() | ||
this.title = this.i18n('pluginNameGoogleDrive') | ||
|
||
this.onFirstRender = this.onFirstRender.bind(this) | ||
this.render = this.render.bind(this) | ||
} | ||
|
||
install () { | ||
this.view = new DriveProviderViews(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('root', '/'), | ||
]) | ||
} | ||
|
||
render (state) { | ||
return this.view.render(state) | ||
} | ||
} | ||
export { default } from './GoogleDrive.jsx' |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
export default { | ||
strings: { | ||
pluginNameGoogleDrive: 'Google Drive', | ||
}, | ||
|
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
Oops, something went wrong.