Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Remove obsolete style rules - mx_SpaceRoomView_inviteTeammates_betaDisclaimer #11004

Merged
merged 5 commits into from
May 29, 2023
Merged

Conversation

luixxiul
Copy link
Contributor

@luixxiul luixxiul commented May 27, 2023

This PR intends to remove mx_SpaceRoomView_inviteTeammates_betaDisclaimer style rules as the Space has left beta. This also suggests to add a Percy snapshot test as there has not been one for dialogs related to Space. The snapshot should also help us to detect a regression if any, when we replace the invite mask-image with a SVG icon next to Invite by username.

Before After
before after

type: task

Signed-off-by: Suguru Hirahara [email protected]

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

This change is marked as an internal change (Task), so will not be included in the changelog.

@github-actions github-actions bot added Z-Community-PR Issue is solved by a community member's PR T-Task Refactoring, enabling or disabling functionality, other engineering tasks labels May 27, 2023
@luixxiul luixxiul marked this pull request as ready for review May 27, 2023 17:47
@luixxiul luixxiul requested a review from a team as a code owner May 27, 2023 17:47
@luixxiul luixxiul requested review from dbkr and kerryarchibald May 27, 2023 17:47
@luixxiul
Copy link
Contributor Author

…But is this still used?

const SpaceSetupPrivateInvite: React.FC<{
space: Room;
onFinished(): void;
}> = ({ space, onFinished }) => {
const [busy, setBusy] = useState(false);
const [error, setError] = useState("");
const numFields = 3;
const fieldRefs = [useRef(), useRef(), useRef()] as RefObject<Field>[];
const [emailAddresses, setEmailAddress] = useStateArray(numFields, "");
const fields = new Array(numFields).fill(0).map((x, i) => {
const name = "emailAddress" + i;
return (
<Field
key={name}
name={name}
type="text"
label={_t("Email address")}
placeholder={_t("Email")}
value={emailAddresses[i]}
onChange={(ev: React.ChangeEvent<HTMLInputElement>) => setEmailAddress(i, ev.target.value)}
ref={fieldRefs[i]}
onValidate={validateEmailRules}
autoFocus={i === 0}
disabled={busy}
/>
);
});
const onNextClick = async (ev: ButtonEvent): Promise<void> => {
ev.preventDefault();
if (busy) return;
setError("");
for (const fieldRef of fieldRefs) {
const valid = await fieldRef.current?.validate({ allowEmpty: true });
if (valid === false) {
// true/null are allowed
fieldRef.current!.focus();
fieldRef.current!.validate({ allowEmpty: true, focused: true });
return;
}
}
setBusy(true);
const targetIds = emailAddresses.map((name) => name.trim()).filter(Boolean);
try {
const result = await inviteMultipleToRoom(space.client, space.roomId, targetIds);
const failedUsers = Object.keys(result.states).filter((a) => result.states[a] === "error");
if (failedUsers.length > 0) {
logger.log("Failed to invite users to space: ", result);
setError(
_t("Failed to invite the following users to your space: %(csvUsers)s", {
csvUsers: failedUsers.join(", "),
}),
);
} else {
onFinished();
}
} catch (err) {
logger.error("Failed to invite users to space: ", err);
setError(_t("We couldn't invite those users. Please check the users you want to invite and try again."));
}
setBusy(false);
};
let onClick = (ev: ButtonEvent): void => {
ev.preventDefault();
onFinished();
};
let buttonLabel = _t("Skip for now");
if (emailAddresses.some((name) => name.trim())) {
onClick = onNextClick;
buttonLabel = busy ? _t("Inviting…") : _t("Continue");
}
return (
<div className="mx_SpaceRoomView_inviteTeammates">
<h1>{_t("Invite your teammates")}</h1>
<div className="mx_SpaceRoomView_description">
{_t("Make sure the right people have access. You can invite more later.")}
</div>
<div className="mx_SpaceRoomView_inviteTeammates_betaDisclaimer">
{_t(
"<b>This is an experimental feature.</b> For now, " +
"new users receiving an invite will have to open the invite on <link/> to actually join.",
{},
{
b: (sub) => <b>{sub}</b>,
link: () => (
<ExternalLink href="https://app.element.io/" rel="noreferrer noopener" target="_blank">
app.element.io
</ExternalLink>
),
},
)}
</div>
{error && <div className="mx_SpaceRoomView_errorText">{error}</div>}
<form onSubmit={onClick} id="mx_SpaceSetupPrivateInvite">
{fields}
</form>
<div className="mx_SpaceRoomView_inviteTeammates_buttons">
<AccessibleButton
className="mx_SpaceRoomView_inviteTeammates_inviteDialogButton"
onClick={() => showRoomInviteDialog(space.roomId)}
>
{_t("Invite by username")}
</AccessibleButton>
</div>
<div className="mx_SpaceRoomView_buttons">
<AccessibleButton
kind="primary"
disabled={busy}
onClick={onClick}
element="input"
type="submit"
form="mx_SpaceSetupPrivateInvite"
value={buttonLabel}
/>
</div>
</div>
);
};

This seems to have been used to render Invite your teammates dialog which was initially implemented by #5933.

Copy link
Contributor

@kerryarchibald kerryarchibald left a comment

Choose a reason for hiding this comment

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

This style is still in use.
It's safe to remove the beta disclaimer along with the styles as spaces is out of beta, and the warning about the link is no longer relevant.

@luixxiul
Copy link
Contributor Author

yeah right, thanks for confirmation.

@kerryarchibald
Copy link
Contributor

@luixxiul Can you please add a screenshot of the invite dialog with the beta card removed?

@kerryarchibald
Copy link
Contributor

And update the PR title to better describe the change please!

Copy link
Contributor

@kerryarchibald kerryarchibald left a comment

Choose a reason for hiding this comment

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

Looks good, thank you. Just a couple of small requests about the PR title and screenshot, then should be good to go 🚀

@kerryarchibald kerryarchibald added this pull request to the merge queue May 29, 2023
Merged via the queue into matrix-org:develop with commit e6cddcb May 29, 2023
@luixxiul luixxiul deleted the SpaceRoomView branch May 30, 2023 09:12
@luixxiul luixxiul restored the SpaceRoomView branch May 30, 2023 09:15
@luixxiul
Copy link
Contributor Author

The percy snapshot was not correctly specified to take "invite your teammates" dialog. I am going to submit a fix.

Currently it takes a dialog after clicking the primary button just before the invitation dialog: https://percy.io/dfde73bd/matrix-react-sdk/builds/27785922/changed/1545562064

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Task Refactoring, enabling or disabling functionality, other engineering tasks Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants