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
|
// Edit
|
||||||
if (!videoConfBlock) {
|
const isEditAllowed = allowEdit(message);
|
||||||
|
if (!videoConfBlock && (isOwn(message) || isEditAllowed)) {
|
||||||
options.push({
|
options.push({
|
||||||
title: I18n.t('Edit'),
|
title: I18n.t('Edit'),
|
||||||
icon: 'edit',
|
icon: 'edit',
|
||||||
onPress: () => handleEdit(message),
|
onPress: () => handleEdit(message),
|
||||||
enabled: allowEdit(message)
|
enabled: isEditAllowed
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,13 +519,16 @@ const MessageActions = React.memo(
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
options.push({
|
const isDeleteAllowed = allowDelete(message);
|
||||||
title: I18n.t('Delete'),
|
if (isOwn(message) || isDeleteAllowed) {
|
||||||
icon: 'delete',
|
options.push({
|
||||||
danger: true,
|
title: I18n.t('Delete'),
|
||||||
onPress: () => handleDelete(message),
|
icon: 'delete',
|
||||||
enabled: allowDelete(message)
|
danger: true,
|
||||||
});
|
onPress: () => handleDelete(message),
|
||||||
|
enabled: isDeleteAllowed
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
};
|
};
|
||||||
|
|
|
@ -186,7 +186,7 @@ describe('Auto Translate', () => {
|
||||||
|
|
||||||
await waitForVisible('action-sheet-handle');
|
await waitForVisible('action-sheet-handle');
|
||||||
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
|
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 waitForVisibleTextMatcher('View original', textMatcher);
|
||||||
await element(by[textMatcher]('View original')).atIndex(0).tap();
|
await element(by[textMatcher]('View original')).atIndex(0).tap();
|
||||||
|
|
Loading…
Reference in New Issue