fix: Show invite option for substring user emails of other shared users (#8962)
* show invitation option for overlapping email addr string if no exact match is found. * added test case Co-authored-by: Arpit Mohan <arpit@appsmith.com>
This commit is contained in:
parent
ff0222e270
commit
bffe28361a
|
|
@ -121,6 +121,19 @@ describe("Comments", function() {
|
|||
});
|
||||
});
|
||||
|
||||
it("Can invite new collaborators, with substring emails", () => {
|
||||
cy.get(commentsLocators.cancelCommentButton).click({ force: true });
|
||||
cy.get(homePage.shareApp).click({ force: true });
|
||||
cy.shareApp("cypresstest@appsmith.com", homePage.viewerRole);
|
||||
cy.get(commonLocators.canvas).click(30, 30);
|
||||
cy.wait(300);
|
||||
cy.get(commentsLocators.mentionsInput).type("@test@appsmith.com", {
|
||||
delay: 100,
|
||||
});
|
||||
cy.wait(1000);
|
||||
cy.contains("Invite a new user").should("exist");
|
||||
});
|
||||
|
||||
it("unread indicator is visible for another app user when a new comment is added", () => {
|
||||
// share app with TESTUSERNAME2
|
||||
cy.get(homePage.shareApp).click({ force: true });
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
"switchToCommentModeBtn": ".t--switch-comment-mode-on",
|
||||
"mentionsInput": "[data-testid='mentions-input']",
|
||||
"postButtonAddComment": "[data-cy='add-comment-submit']",
|
||||
"cancelCommentButton": "[data-cy='add-comment-cancel']",
|
||||
"inlineCommentThreadPin": ".t--inline-comment-pin-trigger-",
|
||||
"toggleCommentModeOnUnread": ".t--toggle-comment-mode-on--unread",
|
||||
"toggleCommentModeOn": ".t--toggle-comment-mode-on"
|
||||
|
|
|
|||
|
|
@ -267,6 +267,7 @@ function AddCommentInput({
|
|||
|
||||
const filteredSuggestions = useMemo(() => {
|
||||
let suggestionResults = suggestions;
|
||||
let hasExactMatch = false;
|
||||
if (!suggestionsQuery) return suggestionResults;
|
||||
else {
|
||||
const filter = suggestionsQuery.toLowerCase();
|
||||
|
|
@ -274,14 +275,18 @@ function AddCommentInput({
|
|||
.filter((suggestion) => {
|
||||
const name = suggestion.name.toLowerCase();
|
||||
const username = suggestion.user?.username.toLowerCase() || "";
|
||||
hasExactMatch = name === filter || username === filter;
|
||||
return name.indexOf(filter) !== -1 || username.indexOf(filter) !== -1;
|
||||
})
|
||||
.sort(sortMentionData(filter));
|
||||
}
|
||||
|
||||
if (suggestionResults.length !== 0) return suggestionResults;
|
||||
|
||||
return [{ name: suggestionsQuery, isInviteTrigger: true }];
|
||||
const couldBeNewEmail = isEmail(suggestionsQuery);
|
||||
const inviteNew = [{ name: suggestionsQuery, isInviteTrigger: true }];
|
||||
// Show invite prompt only if there is no exact match and user has typed email.
|
||||
return [
|
||||
...suggestionResults,
|
||||
...(couldBeNewEmail && !hasExactMatch ? inviteNew : []),
|
||||
];
|
||||
}, [suggestionsQuery, suggestions, trigger]);
|
||||
|
||||
const onAddMention = (mention: MentionData) => {
|
||||
|
|
@ -332,6 +337,7 @@ function AddCommentInput({
|
|||
<Button
|
||||
category={Category.tertiary}
|
||||
className={"cancel-button"}
|
||||
data-cy="add-comment-cancel"
|
||||
onClick={_onCancel}
|
||||
text={createMessage(CANCEL)}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user