fix: hide the edit/delete action based on permission (#5393)

* fix: hide the edit/delete item for not allowed or not own the message

* fix e2e test
This commit is contained in:
Reinaldo Neto 2023-12-12 14:58:40 -03:00 committed by GitHub
parent bbdc5c55bb
commit fd1827f618
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View File

@ -454,12 +454,13 @@ const MessageActions = React.memo(
});
// Edit
if (!videoConfBlock) {
const isEditAllowed = allowEdit(message);
if (!videoConfBlock && (isOwn(message) || isEditAllowed)) {
options.push({
title: I18n.t('Edit'),
icon: 'edit',
onPress: () => handleEdit(message),
enabled: allowEdit(message)
enabled: isEditAllowed
});
}
@ -518,13 +519,16 @@ const MessageActions = React.memo(
});
// Delete
options.push({
title: I18n.t('Delete'),
icon: 'delete',
danger: true,
onPress: () => handleDelete(message),
enabled: allowDelete(message)
});
const isDeleteAllowed = allowDelete(message);
if (isOwn(message) || isDeleteAllowed) {
options.push({
title: I18n.t('Delete'),
icon: 'delete',
danger: true,
onPress: () => handleDelete(message),
enabled: isDeleteAllowed
});
}
return options;
};

View File

@ -186,7 +186,7 @@ describe('Auto Translate', () => {
await waitForVisible('action-sheet-handle');
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by[textMatcher]('Edit')).atIndex(0).swipe('up', 'fast', 0.5);
await element(by[textMatcher]('Get link')).atIndex(0).swipe('up', 'fast', 0.5);
await waitForVisibleTextMatcher('View original', textMatcher);
await element(by[textMatcher]('View original')).atIndex(0).tap();