Skip to content

Commit bf63ad2

Browse files
pfeufferfscholdei
authored andcommitted
Mark reviewed files in diff file tree
Squash commits of branch feature/review_marks_in_file_tree: - POC for review marks in file tree - Migrate to wrapper - Put check mark in front - Use new extension - Fix hover color - Documentation
1 parent e63b35e commit bf63ad2

File tree

8 files changed

+85
-5
lines changed

8 files changed

+85
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies {
3535
}
3636

3737
scmPlugin {
38-
scmVersion = "3.10.0"
38+
scmVersion = "3.10.2-SNAPSHOT"
3939
displayName = "Review"
4040
description = "Depict a review process with pull requests"
4141
author = "Cloudogu GmbH"
120 KB
Loading

docs/de/working-with-prs/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ Diese Diffs können auch schrittweise oder komplett nachgeladen werden, um den g
2121

2222
![Pull Request - Diff expand](assets/diffExpand.png)
2323

24+
### "Review-Markierungen" für einzelne Dateien
25+
In der Diff-Ansicht kann das Review für einzelne Dateien als abgeschlossen markiert werden. In diesem Fall wird in der
26+
Schaltfläche ein Haken dargestellt, die Datei wird standardmäßig eingeklappt und in dem Dateibaum wird sie ausgegraut.
27+
28+
![Pull Request - Review-Markierungen](assets/markReviewed.png)
29+
2430
### Kommentare erstellen
2531
Für einen Pull Request können drei Arten von Kommentaren erstellt werden.
2632

118 KB
Loading

docs/en/working-with-prs/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ In the pull request all changes are shown as diff per file. This shortened view
2020

2121
![Pull Request - Diff expand](assets/diffExpand.png)
2222

23+
### Review-Marks for single files
24+
In the diff view, single files can be marked as reviewed. In this case, the button will get a check-mark, the file will
25+
be collapsed by default, and it will be grayed-out in the file tree.
26+
27+
![Pull Request - Review-Marks](assets/markReviewed.png)
28+
2329
### Create comments
2430
There are three different kinds of comments for pull requests.
2531

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- type: added
2+
description: Marks for reviewed files in diff file tree

src/main/js/diff/Diff.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ const Diff: FC<Props> = ({
351351
actions={actions}
352352
pullRequestComments={comments?._embedded.pullRequestComments || []}
353353
stickyHeader={stickyHeaderHeight}
354+
reviewedFiles={reviewedFiles}
354355
/>
355356
</StyledDiffWrapper>
356357
);

src/main/js/diff/LoadingDiff.tsx

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,22 @@ import {
3232
WhitespaceMode,
3333
LayoutRadioButtons,
3434
useLayoutState,
35-
devices
35+
devices,
3636
} from "@scm-manager/ui-components";
3737
import { Comment } from "../types/PullRequest";
3838
import PartialNotification from "./PartialNotification";
3939
import styled from "styled-components";
4040
import { useHistory, useLocation } from "react-router-dom";
41+
import { Icon } from "@scm-manager/ui-core";
42+
import classNames from "classnames";
4143

4244
type LoadingDiffProps = DiffObjectProps & {
4345
diffUrl: string;
4446
actions: any;
4547
pullRequestComments: Comment[];
4648
refetchOnWindowFocus?: boolean;
4749
stickyHeader?: boolean | number;
50+
reviewedFiles?: string[];
4851
};
4952

5053
const StickyContainer = styled.div<{ top: number }>`
@@ -57,6 +60,22 @@ const StickyContainer = styled.div<{ top: number }>`
5760
z-index: 11;
5861
`;
5962

63+
export const StackedSpan = styled.span`
64+
width: 3em;
65+
height: 3em;
66+
font-size: 0.5em;
67+
`;
68+
69+
export const StyledIcon = styled(Icon)<{ isSmaller?: boolean }>`
70+
${({ isSmaller }) =>
71+
isSmaller &&
72+
`
73+
font-size: 0.5em;
74+
margin-top: 0.05rem;
75+
`}
76+
min-width: 1.5rem;
77+
`;
78+
6079
export const StickyTreeContainer = styled.div`
6180
@media (min-width: ${devices.widescreen.width}px) {
6281
position: sticky;
@@ -75,7 +94,14 @@ export const Divider = styled.div`
7594
box-shadow: 0 24px 3px -24px var(--scm-border-color);
7695
`;
7796

78-
const LoadingDiff: FC<LoadingDiffProps> = ({ diffUrl, actions, pullRequestComments, stickyHeader, ...props }) => {
97+
const LoadingDiff: FC<LoadingDiffProps> = ({
98+
diffUrl,
99+
actions,
100+
pullRequestComments,
101+
stickyHeader,
102+
reviewedFiles,
103+
...props
104+
}) => {
79105
const [t] = useTranslation("plugins");
80106
const [ignoreWhitespace, setIgnoreWhitespace] = useState<WhitespaceMode>("NONE");
81107
const [layout, setLayout] = useLayoutState();
@@ -140,8 +166,7 @@ const LoadingDiff: FC<LoadingDiffProps> = ({ diffUrl, actions, pullRequestCommen
140166
</div>
141167
<StickyTreeContainer
142168
className={
143-
(layout === "Both" ? "column pl-3" : "column pl-3 is-full") +
144-
(layout !== "Diff" ? "" : " is-hidden")
169+
(layout === "Both" ? "column pl-3" : "column pl-3 is-full") + (layout !== "Diff" ? "" : " is-hidden")
145170
}
146171
>
147172
<FileTreeContent isBorder={layout !== "Diff"}>
@@ -152,6 +177,46 @@ const LoadingDiff: FC<LoadingDiffProps> = ({ diffUrl, actions, pullRequestCommen
152177
tree={data.tree}
153178
currentFile={decodeURIComponent(getFileNameFromHash(location.hash) ?? "")}
154179
setCurrentFile={setFilePath}
180+
FileTreeNodeWrapper={({
181+
path,
182+
name,
183+
isFile,
184+
iconName,
185+
iconColor,
186+
changeType,
187+
children,
188+
isCurrentFile,
189+
}) => {
190+
if (isFile && reviewedFiles?.find((file) => file === path)) {
191+
console.log("rendering reviewed icon for", name);
192+
const lightIcon = (
193+
<StackedSpan className="fa-stack">
194+
<StyledIcon
195+
className={classNames("fa-stack-2x", `has-text-${iconColor}`)}
196+
type="far"
197+
alt={t("diff.showContent")}
198+
>
199+
file
200+
</StyledIcon>
201+
<StyledIcon
202+
className={classNames("fa-stack-1x", "is-relative", `has-text-${iconColor}`)}
203+
isSmaller={iconName === "circle"}
204+
alt={t(`diff.changes.${changeType}`)}
205+
>
206+
{iconName}
207+
</StyledIcon>
208+
</StackedSpan>
209+
);
210+
return (
211+
<>
212+
{lightIcon}
213+
<div className={classNames("ml-1", "has-text-secondary has-hover-color-blue", isCurrentFile ? "has-text-weight-bold": "")}>{name}</div>
214+
</>
215+
);
216+
} else {
217+
return children;
218+
}
219+
}}
155220
/>
156221
)}
157222
</FileTreeContent>

0 commit comments

Comments
 (0)