Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create FlagCommentPage #19412

Merged
merged 27 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b8d5da8
navigation and skeleton page
dangrous May 22, 2023
d770146
add menu items
dangrous May 22, 2023
b7b0c69
include reportID and skeleton onPress
dangrous May 22, 2023
d60f0d9
add flag icons
dangrous May 24, 2023
e21c085
add context menu action
dangrous May 26, 2023
37a2115
Merge branch 'main' into dangrous-flagcommentpane
dangrous May 26, 2023
7705873
Merge branch 'main' into dangrous-flagcommentpane
dangrous May 26, 2023
52b5306
add translations
dangrous May 26, 2023
15e4aef
call the flagComment method
dangrous May 26, 2023
48f1be5
style and prettier
dangrous May 26, 2023
6709e2a
update to work with new backend logic re: moderationDecisions object
dangrous May 26, 2023
cb2d45e
add constants for all severities
dangrous May 26, 2023
a020c49
prettier one more time
dangrous May 26, 2023
863422a
dont allow flagging of whispers from concierge
dangrous May 26, 2023
72b8f6f
merge conflicts
dangrous May 30, 2023
d6c1d84
handle threads
dangrous May 30, 2023
1b8ddfb
navigate back to chat not LHN
dangrous May 30, 2023
6ef721c
add back the further details
dangrous May 30, 2023
9adf5f3
prettier and one typo
dangrous May 30, 2023
11679f5
update copy
dangrous May 30, 2023
91411bc
copy update only
dangrous May 31, 2023
599d3c2
fix display bugs
dangrous May 31, 2023
7e9adc8
allow flagging of attachments
dangrous May 31, 2023
8789e03
prettier
dangrous May 31, 2023
fa0fd0b
look at latest moderationDecision
dangrous May 31, 2023
80b28d6
apply hover style to press as well
dangrous May 31, 2023
83929ca
use getReportID
dangrous May 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions assets/images/flag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions assets/images/flag_level_01.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions assets/images/flag_level_02.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions assets/images/flag_level_03.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export default {
NEW_TASK_DETAILS: `${NEW_TASK}/details`,
NEW_TASK_TITLE: `${NEW_TASK}/title`,
NEW_TASK_DESCRIPTION: `${NEW_TASK}/description`,
FLAG_COMMENT: `flag/:reportID/:reportActionID`,
getFlagCommentRoute: (reportID, reportActionID) => `flag/${reportID}/${reportActionID}`,
SEARCH: 'search',
SET_PASSWORD_WITH_VALIDATE_CODE: 'setpassword/:accountID/:validateCode',
DETAILS: 'details',
Expand Down
8 changes: 8 additions & 0 deletions src/components/Icon/Expensicons.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ import ExpensifyWordmark from '../../../assets/images/expensify-wordmark.svg';
import Expand from '../../../assets/images/expand.svg';
import Eye from '../../../assets/images/eye.svg';
import EyeDisabled from '../../../assets/images/eye-disabled.svg';
import Flag from '../../../assets/images/flag.svg';
import FlagLevelOne from '../../../assets/images/flag_level_01.svg';
import FlagLevelTwo from '../../../assets/images/flag_level_02.svg';
import FlagLevelThree from '../../../assets/images/flag_level_03.svg';
import Gallery from '../../../assets/images/gallery.svg';
import Gear from '../../../assets/images/gear.svg';
import Globe from '../../../assets/images/globe.svg';
Expand Down Expand Up @@ -162,6 +166,10 @@ export {
EyeDisabled,
FallbackAvatar,
FallbackWorkspaceAvatar,
Flag,
FlagLevelOne,
FlagLevelTwo,
FlagLevelThree,
Gallery,
Gear,
Globe,
Expand Down
18 changes: 18 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export default {
deleteConfirmation: ({action}) => `Are you sure you want to delete this ${ReportActionsUtils.isMoneyRequestAction(action) ? 'request' : 'comment'}?`,
onlyVisible: 'Only visible to',
replyInThread: 'Reply in thread',
flagAsOffensive: 'Flag as offensive',
},
emojiReactions: {
addReactionTooltip: 'Add reaction',
Expand Down Expand Up @@ -1400,4 +1401,21 @@ export default {
copyUrlToClipboard: 'Copy URL to clipboard',
copied: 'Copied!',
},
moderation: {
flagDescription:
'All flagged messages will be sent to a moderator for review. If a message is flagged at a level above Spam or Inconsiderate, it will immediately be hidden. Users may, however, choose to reveal the message while it is being reviewed if they choose. Dependent on the decision of the moderator, the message may or may not be permanently hidden or deleted, and the sender may be banned from posting temporarily or permanently.',
chooseAReason: 'Choose a reason below:',
spam: 'Spam',
spamDescription: 'Unsolicited off-topic promotion',
inconsiderate: 'Inconsiderate',
inconsiderateDescription: 'Insulting or disrespectful phrasing, with questionable intentions',
intimidation: 'Intimidation',
intimidationDescription: 'Aggressively pursuing an agenda over valid objections',
bullying: 'Bullying',
bullyingDescription: 'Targeting an individual to obtain obedience',
harassment: 'Harassment',
harassmentDescription: 'Racist, misogynistic, or other broadly discriminatory behavior',
assault: 'Assault',
assaultDescription: 'Specifically targeted emotional attack with the intention of harm',
},
};
18 changes: 18 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export default {
deleteConfirmation: ({action}) => `¿Estás seguro de que quieres eliminar este ${ReportActionsUtils.isMoneyRequestAction(action) ? 'pedido' : 'comentario'}`,
onlyVisible: 'Visible sólo para',
replyInThread: 'Responder en el hilo',
flagAsOffensive: 'Marcar como ofensivo',
},
emojiReactions: {
addReactionTooltip: 'Añadir una reacción',
Expand Down Expand Up @@ -1866,4 +1867,21 @@ export default {
copyUrlToClipboard: 'Copiar URL al portapapeles',
copied: '¡Copiado!',
},
moderation: {
flagDescription:
'Todos los mensajes marcados se enviarán a un moderador para su revisión. Si un mensaje se marca en un nivel superior a Spam o Desconsiderado, se ocultará de inmediato. Sin embargo, los usuarios pueden optar por revelar el mensaje mientras se revisa si así lo desean. Dependiendo de la decisión del moderador, el mensaje puede ocultarse o eliminarse permanentemente o no, y el remitente puede tener prohibido enviar mensajes de forma temporal o permanente.',
chooseAReason: 'Elige un motivo de abajo:',
spam: 'Spam',
spamDescription: 'Promoción fuera de tema no solicitada',
inconsiderate: 'Desconsiderado',
inconsiderateDescription: 'Frase insultante o irrespetuosa, con intenciones cuestionables',
intimidation: 'Intimidación',
intimidationDescription: 'Persigue agresivamente una agenda sobre objeciones válidas',
bullying: 'Bullying',
bullyingDescription: 'Apunta a un individuo para obtener obediencia',
harassment: 'Acoso',
harassmentDescription: 'Comportamiento racista, misógino u otro comportamiento discriminatorio',
assault: 'Agresion',
assaultDescription: 'Ataque emocional específicamente dirigido con la intención de hacer daño',
},
};
6 changes: 6 additions & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ class AuthScreens extends React.Component {
component={ModalStackNavigators.YearPickerStackNavigator}
listeners={modalScreenListeners}
/>
<RootStack.Screen
name="Flag_Comment"
options={modalScreenOptions}
component={ModalStackNavigators.FlagCommentStackNavigator}
listeners={modalScreenListeners}
/>
<RootStack.Screen
name={SCREENS.NOT_FOUND}
options={{headerShown: false}}
Expand Down
11 changes: 11 additions & 0 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,16 @@ const YearPickerStackNavigator = createModalStackNavigator([
},
]);

const FlagCommentStackNavigator = createModalStackNavigator([
{
getComponent: () => {
const FlagCommentPage = require('../../../pages/FlagCommentPage').default;
return FlagCommentPage;
},
name: 'FlagComment_Root',
},
]);

export {
IOUBillStackNavigator,
IOURequestModalStackNavigator,
Expand All @@ -723,4 +733,5 @@ export {
ReimbursementAccountModalStackNavigator,
WalletStatementStackNavigator,
YearPickerStackNavigator,
FlagCommentStackNavigator,
};
5 changes: 5 additions & 0 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ export default {
YearPicker_Root: ROUTES.SELECT_YEAR,
},
},
Flag_Comment: {
screens: {
FlagComment_Root: ROUTES.FLAG_COMMENT,
},
},
[SCREENS.NOT_FOUND]: '*',
},
},
Expand Down
20 changes: 20 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,25 @@ function canEditReportAction(reportAction) {
);
}

/**
* Can only flag if:
*
* - It was written by someone else
* - It's an ADDCOMMENT that is not an attachment
*
* @param {Object} reportAction
* @returns {Boolean}
*/
function canFlagReportAction(reportAction) {
return (
reportAction.actorEmail !== sessionEmail &&
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT &&
!isReportMessageAttachment(lodashGet(reportAction, ['message', 0], {})) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, why are we excluding attachments?

!ReportActionsUtils.isDeletedAction(reportAction) &&
!ReportActionsUtils.isCreatedTaskReportAction(reportAction)
);
}

/**
* Whether the Money Request report is settled
*
Expand Down Expand Up @@ -2255,6 +2274,7 @@ export {
isReportMessageAttachment,
findLastAccessedReport,
canEditReportAction,
canFlagReportAction,
canDeleteReportAction,
canLeaveRoom,
sortReportsByLastRead,
Expand Down
26 changes: 13 additions & 13 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1685,30 +1685,30 @@ function leaveRoom(reportID) {
* @param {String} severity
*/
function flagComment(reportID, reportAction, severity) {
let newDecision;
const message = reportAction.message[0];
let updatedDecision;
if (severity === CONST.MODERATION.FLAG_SEVERITY_SPAM || severity === CONST.MODERATION.FLAG_SEVERITY_INCONSIDERATE) {
newDecision = {
decision: CONST.MODERATION.MODERATOR_DECISION_PENDING,
};
if (_.isEmpty(message.moderationDecisions) || message.moderationDecisions[0].decision !== CONST.MODERATOR_DECISION_PENDING_HIDE) {
updatedDecision = [{
decision: CONST.MODERATION.MODERATOR_DECISION_PENDING,
}];
}
} else {
newDecision = {
updatedDecision = [{
decision: CONST.MODERATION.MODERATOR_DECISION_PENDING_HIDE,
};
}];
}

const message = reportAction.message[0];
const reportActionID = reportAction.reportActionID;

const updatedDecisions = [...(message.moderationDecisions || []), newDecision];

const updatedMessage = {
...message,
moderationDecisions: updatedDecisions,
moderationDecisions: updatedDecision,
};

const optimisticData = [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
value: {
[reportActionID]: {
Expand All @@ -1721,7 +1721,7 @@ function flagComment(reportID, reportAction, severity) {

const failureData = [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
value: {
[reportActionID]: {
Expand All @@ -1734,7 +1734,7 @@ function flagComment(reportID, reportAction, severity) {

const successData = [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
value: {
[reportActionID]: {
Expand Down
Loading