From eff7bac9d882d2aa5a2d0890f956132a67d2144f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Chaves=20Neto?= Date: Thu, 16 Jan 2020 16:02:49 -0300 Subject: [PATCH] refact: refactor userDetails (#5467) --- app/javascript/.eslintrc.js | 2 + .../__snapshots__/userDetails.test.jsx.snap | 14 +- app/javascript/chat/userDetails.jsx | 383 +++++++++--------- 3 files changed, 215 insertions(+), 184 deletions(-) diff --git a/app/javascript/.eslintrc.js b/app/javascript/.eslintrc.js index f9ff4f0ab..b7773cfd5 100644 --- a/app/javascript/.eslintrc.js +++ b/app/javascript/.eslintrc.js @@ -34,6 +34,8 @@ module.exports = { 'react/jsx-no-target-blank': [2, { enforceDynamicLinks: 'always' }], }, globals: { + getCsrfToken: false, + sendFetch: false, InstantClick: false, filterXSS: false, Pusher: false, diff --git a/app/javascript/chat/__tests__/__snapshots__/userDetails.test.jsx.snap b/app/javascript/chat/__tests__/__snapshots__/userDetails.test.jsx.snap index e1166c1c0..b04faa386 100644 --- a/app/javascript/chat/__tests__/__snapshots__/userDetails.test.jsx.snap +++ b/app/javascript/chat/__tests__/__snapshots__/userDetails.test.jsx.snap @@ -3,7 +3,7 @@ exports[` for user1 should render and test snapshot 1`] = `
bojackhorseman profile image for user1 should render and test snapshot 1`] = ` > Bojack Horseman @@ -165,6 +166,7 @@ exports[` for user1 should render and test snapshot 1`] = ` class="no" onClick={[Function]} onKeyUp={[Function]} + role="button" tabIndex="0" > No @@ -202,6 +204,7 @@ exports[` for user1 should render and test snapshot 1`] = ` Yes, Block @@ -210,6 +213,7 @@ exports[` for user1 should render and test snapshot 1`] = ` class="no" onClick={[Function]} onKeyUp={[Function]} + role="button" tabIndex="0" > No @@ -222,7 +226,7 @@ exports[` for user1 should render and test snapshot 1`] = ` exports[` for user2 should render and test snapshot 1`] = `
mrpeanutbutter profile image for user2 should render and test snapshot 1`] = ` > Mr. Peanutbutter @@ -347,11 +352,13 @@ exports[` for user2 should render and test snapshot 1`] = ` > @@ -395,6 +402,7 @@ exports[` for user2 should render and test snapshot 1`] = ` class="no" onClick={[Function]} onKeyUp={[Function]} + role="button" tabIndex="0" > No @@ -432,6 +440,7 @@ exports[` for user2 should render and test snapshot 1`] = ` Yes, Block @@ -440,6 +449,7 @@ exports[` for user2 should render and test snapshot 1`] = ` class="no" onClick={[Function]} onKeyUp={[Function]} + role="button" tabIndex="0" > No diff --git a/app/javascript/chat/userDetails.jsx b/app/javascript/chat/userDetails.jsx index 465aaf5e6..d34b85045 100644 --- a/app/javascript/chat/userDetails.jsx +++ b/app/javascript/chat/userDetails.jsx @@ -1,6 +1,10 @@ -import { h, Component } from 'preact'; +import { h } from 'preact'; +import { PropTypes } from 'prop-types'; +// eslint-disable-next-line import/no-unresolved import twitterImage from 'images/twitter-logo.svg'; +// eslint-disable-next-line import/no-unresolved import githubImage from 'images/github-logo.svg'; +// eslint-disable-next-line import/no-unresolved import websiteImage from 'images/external-link-logo.svg'; function blockUser(blockedUserId) { @@ -16,6 +20,7 @@ function blockUser(blockedUserId) { const setUpButton = ({ modalId = '', otherModalId = '', btnName = '' }) => { return (