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

@uppy/dashboard: add dashboard:show-panel event #4108

Merged
merged 4 commits into from
Sep 15, 2022
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
2 changes: 2 additions & 0 deletions packages/@uppy/dashboard/src/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ export default class Dashboard extends UIPlugin {
activePickerPanel,
activeOverlayType: 'PickerPanel',
})

this.uppy.emit('dashboard:show-panel', id)
}

canEditFile = (file) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/@uppy/dashboard/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ export default Dashboard

export type DashboardFileEditStartCallback<TMeta extends IndexedObject<any>> = (file?: UppyFile<TMeta>) => void;
export type DashboardFileEditCompleteCallback<TMeta extends IndexedObject<any>> = (file?: UppyFile<TMeta>) => void;
export type DashboardShowPlanelCallback = (id: string) => void;
declare module '@uppy/core' {
export interface UppyEventMap<TMeta> {
'dashboard:modal-open': GenericEventCallback
'dashboard:modal-closed': GenericEventCallback
'dashboard:file-edit-state': DashboardFileEditStartCallback<TMeta>
'dashboard:show-panel': DashboardShowPlanelCallback
'dashboard:file-edit-start': DashboardFileEditStartCallback<TMeta>
'dashboard:file-edit-complete': DashboardFileEditCompleteCallback<TMeta>
}
}
6 changes: 5 additions & 1 deletion packages/@uppy/dashboard/types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ import Dashboard from '..'
onDragLeave: (event) => event.clientX,
})

uppy.on('dashboard:file-edit-state', (file) => {
uppy.on('dashboard:file-edit-start', (file) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const fileName = file?.name
})
uppy.on('dashboard:show-panel', (id) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const pluginId = id
})
}

{
Expand Down
2 changes: 1 addition & 1 deletion website/src/_posts/2021-08-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Plugins that add their own events can merge with existing ones in `@uppy/core` w

<!-- eslint-disable @typescript-eslint/no-unused-vars -->
```ts
uppy.on('dashboard:file-edit-state', (file) => {
uppy.on('dashboard:file-edit-start', (file) => {
const fileName = file.name
})
```
Expand Down
8 changes: 8 additions & 0 deletions website/src/docs/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,14 @@ uppy.on('dashboard:modal-open', () => {

Fired when the Dashboard modal is closed.

### `dashboard:show-panel`

**Parameters:**

* `id` — The unique identifier of the plugin that is being shown

Fired when a user clicks on a source plugin, such as Webcam or Google Drive, in the Dashboard.

### `dashboard:file-edit-start`

**Parameters:**
Expand Down
2 changes: 1 addition & 1 deletion website/src/docs/migration-guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ Plugins that add their own events can merge with existing ones in `@uppy/core` w
<!-- eslint-disable @typescript-eslint/no-unused-vars -->

```ts
uppy.on('dashboard:file-edit-state', (file) => {
uppy.on('dashboard:file-edit-start', (file) => {
const fileName = file.name
})
```
Expand Down