From 73de95efc70f6f62548c21651bd0c10c09e2c204 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Tue, 11 Feb 2020 08:35:55 +0100 Subject: [PATCH] Use tooltip instead of title and added aria label to DiffButton --- .../src/__snapshots__/storyshots.test.ts.snap | 3006 +++++++++-------- .../ui-components/src/repos/Diff.stories.tsx | 12 +- scm-ui/ui-components/src/repos/DiffButton.tsx | 13 +- scm-ui/ui-components/src/repos/DiffFile.tsx | 2 +- 4 files changed, 1690 insertions(+), 1343 deletions(-) diff --git a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap index 27ba6d833c..730e93136d 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -483,7 +483,9 @@ exports[`Storyshots DateFromNow Default 1`] = ` `; exports[`Storyshots Diff Binaries 1`] = ` -Array [ +
@@ -521,15 +523,20 @@ Array [
- - - + + + +
@@ -694,7 +701,7 @@ Array [ - , +
@@ -740,12 +747,14 @@ Array [
- , -] + + `; exports[`Storyshots Diff Collapsed 1`] = ` -Array [ +
@@ -783,21 +792,26 @@ Array [
- , +
@@ -835,21 +849,26 @@ Array [
- , +
@@ -887,21 +906,26 @@ Array [
- , +
@@ -939,21 +963,26 @@ Array [
- , +
@@ -991,21 +1020,26 @@ Array [
- , +
@@ -1043,26 +1077,33 @@ Array [
- , -] + + `; exports[`Storyshots Diff CollapsingWithFunction 1`] = ` -Array [ +
@@ -1100,21 +1141,26 @@ Array [
- , +
@@ -1152,15 +1198,20 @@ Array [
@@ -1961,7 +2012,7 @@ Array [ - , +
@@ -1999,15 +2050,20 @@ Array [
@@ -2404,7 +2460,7 @@ Array [ - , +
@@ -2442,15 +2498,20 @@ Array [
@@ -2847,7 +2908,7 @@ Array [ - , +
@@ -2885,21 +2946,26 @@ Array [
- , +
@@ -2937,26 +3003,33 @@ Array [
- , -] + + `; exports[`Storyshots Diff Default 1`] = ` -Array [ +
@@ -2994,15 +3067,20 @@ Array [
@@ -3526,7 +3604,7 @@ Array [ - , +
@@ -3564,15 +3642,20 @@ Array [
@@ -4373,7 +4456,7 @@ Array [ - , +
@@ -4411,15 +4494,20 @@ Array [
@@ -4816,7 +4904,7 @@ Array [ - , +
@@ -4854,15 +4942,20 @@ Array [
@@ -5259,7 +5352,7 @@ Array [ - , +
@@ -5297,15 +5390,20 @@ Array [
@@ -6309,7 +6407,7 @@ Array [ - , +
@@ -6347,15 +6445,20 @@ Array [
@@ -6827,12 +6930,14 @@ Array [ - , -] + + `; exports[`Storyshots Diff File Annotation 1`] = ` -Array [ +
@@ -6870,15 +6975,20 @@ Array [
@@ -7406,7 +7516,7 @@ Array [ - , +
@@ -7444,15 +7554,20 @@ Array [
@@ -8257,7 +8372,7 @@ Array [ - , +
@@ -8295,15 +8410,20 @@ Array [
@@ -8704,7 +8824,7 @@ Array [ - , +
@@ -8742,15 +8862,20 @@ Array [
@@ -9151,7 +9276,7 @@ Array [ - , +
@@ -9189,15 +9314,20 @@ Array [
@@ -10205,7 +10335,7 @@ Array [ - , +
@@ -10243,15 +10373,20 @@ Array [
@@ -10727,12 +10862,14 @@ Array [ - , -] + + `; exports[`Storyshots Diff File Controls 1`] = ` -Array [ +
@@ -10770,28 +10907,38 @@ Array [
@@ -11315,7 +11462,7 @@ Array [ - , +
@@ -11353,28 +11500,38 @@ Array [
@@ -12175,7 +12332,7 @@ Array [ - , +
@@ -12213,28 +12370,38 @@ Array [
@@ -12631,7 +12798,7 @@ Array [ - , +
@@ -12669,28 +12836,38 @@ Array [
@@ -13087,7 +13264,7 @@ Array [ - , +
@@ -13125,28 +13302,38 @@ Array [
@@ -14150,7 +14337,7 @@ Array [ - , +
@@ -14188,28 +14375,38 @@ Array [
@@ -14681,840 +14878,851 @@ Array [ - , -] + + `; exports[`Storyshots Diff Hunks 1`] = `
- - - src/main/java/com/cloudogu/scm/review/pullrequest/service/DefaultPullRequestService.java - - - modify - -
-
+ + + src/main/java/com/cloudogu/scm/review/pullrequest/service/DefaultPullRequestService.java + + + modify + +
+
- - - + + + + + +
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - + + + + - - + + + + - 31 - - + + + + - import static com.cloudogu.scm.review.pullrequest.service.PullRequestStatus.OPEN; - - - - + + + + - 30 - - - - - - - - - - - - - + + + - 200 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 29 + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - - + + + + - 215 - - + + + + - .filter(recipient -> user.getId().equals(recipient)) - - - + 202 + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - - + + + + - .ifPresent(pullRequest::removeApprover); - - - - + + + + - 215 - - + + + + - getStore(repository).update(pullRequest); - - - - + + + - 217 - - + + + - .ifPresent( - - - - + + + - 218 - - + + + - approval -> { - - - - + + + - 219 - - + + + - pullRequest.removeApprover(approval); - - - - + + + - 220 - - + + + - getStore(repository).update(pullRequest); - - - - + + + + - 221 - - + + + + - eventBus.post(new PullRequestApprovalEvent(repository, pullRequest, APPROVAL_REMOVED)); - - - - - - - - - - - - - - - - - - - - - - -
- -
- 25 - - 25 - - import java.util.Set; -
- 26 - - 26 - - import java.util.stream.Collectors; -
- 27 - - 27 - - -
+
- 28 - - import static com.cloudogu.scm.review.pullrequest.service.PullRequestApprovalEvent.ApprovalCause.APPROVAL_REMOVED; -
- - 29 - - import static com.cloudogu.scm.review.pullrequest.service.PullRequestApprovalEvent.ApprovalCause.APPROVED; -
- 28 - - 30 - - import static com.cloudogu.scm.review.pullrequest.service.PullRequestStatus.MERGED; -
+ +
- 29 - + 25 + + 25 + + import java.util.Set; +
+ 26 + + 26 + + import java.util.stream.Collectors; +
+ 27 + + 27 + + +
- 32 - - import static com.cloudogu.scm.review.pullrequest.service.PullRequestStatus.REJECTED; -
-
-
+ 28 + + import static com.cloudogu.scm.review.pullrequest.service.PullRequestApprovalEvent.ApprovalCause.APPROVAL_REMOVED; +
- 202 - - PullRequest pullRequest = getPullRequestFromStore(repository, pullRequestId); -
- 201 - - 203 - - pullRequest.addApprover(user.getId()); -
- 202 - - 204 - - getStore(repository).update(pullRequest); -
- - 205 - - eventBus.post(new PullRequestApprovalEvent(repository, pullRequest, APPROVED)); -
- 203 - - 206 - - } -
- 204 - - 207 - - -
- 205 - - 208 - - @Override -
-
-
+ import static com.cloudogu.scm.review.pullrequest.service.PullRequestApprovalEvent.ApprovalCause.APPROVED; +
+ 28 + + 30 + + import static com.cloudogu.scm.review.pullrequest.service.PullRequestStatus.MERGED; +
+ 29 + + 31 + + import static com.cloudogu.scm.review.pullrequest.service.PullRequestStatus.OPEN; +
+ 30 + + 32 + + import static com.cloudogu.scm.review.pullrequest.service.PullRequestStatus.REJECTED; +
- 211 - - 214 - - approver.stream() -
+
+
- 212 - + 200 + + 202 + + PullRequest pullRequest = getPullRequestFromStore(repository, pullRequestId); +
+ 201 + + 203 + + pullRequest.addApprover(user.getId()); +
+ 204 + + getStore(repository).update(pullRequest); +
+ + 205 + + eventBus.post(new PullRequestApprovalEvent(repository, pullRequest, APPROVED)); +
+ 203 + + 206 + + } +
+ 204 + + 207 + + +
+ 205 + + 208 + + @Override +
- 213 - - 216 - - .findFirst() -
+
+
- 214 - - + 211 + + 214 + + approver.stream() +
+ 212 + + 215 + + .filter(recipient -> user.getId().equals(recipient)) +
- + 213 + + 216 + + .findFirst() +
- + 214 + + + .ifPresent(pullRequest::removeApprover); +
+ 215 + + + getStore(repository).update(pullRequest); +
- + + 217 + + .ifPresent( +
+ + 218 + + approval -> { +
- + + 219 + + pullRequest.removeApprover(approval); +
+ + 220 + + getStore(repository).update(pullRequest); +
- + + 221 + + eventBus.post(new PullRequestApprovalEvent(repository, pullRequest, APPROVAL_REMOVED)); +
+ + 222 + + }); +
- + 216 + + 223 + + } +
+ 217 + + 224 + + +
- - 222 - - }); -
- 216 - - 223 - - } -
- 217 - - 224 - - -
- 218 - - 225 - - @Override -
+ + 218 + + + 225 + + + @Override + + + + +
`; exports[`Storyshots Diff Line Annotation 1`] = ` -Array [ +
@@ -15552,15 +15760,20 @@ Array [
@@ -16096,7 +16309,7 @@ Array [ - , +
@@ -16134,15 +16347,20 @@ Array [
@@ -16955,7 +17173,7 @@ Array [ - , +
@@ -16993,15 +17211,20 @@ Array [
@@ -17398,7 +17621,7 @@ Array [ - , +
@@ -17436,15 +17659,20 @@ Array [
@@ -17841,7 +18069,7 @@ Array [ - , +
@@ -17879,15 +18107,20 @@ Array [
@@ -18891,7 +19124,7 @@ Array [ - , +
@@ -18929,15 +19162,20 @@ Array [
@@ -19421,12 +19659,14 @@ Array [ - , -] + + `; exports[`Storyshots Diff OnClick 1`] = ` -Array [ +
@@ -19464,15 +19704,20 @@ Array [
@@ -20036,7 +20281,7 @@ Array [ - , +
@@ -20074,15 +20319,20 @@ Array [
@@ -20945,7 +21195,7 @@ Array [ - , +
@@ -20983,15 +21233,20 @@ Array [
@@ -21418,7 +21673,7 @@ Array [ - , +
@@ -21456,15 +21711,20 @@ Array [
@@ -21891,7 +22151,7 @@ Array [ - , +
@@ -21929,15 +22189,20 @@ Array [
@@ -23017,7 +23282,7 @@ Array [ - , +
@@ -23055,15 +23320,20 @@ Array [
@@ -23571,12 +23841,14 @@ Array [ - , -] + + `; exports[`Storyshots Diff Side-By-Side 1`] = ` -Array [ +
@@ -23614,15 +23886,20 @@ Array [
@@ -24239,7 +24516,7 @@ Array [ - , +
@@ -24277,15 +24554,20 @@ Array [
@@ -25176,7 +25458,7 @@ Array [ - , +
@@ -25214,15 +25496,20 @@ Array [
@@ -25671,7 +25958,7 @@ Array [ - , +
@@ -25709,15 +25996,20 @@ Array [
@@ -26166,7 +26458,7 @@ Array [ - , +
@@ -26204,15 +26496,20 @@ Array [
@@ -27385,7 +27682,7 @@ Array [ - , +
@@ -27423,15 +27720,20 @@ Array [
@@ -27976,12 +28278,14 @@ Array [ - , -] + + `; exports[`Storyshots Diff SyntaxHighlighting 1`] = ` -Array [ +
@@ -28019,15 +28323,20 @@ Array [
@@ -28551,7 +28860,7 @@ Array [ - , +
@@ -28589,15 +28898,20 @@ Array [
@@ -29398,7 +29712,7 @@ Array [ - , +
@@ -29436,15 +29750,20 @@ Array [
@@ -29841,7 +30160,7 @@ Array [ - , +
@@ -29879,15 +30198,20 @@ Array [
@@ -30284,7 +30608,7 @@ Array [ - , +
@@ -30322,15 +30646,20 @@ Array [
@@ -31334,7 +31663,7 @@ Array [ - , +
@@ -31372,15 +31701,20 @@ Array [
@@ -31852,8 +32186,8 @@ Array [ - , -] + + `; exports[`Storyshots Forms|Checkbox Default 1`] = ` diff --git a/scm-ui/ui-components/src/repos/Diff.stories.tsx b/scm-ui/ui-components/src/repos/Diff.stories.tsx index 52cd80048e..18a6457eb6 100644 --- a/scm-ui/ui-components/src/repos/Diff.stories.tsx +++ b/scm-ui/ui-components/src/repos/Diff.stories.tsx @@ -10,10 +10,16 @@ import { DiffEventContext, File } from "./DiffTypes"; import Toast from "../toast/Toast"; import { getPath } from "./diffs"; import DiffButton from "./DiffButton"; +import styled from "styled-components"; const diffFiles = parser.parse(simpleDiff); +const Container = styled.div` + padding: 2rem 6rem; +`; + storiesOf("Diff", module) + .addDecorator(storyFn => {storyFn()}) .add("Default", () => ) .add("Side-By-Side", () => ) .add("Collapsed", () => ) @@ -21,7 +27,11 @@ storiesOf("Diff", module) ( - alert("Arrrgggghhhh ...")} /> + alert("Arrrgggghhhh ...")} + /> )} /> )) diff --git a/scm-ui/ui-components/src/repos/DiffButton.tsx b/scm-ui/ui-components/src/repos/DiffButton.tsx index 3de37e6f70..ae2bb86306 100644 --- a/scm-ui/ui-components/src/repos/DiffButton.tsx +++ b/scm-ui/ui-components/src/repos/DiffButton.tsx @@ -1,5 +1,6 @@ import React, { FC, MouseEvent } from "react"; import styled from "styled-components"; +import Tooltip from "../Tooltip"; const Button = styled.a` width: 50px; @@ -11,20 +12,22 @@ const Button = styled.a` type Props = { icon: string; - title: string; + tooltip: string; onClick: () => void; }; -const DiffButton: FC = ({ icon, title, onClick }) => { +const DiffButton: FC = ({ icon, tooltip, onClick }) => { const handleClick = (e: MouseEvent) => { e.preventDefault(); onClick(); }; return ( - + + + ); }; diff --git a/scm-ui/ui-components/src/repos/DiffFile.tsx b/scm-ui/ui-components/src/repos/DiffFile.tsx index de784ac629..c8152249b0 100644 --- a/scm-ui/ui-components/src/repos/DiffFile.tsx +++ b/scm-ui/ui-components/src/repos/DiffFile.tsx @@ -253,7 +253,7 @@ class DiffFile extends React.Component { {fileControls}