-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add label appeal tool to posts and accounts (#2124)
* Add label appeal tool to posts and accounts * Fix translations
- Loading branch information
Showing
12 changed files
with
846 additions
and
380 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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,139 @@ | ||
import React, {useState} from 'react' | ||
import {StyleSheet, TouchableOpacity, View} from 'react-native' | ||
import {ComAtprotoModerationDefs} from '@atproto/api' | ||
import {ScrollView, TextInput} from './util' | ||
import {Text} from '../util/text/Text' | ||
import {s, colors} from 'lib/styles' | ||
import {usePalette} from 'lib/hooks/usePalette' | ||
import {Trans, msg} from '@lingui/macro' | ||
import {useLingui} from '@lingui/react' | ||
import {useModalControls} from '#/state/modals' | ||
import {CharProgress} from '../composer/char-progress/CharProgress' | ||
import {getAgent} from '#/state/session' | ||
import * as Toast from '../util/Toast' | ||
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' | ||
|
||
export const snapPoints = ['40%'] | ||
|
||
type ReportComponentProps = | ||
| { | ||
uri: string | ||
cid: string | ||
} | ||
| { | ||
did: string | ||
} | ||
|
||
export function Component(props: ReportComponentProps) { | ||
const pal = usePalette('default') | ||
const [details, setDetails] = useState<string>('') | ||
const {_} = useLingui() | ||
const {closeModal} = useModalControls() | ||
const {isMobile} = useWebMediaQueries() | ||
const isAccountReport = 'did' in props | ||
|
||
const submit = async () => { | ||
try { | ||
const $type = !isAccountReport | ||
? 'com.atproto.repo.strongRef' | ||
: 'com.atproto.admin.defs#repoRef' | ||
await getAgent().createModerationReport({ | ||
reasonType: ComAtprotoModerationDefs.REASONOTHER, | ||
subject: { | ||
$type, | ||
...props, | ||
}, | ||
reason: details, | ||
}) | ||
Toast.show("We'll look into your appeal promptly.") | ||
} finally { | ||
closeModal() | ||
} | ||
} | ||
|
||
return ( | ||
<View | ||
style={[ | ||
pal.view, | ||
s.flex1, | ||
isMobile ? {paddingHorizontal: 12} : undefined, | ||
]} | ||
testID="appealLabelModal"> | ||
<Text | ||
type="2xl-bold" | ||
style={[pal.text, s.textCenter, {paddingBottom: 8}]}> | ||
<Trans>Appeal Decision</Trans> | ||
</Text> | ||
<ScrollView> | ||
<View style={[pal.btn, styles.detailsInputContainer]}> | ||
<TextInput | ||
accessibilityLabel={_(msg`Text input field`)} | ||
accessibilityHint={_( | ||
msg`Please tell us why you think this decision was incorrect.`, | ||
)} | ||
placeholder={_( | ||
msg`Please tell us why you think this decision was incorrect.`, | ||
)} | ||
placeholderTextColor={pal.textLight.color} | ||
value={details} | ||
onChangeText={setDetails} | ||
autoFocus={true} | ||
numberOfLines={3} | ||
multiline={true} | ||
textAlignVertical="top" | ||
maxLength={300} | ||
style={[styles.detailsInput, pal.text]} | ||
/> | ||
<View style={styles.detailsInputBottomBar}> | ||
<View style={styles.charCounter}> | ||
<CharProgress count={details?.length || 0} /> | ||
</View> | ||
</View> | ||
</View> | ||
<TouchableOpacity | ||
testID="confirmBtn" | ||
onPress={submit} | ||
style={styles.btn} | ||
accessibilityRole="button" | ||
accessibilityLabel={_(msg`Confirm`)} | ||
accessibilityHint=""> | ||
<Text style={[s.white, s.bold, s.f18]}> | ||
<Trans>Submit</Trans> | ||
</Text> | ||
</TouchableOpacity> | ||
</ScrollView> | ||
</View> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
detailsInputContainer: { | ||
borderRadius: 8, | ||
marginBottom: 8, | ||
}, | ||
detailsInput: { | ||
paddingHorizontal: 12, | ||
paddingTop: 12, | ||
paddingBottom: 12, | ||
borderRadius: 8, | ||
minHeight: 100, | ||
fontSize: 16, | ||
}, | ||
detailsInputBottomBar: { | ||
alignSelf: 'flex-end', | ||
}, | ||
charCounter: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
paddingRight: 10, | ||
paddingBottom: 8, | ||
}, | ||
btn: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
borderRadius: 32, | ||
padding: 14, | ||
backgroundColor: colors.blue3, | ||
}, | ||
}) |
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
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,60 @@ | ||
import React from 'react' | ||
import {Pressable, StyleProp, View, ViewStyle} from 'react-native' | ||
import {ComAtprotoLabelDefs} from '@atproto/api' | ||
import {Text} from '../text/Text' | ||
import {usePalette} from 'lib/hooks/usePalette' | ||
import {msg, Trans} from '@lingui/macro' | ||
import {useLingui} from '@lingui/react' | ||
import {useModalControls} from '#/state/modals' | ||
|
||
export function LabelInfo({ | ||
details, | ||
labels, | ||
style, | ||
}: { | ||
details: {did: string} | {uri: string; cid: string} | ||
labels: ComAtprotoLabelDefs.Label[] | undefined | ||
style?: StyleProp<ViewStyle> | ||
}) { | ||
const pal = usePalette('default') | ||
const {_} = useLingui() | ||
const {openModal} = useModalControls() | ||
|
||
if (!labels) { | ||
return null | ||
} | ||
labels = labels.filter(l => !l.val.startsWith('!')) | ||
if (!labels.length) { | ||
return null | ||
} | ||
|
||
return ( | ||
<View | ||
style={[ | ||
pal.viewLight, | ||
{ | ||
flexDirection: 'row', | ||
flexWrap: 'wrap', | ||
paddingHorizontal: 12, | ||
paddingVertical: 10, | ||
borderRadius: 8, | ||
}, | ||
style, | ||
]}> | ||
<Text type="sm" style={pal.text}> | ||
<Trans> | ||
This {'did' in details ? 'account' : 'post'} has been labeled. | ||
</Trans>{' '} | ||
</Text> | ||
<Pressable | ||
accessibilityRole="button" | ||
accessibilityLabel={_(msg`Appeal this decision`)} | ||
accessibilityHint="" | ||
onPress={() => openModal({name: 'appeal-label', ...details})}> | ||
<Text type="sm" style={pal.link}> | ||
<Trans>Appeal this decision.</Trans> | ||
</Text> | ||
</Pressable> | ||
</View> | ||
) | ||
} |