Remove most recent commit information and sorting (#2637)
This commit is contained in:
@@ -318,7 +318,6 @@ This requires running a MRVA query and seeing the results view.
|
||||
1. Alphabetically
|
||||
2. By number of results
|
||||
3. By popularity
|
||||
4. By most recent commit
|
||||
9. Can filter repos
|
||||
10. Shows correct statistics
|
||||
1. Total number of results
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
## [UNRELEASED]
|
||||
|
||||
- Remove "last updated" information and sorting from variant analysis results view. [#2637](https://github.com/github/vscode-codeql/pull/2637)
|
||||
- Links to code on GitHub now include column numbers as well as line numbers. [#2406](https://github.com/github/vscode-codeql/pull/2406)
|
||||
- No longer highlight trailing commas for jump to definition. [#2615](https://github.com/github/vscode-codeql/pull/2615)
|
||||
|
||||
|
||||
@@ -350,13 +350,11 @@
|
||||
"enum": [
|
||||
"alphabetically",
|
||||
"popularity",
|
||||
"mostRecentCommit",
|
||||
"numberOfResults"
|
||||
],
|
||||
"enumDescriptions": [
|
||||
"Sort repositories alphabetically in the results view.",
|
||||
"Sort repositories by popularity in the results view.",
|
||||
"Sort repositories by most recent commit in the results view.",
|
||||
"Sort repositories by number of results in the results view."
|
||||
],
|
||||
"description": "The default sorting order for repositories in the variant analysis results view."
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { Meta, StoryFn } from "@storybook/react";
|
||||
|
||||
import { LastUpdated as LastUpdatedComponent } from "../../view/common/LastUpdated";
|
||||
|
||||
export default {
|
||||
title: "Last Updated",
|
||||
component: LastUpdatedComponent,
|
||||
} as Meta<typeof LastUpdatedComponent>;
|
||||
|
||||
const Template: StoryFn<typeof LastUpdatedComponent> = (args) => (
|
||||
<LastUpdatedComponent {...args} />
|
||||
);
|
||||
|
||||
export const LastUpdated = Template.bind({});
|
||||
|
||||
LastUpdated.args = {
|
||||
lastUpdated: new Date(Date.now() - 3_600_000).toISOString(), // 1 hour ago
|
||||
};
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Repository, RepositoryWithMetadata } from "./repository";
|
||||
import { parseDate } from "../../common/date";
|
||||
import { assertNever } from "../../common/helpers-pure";
|
||||
|
||||
export enum FilterKey {
|
||||
@@ -10,7 +9,6 @@ export enum FilterKey {
|
||||
export enum SortKey {
|
||||
Alphabetically = "alphabetically",
|
||||
Popularity = "popularity",
|
||||
MostRecentCommit = "mostRecentCommit",
|
||||
NumberOfResults = "numberOfResults",
|
||||
}
|
||||
|
||||
@@ -81,16 +79,6 @@ export function compareRepository(
|
||||
}
|
||||
}
|
||||
|
||||
// Newest to oldest
|
||||
if (filterSortState?.sortKey === SortKey.MostRecentCommit) {
|
||||
const lastUpdated =
|
||||
(parseDate(right.updatedAt)?.getTime() ?? 0) -
|
||||
(parseDate(left.updatedAt)?.getTime() ?? 0);
|
||||
if (lastUpdated !== 0) {
|
||||
return lastUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back on name compare. Use en-US because the repository name does not contain
|
||||
// special characters due to restrictions in GitHub owner/repository names.
|
||||
return left.fullName.localeCompare(right.fullName, "en-US", {
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import * as React from "react";
|
||||
import { useMemo } from "react";
|
||||
import styled from "styled-components";
|
||||
|
||||
import { parseDate } from "../../common/date";
|
||||
import { humanizeRelativeTime } from "../../common/time";
|
||||
|
||||
import { Codicon } from "./icon";
|
||||
|
||||
const IconContainer = styled.span`
|
||||
flex-grow: 0;
|
||||
text-align: right;
|
||||
margin-right: 0;
|
||||
`;
|
||||
|
||||
const Duration = styled.span`
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
width: 8em;
|
||||
margin-left: 0.5em;
|
||||
`;
|
||||
|
||||
type Props = {
|
||||
lastUpdated?: string | null;
|
||||
};
|
||||
|
||||
export const LastUpdated = ({ lastUpdated }: Props) => {
|
||||
const date = useMemo(() => parseDate(lastUpdated), [lastUpdated]);
|
||||
|
||||
if (!date) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<IconContainer>
|
||||
<Codicon name="repo-push" label="Most recent commit" />
|
||||
</IconContainer>
|
||||
<Duration>{humanizeRelativeTime(date.getTime() - Date.now())}</Duration>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
import { vscode } from "../vscode-api";
|
||||
import { AnalyzedRepoItemContent } from "./AnalyzedRepoItemContent";
|
||||
import StarCount from "../common/StarCount";
|
||||
import { LastUpdated } from "../common/LastUpdated";
|
||||
import { useTelemetryOnChange } from "../common/telemetry";
|
||||
import { DeterminateProgressRing } from "../common/DeterminateProgressRing";
|
||||
|
||||
@@ -297,7 +296,6 @@ export const RepoRow = ({
|
||||
<div>
|
||||
<StarCount starCount={repository.stargazersCount} />
|
||||
</div>
|
||||
<LastUpdated lastUpdated={repository.updatedAt} />
|
||||
</MetadataContainer>
|
||||
</TitleContainer>
|
||||
{isExpanded && expandableContentLoaded && (
|
||||
|
||||
@@ -34,9 +34,6 @@ export const RepositoriesSort = ({ value, onChange, className }: Props) => {
|
||||
Number of results
|
||||
</VSCodeOption>
|
||||
<VSCodeOption value={SortKey.Popularity}>Popularity</VSCodeOption>
|
||||
<VSCodeOption value={SortKey.MostRecentCommit}>
|
||||
Most recent commit
|
||||
</VSCodeOption>
|
||||
</Dropdown>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -38,10 +38,7 @@ describe(RepoRow.name, () => {
|
||||
expect(
|
||||
screen.queryByRole("img", {
|
||||
// There should not be any icons, except for the icons which are always shown
|
||||
name: (name) =>
|
||||
!["expand", "stars count", "most recent commit"].includes(
|
||||
name.toLowerCase(),
|
||||
),
|
||||
name: (name) => !["expand", "stars count"].includes(name.toLowerCase()),
|
||||
}),
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
@@ -279,26 +276,7 @@ describe(RepoRow.name, () => {
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows updated at", () => {
|
||||
render({
|
||||
repository: {
|
||||
...createMockRepositoryWithMetadata(),
|
||||
// 1 month ago
|
||||
updatedAt: new Date(
|
||||
Date.now() - 1000 * 60 * 60 * 24 * 30,
|
||||
).toISOString(),
|
||||
},
|
||||
});
|
||||
|
||||
expect(screen.getByText("last month")).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("img", {
|
||||
name: "Most recent commit",
|
||||
}),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("does not show star count and updated at when unknown", () => {
|
||||
it("does not show star count when unknown", () => {
|
||||
render({
|
||||
repository: {
|
||||
id: undefined,
|
||||
@@ -312,11 +290,6 @@ describe(RepoRow.name, () => {
|
||||
name: "Stars count",
|
||||
}),
|
||||
).not.toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByRole("img", {
|
||||
name: "Most recent commit",
|
||||
}),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("can expand the repo item", async () => {
|
||||
|
||||
@@ -204,55 +204,6 @@ describe(compareRepository.name, () => {
|
||||
).toBeLessThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when sort key is 'Most recent commit'", () => {
|
||||
const sorter = compareRepository({
|
||||
...permissiveFilterSortState,
|
||||
sortKey: SortKey.MostRecentCommit,
|
||||
});
|
||||
|
||||
const left = {
|
||||
fullName: "github/galaxy",
|
||||
updatedAt: "2020-01-01T00:00:00Z",
|
||||
};
|
||||
const right = {
|
||||
fullName: "github/world",
|
||||
updatedAt: "2021-01-01T00:00:00Z",
|
||||
};
|
||||
|
||||
it("compares correctly", () => {
|
||||
expect(sorter(left, right)).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("compares the inverse correctly", () => {
|
||||
expect(sorter(right, left)).toBeLessThan(0);
|
||||
});
|
||||
|
||||
it("compares equal values correctly", () => {
|
||||
expect(sorter(left, left)).toBe(0);
|
||||
});
|
||||
|
||||
it("compares equal single values correctly", () => {
|
||||
expect(
|
||||
sorter(left, {
|
||||
...right,
|
||||
updatedAt: left.updatedAt,
|
||||
}),
|
||||
).toBeLessThan(0);
|
||||
});
|
||||
|
||||
it("compares missing single values correctly", () => {
|
||||
expect(
|
||||
sorter(
|
||||
{
|
||||
...left,
|
||||
updatedAt: undefined,
|
||||
},
|
||||
right,
|
||||
),
|
||||
).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(compareWithResults.name, () => {
|
||||
@@ -303,32 +254,6 @@ describe(compareWithResults.name, () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("when sort key is 'Most recent commit'", () => {
|
||||
const sorter = compareWithResults({
|
||||
...permissiveFilterSortState,
|
||||
sortKey: SortKey.MostRecentCommit,
|
||||
});
|
||||
|
||||
const left = {
|
||||
repository: {
|
||||
id: 11,
|
||||
fullName: "github/galaxy",
|
||||
updatedAt: "2020-01-01T00:00:00Z",
|
||||
},
|
||||
};
|
||||
const right = {
|
||||
repository: {
|
||||
id: 12,
|
||||
fullName: "github/world",
|
||||
updatedAt: "2021-01-01T00:00:00Z",
|
||||
},
|
||||
};
|
||||
|
||||
it("compares correctly", () => {
|
||||
expect(sorter(left, right)).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when sort key is results count", () => {
|
||||
const sorter = compareWithResults({
|
||||
...permissiveFilterSortState,
|
||||
|
||||
Reference in New Issue
Block a user