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:
parent
bbdc5c55bb
commit
fd1827f618
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue