-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5459 from gaetanmaisse/ts-migration/addon-actions
Migrate addon actions to TS
- Loading branch information
Showing
26 changed files
with
175 additions
and
138 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
File renamed without changes.
File renamed without changes.
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,6 @@ | ||
export * from './constants'; | ||
export * from './preview'; | ||
|
||
if (module && module.hot && module.hot.decline) { | ||
module.hot.decline(); | ||
} |
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,11 @@ | ||
import { ActionOptions } from './ActionOptions'; | ||
|
||
export interface ActionDisplay { | ||
id: string; | ||
data: { | ||
name: string; | ||
args: any[]; | ||
}; | ||
count: number; | ||
options: ActionOptions; | ||
} |
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 @@ | ||
export interface ActionOptions { | ||
depth?: number; | ||
clearOnStoryChange?: boolean; | ||
limit?: number; | ||
} |
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 @@ | ||
import { HandlerFunction } from './HandlerFunction'; | ||
|
||
export interface ActionsMap { | ||
[key: string]: HandlerFunction; | ||
} |
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 @@ | ||
export type DecoratorFunction = (args: any[]) => any[]; |
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 @@ | ||
export type HandlerFunction = (...args: any[]) => void; |
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 @@ | ||
export * from './ActionDisplay'; | ||
export * from './ActionOptions'; | ||
export * from './ActionsMap'; | ||
export * from './DecoratorFunction'; | ||
export * from './HandlerFunction'; |
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,25 @@ | ||
import uuid from 'uuid/v1'; | ||
import { addons } from '@storybook/addons'; | ||
import { EVENT_ID } from '../constants'; | ||
import { ActionDisplay, ActionOptions, HandlerFunction } from '../models'; | ||
|
||
export function action(name: string, options: ActionOptions = {}): HandlerFunction { | ||
const actionOptions = { | ||
...options, | ||
}; | ||
|
||
// tslint:disable-next-line:no-shadowed-variable | ||
const handler = function action(...args: any[]) { | ||
const channel = addons.getChannel(); | ||
const id = uuid(); | ||
const actionDisplayToEmit: ActionDisplay = { | ||
id, | ||
count: 0, | ||
data: { name, args }, | ||
options: actionOptions, | ||
}; | ||
channel.emit(EVENT_ID, actionDisplayToEmit); | ||
}; | ||
|
||
return handler; | ||
} |
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,11 @@ | ||
import { ActionOptions } from '../models'; | ||
|
||
export const config: ActionOptions = { | ||
depth: 10, | ||
clearOnStoryChange: true, | ||
limit: 50, | ||
}; | ||
|
||
export const configureActions = (options: ActionOptions = {}): void => { | ||
Object.assign(config, options); | ||
}; |
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,5 @@ | ||
export * from './action'; | ||
export * from './actions'; | ||
export * from './configureActions'; | ||
export * from './decorateAction'; | ||
export * from './withActions'; |
Oops, something went wrong.