MCPcopy Create free account
hub / github.com/microsoft/SandDance / DataSourceButton

Function DataSourceButton

packages/sanddance-app/src/dataSourcePicker.tsx:21–72  ·  view source on GitHub ↗
(props: ButtonProps)

Source from the content-addressed store, hash-verified

19}
20
21export function DataSourceButton(props: ButtonProps) {
22 const picker = props.getPicker();
23 if (!picker) return null;
24 const menuProps: FluentUITypes.IContextualMenuProps = {
25 items: [
26 {
27 key: 'sample-section',
28 itemType: base.fluentUI.ContextualMenuItemType.Section,
29 sectionProps: {
30 title: strings.sampleDataPrefix,
31 items: props.dataSources.map((ds, i) => {
32 const item: FluentUITypes.IContextualMenuItem = {
33 key: ds.id,
34 text: ds.displayName,
35 onClick: e => {
36 picker.changeDataSource(ds);
37 },
38 };
39 return item;
40 }),
41 },
42 },
43 {
44 key: 'user-section',
45 itemType: base.fluentUI.ContextualMenuItemType.Section,
46 sectionProps: {
47 topDivider: true,
48 title: strings.menuUserData,
49 items: [
50 {
51 key: 'local',
52 text: strings.menuLocal,
53 onClick: e => picker.setState({ dialogMode: 'local' }),
54 },
55 {
56 key: 'url',
57 text: strings.menuUrl,
58 onClick: e => picker.setState({ dialogMode: 'url' }),
59 },
60 ],
61 },
62 },
63 ],
64 };
65 return (
66 <base.fluentUI.PrimaryButton
67 className="sanddance-datasource-picker"
68 text={dataSourcePrefix(props.dataSource.dataSourceType, props.dataSource.displayName)}
69 menuProps={menuProps}
70 />
71 );
72}
73
74export interface DialogProps extends Props {
75 theme: string;

Callers

nothing calls this directly

Calls 2

dataSourcePrefixFunction · 0.70
changeDataSourceMethod · 0.45

Tested by

no test coverage detected