({
pluginName,
pluginDescription,
marketplaceName,
sourceCommand,
onResponse
}: Props)
| 11 | }; |
| 12 | const AUTO_DISMISS_MS = 30_000; |
| 13 | export function PluginHintMenu({ |
| 14 | pluginName, |
| 15 | pluginDescription, |
| 16 | marketplaceName, |
| 17 | sourceCommand, |
| 18 | onResponse |
| 19 | }: Props): React.ReactNode { |
| 20 | const onResponseRef = React.useRef(onResponse); |
| 21 | onResponseRef.current = onResponse; |
| 22 | React.useEffect(() => { |
| 23 | const timeoutId = setTimeout(ref => ref.current('no'), AUTO_DISMISS_MS, onResponseRef); |
| 24 | return () => clearTimeout(timeoutId); |
| 25 | }, []); |
| 26 | function onSelect(value: string): void { |
| 27 | switch (value) { |
| 28 | case 'yes': |
| 29 | onResponse('yes'); |
| 30 | break; |
| 31 | case 'disable': |
| 32 | onResponse('disable'); |
| 33 | break; |
| 34 | default: |
| 35 | onResponse('no'); |
| 36 | } |
| 37 | } |
| 38 | const options = [{ |
| 39 | label: <Text> |
| 40 | Yes, install <Text bold>{pluginName}</Text> |
| 41 | </Text>, |
| 42 | value: 'yes' |
| 43 | }, { |
| 44 | label: 'No', |
| 45 | value: 'no' |
| 46 | }, { |
| 47 | label: "No, and don't show plugin installation hints again", |
| 48 | value: 'disable' |
| 49 | }]; |
| 50 | return <PermissionDialog title="Plugin Recommendation"> |
| 51 | <Box flexDirection="column" paddingX={2} paddingY={1}> |
| 52 | <Box marginBottom={1}> |
| 53 | <Text dimColor> |
| 54 | The <Text bold>{sourceCommand}</Text> command suggests installing a |
| 55 | plugin. |
| 56 | </Text> |
| 57 | </Box> |
| 58 | <Box> |
| 59 | <Text dimColor>Plugin:</Text> |
| 60 | <Text> {pluginName}</Text> |
| 61 | </Box> |
| 62 | <Box> |
| 63 | <Text dimColor>Marketplace:</Text> |
| 64 | <Text> {marketplaceName}</Text> |
| 65 | </Box> |
| 66 | {pluginDescription && <Box> |
| 67 | <Text dimColor>{pluginDescription}</Text> |
| 68 | </Box>} |
| 69 | <Box marginTop={1}> |
| 70 | <Text>Would you like to install it?</Text> |
nothing calls this directly
no test coverage detected