import React from 'react';
import { StoryFn, Meta } from '@storybook/react';
import ResourceLauncher from './ResourceLauncher';
import sampleSources from '../__mocks__/sample-sources.json';
import { ResourceBrowserSourceWithPlugin, PluginLaunchMode, PluginLaunchModeType } from '../types';
const DummyLauncher = ({
source,
onSearch,
onBrowse,
}: {
source: any;
onSearch: (query: string) => void;
onBrowse: (browseTo: string) => void;
}) => (
{source.name}
);
const sourcesWithDummyPlugin = (sampleSources as any[]).map((source) => ({
...source,
plugin: {
...source.plugin,
type: source.plugin?.type || 'dummy',
// renderResourceLauncher should return a component. Here we return a function that renders DummyLauncher.
renderResourceLauncher: () => DummyLauncher,
},
})) as ResourceBrowserSourceWithPlugin[];
export default {
title: 'Resource Launcher',
component: ResourceLauncher,
} as Meta;
const Template: StoryFn = (args) => {
return (
{
console.log(`Source ${source?.name} / ${source.id} was selected with mode:`, mode);
}}
/>
);
};
export const Primary = Template.bind({});
Primary.args = {};