Skip to content

Commit

Permalink
Merge pull request #126 from supertokens/fix/handle-row-click
Browse files Browse the repository at this point in the history
fix: Add click to entire user row.
  • Loading branch information
rishabhpoddar authored Nov 15, 2023
2 parents 0d6cd9b + 4aea5e2 commit bd916ae
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 40 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [0.8.6] - 2023-11-15

- Adds click action to the entire user row.

## [0.8.5] - 2023-10-5

- Fixes showing email verification UI even though it's not initialised.
Expand Down
2 changes: 1 addition & 1 deletion build/static/css/main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/static/css/main.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/static/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/static/js/bundle.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dashboard",
"version": "0.8.5",
"version": "0.8.6",
"private": true,
"dependencies": {
"@babel/core": "^7.16.0",
Expand Down
14 changes: 8 additions & 6 deletions src/ui/components/usersListTable/UsersListTable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
$container-padding-v: 24px;

.users-list-table-container {
padding: $container-padding-v 34px;
padding: $container-padding-v 0px;
display: block;
width: 100%;
max-width: 100%;
Expand All @@ -42,7 +42,7 @@ $container-padding-v: 24px;
.users-list-table thead tr {
border-bottom: 1px solid var(--color-border);
th {
padding: 0 1em 24px 0;
padding: 0 1em 24px 34px;
font-weight: 500;
text-align: left;
width: 33%;
Expand All @@ -54,7 +54,7 @@ $container-padding-v: 24px;
td {
width: 33%;
max-width: 50%;
padding: 24px 1em 24px 0;
padding: 24px 1em 24px 34px;
}
&.empty-row {
td {
Expand All @@ -64,6 +64,10 @@ $container-padding-v: 24px;
}

.user-row {
&:hover {
cursor: pointer;
background: rgb(242, 247, 253);
}
.user-info {
display: flex;
flex-direction: column;
Expand All @@ -83,9 +87,6 @@ $container-padding-v: 24px;
color: var(--color-black);
font-weight: 500;
cursor: pointer;
&:hover {
color: var(--color-link);
}
}
}

Expand Down Expand Up @@ -218,6 +219,7 @@ $container-padding-v: 24px;
display: flex;
justify-content: flex-end;
padding-top: $container-padding-v;
padding-right: 34px;
position: sticky;
left: 0px;
}
Expand Down
52 changes: 26 additions & 26 deletions src/ui/components/usersListTable/UsersListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,36 @@ const UserTableRow: React.FC<
} & UserRowActionProps
> = (props) => {
const { user, index, onSelect } = props;

let isClicked = false;
let didDrag = false;

return (
<tr
// this code helps users to copy the text available on the row if they want
// and will not accidentally open the user specific page.
onMouseDown={() => {
isClicked = true;
}}
onClick={() => {
if (!didDrag) {
onSelect(user);
} else {
didDrag = false;
}
}}
onMouseMove={() => {
if (isClicked) {
didDrag = true;
}
}}
onMouseUp={() => {
isClicked = false;
}}
key={index}
className="user-row">
<td>
<UserInfo
user={user}
onSelect={onSelect}
/>
<UserInfo user={user} />
</td>
<td>
<UserRecipePill user={user} />
Expand All @@ -171,36 +192,15 @@ const UserTableRow: React.FC<
);
};

const UserInfo = ({ user, onSelect }: { user: User; onSelect: OnSelectUserFunction }) => {
const UserInfo = ({ user }: { user: User }) => {
const { firstName, lastName, emails } = user;
const methodFilter = user.loginMethods.filter((el) => el.recipeUserId === user.id);
const email = methodFilter.length > 0 ? methodFilter[0].email : user.emails[0];
const phone = methodFilter.length > 0 ? methodFilter[0].phoneNumber : user.phoneNumbers[0];
const name = `${firstName ?? ""} ${lastName ?? ""}`.trim();
let isClicked = false;
let didDrag = false;

return (
<div className="user-info">
<div
onMouseDown={() => {
isClicked = true;
}}
onClick={() => {
if (!didDrag) {
onSelect(user);
} else {
didDrag = false;
}
}}
onMouseMove={() => {
if (isClicked) {
didDrag = true;
}
}}
onMouseUp={() => {
isClicked = false;
}}
className="main"
title={name || email}>
{name || email || (phone && <PhoneDisplay phone={phone} />)}
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
* under the License.
*/

export const package_version = "0.8.5";
export const package_version = "0.8.6";

0 comments on commit bd916ae

Please sign in to comment.