-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mobile: Plugin support: Simplify reporting plugin issues (#10319)
- Loading branch information
1 parent
34b2654
commit aec77b5
Showing
11 changed files
with
289 additions
and
62 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
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,83 @@ | ||
import * as React from 'react'; | ||
import { useMemo } from 'react'; | ||
import { StyleSheet, View, ViewStyle, useWindowDimensions } from 'react-native'; | ||
import { IconButton, Surface } from 'react-native-paper'; | ||
import { themeStyle } from './global-style'; | ||
import Modal from './Modal'; | ||
import { _ } from '@joplin/lib/locale'; | ||
|
||
interface Props { | ||
themeId: number; | ||
visible: boolean; | ||
onDismiss: ()=> void; | ||
containerStyle?: ViewStyle; | ||
children: React.ReactNode; | ||
} | ||
|
||
const useStyles = (themeId: number, containerStyle: ViewStyle) => { | ||
const windowSize = useWindowDimensions(); | ||
|
||
return useMemo(() => { | ||
const theme = themeStyle(themeId); | ||
|
||
return StyleSheet.create({ | ||
webView: { | ||
backgroundColor: 'transparent', | ||
display: 'flex', | ||
}, | ||
webViewContainer: { | ||
flexGrow: 1, | ||
flexShrink: 1, | ||
}, | ||
closeButtonContainer: { | ||
flexDirection: 'row', | ||
justifyContent: 'flex-end', | ||
}, | ||
dialog: { | ||
backgroundColor: theme.backgroundColor, | ||
borderRadius: 12, | ||
padding: 10, | ||
|
||
height: windowSize.height * 0.9, | ||
width: windowSize.width * 0.97, | ||
|
||
// Center | ||
marginLeft: 'auto', | ||
marginRight: 'auto', | ||
|
||
...containerStyle, | ||
}, | ||
}); | ||
}, [themeId, windowSize.width, windowSize.height, containerStyle]); | ||
}; | ||
|
||
const DismissibleDialog: React.FC<Props> = props => { | ||
const styles = useStyles(props.themeId, props.containerStyle); | ||
|
||
const closeButton = ( | ||
<View style={styles.closeButtonContainer}> | ||
<IconButton | ||
icon='close' | ||
accessibilityLabel={_('Close')} | ||
onPress={props.onDismiss} | ||
/> | ||
</View> | ||
); | ||
|
||
return ( | ||
<Modal | ||
visible={props.visible} | ||
onDismiss={props.onDismiss} | ||
onRequestClose={props.onDismiss} | ||
animationType='fade' | ||
transparent={true} | ||
> | ||
<Surface style={styles.dialog} elevation={1}> | ||
{closeButton} | ||
{props.children} | ||
</Surface> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default DismissibleDialog; |
115 changes: 115 additions & 0 deletions
115
packages/app-mobile/components/screens/ConfigScreen/plugins/PluginBox/PluginInfoButton.tsx
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,115 @@ | ||
import { PluginItem } from '@joplin/lib/components/shared/config/plugins/types'; | ||
import * as React from 'react'; | ||
import { _ } from '@joplin/lib/locale'; | ||
import { useCallback, useMemo, useState } from 'react'; | ||
import { Button, IconButton, List, Portal, Text } from 'react-native-paper'; | ||
import getPluginIssueReportUrl from '@joplin/lib/services/plugins/utils/getPluginIssueReportUrl'; | ||
import { Linking, ScrollView, StyleSheet, View } from 'react-native'; | ||
import DismissibleDialog from '../../../../DismissibleDialog'; | ||
import openWebsiteForPlugin from '../utils/openWebsiteForPlugin'; | ||
|
||
interface Props { | ||
themeId: number; | ||
size: number; | ||
item: PluginItem; | ||
onModalDismiss?: ()=> void; | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
aboutPluginContainer: { | ||
paddingLeft: 10, | ||
paddingRight: 10, | ||
paddingBottom: 10, | ||
}, | ||
descriptionText: { | ||
marginTop: 5, | ||
marginBottom: 5, | ||
}, | ||
fraudulentPluginButton: { | ||
opacity: 0.6, | ||
}, | ||
}); | ||
|
||
const PluginInfoModal: React.FC<Props> = props => { | ||
const aboutPlugin = ( | ||
<View style={styles.aboutPluginContainer}> | ||
<Text variant='titleLarge'>{props.item.manifest.name}</Text> | ||
<Text variant='bodyLarge'>{props.item.manifest.author ? _('by %s', props.item.manifest.author) : ''}</Text> | ||
<Text style={styles.descriptionText}>{props.item.manifest.description ?? _('No description')}</Text> | ||
</View> | ||
); | ||
|
||
const onAboutPress = useCallback(() => { | ||
void openWebsiteForPlugin({ item: props.item }); | ||
}, [props.item]); | ||
|
||
const reportIssueUrl = useMemo(() => { | ||
return getPluginIssueReportUrl(props.item.manifest); | ||
}, [props.item]); | ||
|
||
const onReportIssuePress = useCallback(() => { | ||
void Linking.openURL(reportIssueUrl); | ||
}, [reportIssueUrl]); | ||
|
||
const reportIssueButton = ( | ||
<List.Item | ||
left={props => <List.Icon {...props} icon='bug'/>} | ||
title={_('Report an issue')} | ||
onPress={onReportIssuePress} | ||
/> | ||
); | ||
|
||
const onReportFraudulentPress = useCallback(() => { | ||
void Linking.openURL('https://github.com/laurent22/joplin/security/advisories/new'); | ||
}, []); | ||
|
||
return ( | ||
<Portal> | ||
<DismissibleDialog | ||
themeId={props.themeId} | ||
visible={true} | ||
onDismiss={props.onModalDismiss} | ||
> | ||
<ScrollView> | ||
{aboutPlugin} | ||
<List.Item | ||
left={props => <List.Icon {...props} icon='web'/>} | ||
title={_('About')} | ||
onPress={onAboutPress} | ||
/> | ||
{ reportIssueUrl ? reportIssueButton : null } | ||
</ScrollView> | ||
<Button | ||
icon='shield-bug' | ||
style={styles.fraudulentPluginButton} | ||
onPress={onReportFraudulentPress} | ||
>{_('Report fraudulent plugin')}</Button> | ||
</DismissibleDialog> | ||
</Portal> | ||
); | ||
}; | ||
|
||
const PluginInfoButton: React.FC<Props> = props => { | ||
const [showInfoModal, setShowInfoModal] = useState(false); | ||
const onInfoButtonPress = useCallback(() => { | ||
setShowInfoModal(true); | ||
}, []); | ||
|
||
const onModalDismiss = useCallback(() => { | ||
setShowInfoModal(false); | ||
props.onModalDismiss?.(); | ||
}, [props.onModalDismiss]); | ||
|
||
return ( | ||
<> | ||
{showInfoModal ? <PluginInfoModal {...props} onModalDismiss={onModalDismiss} /> : null} | ||
<IconButton | ||
size={props.size} | ||
icon='information' | ||
onPress={onInfoButtonPress} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default PluginInfoButton; |
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
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
Oops, something went wrong.