From 04dfcf7b043aeaa404adc64763db340c9eeb3427 Mon Sep 17 00:00:00 2001 From: Charis Kyriakou Date: Tue, 25 Jul 2023 12:51:55 +0000 Subject: [PATCH 1/2] Remove most recent commit information and sorting --- docs/test-plan.md | 1 - extensions/ql-vscode/CHANGELOG.md | 1 + extensions/ql-vscode/package.json | 2 - .../stories/common/LastUpdated.stories.tsx | 20 ----- .../shared/variant-analysis-filter-sort.ts | 12 --- .../ql-vscode/src/view/common/LastUpdated.tsx | 42 ----------- .../src/view/variant-analysis/RepoRow.tsx | 2 - .../variant-analysis/RepositoriesSort.tsx | 3 - .../__tests__/RepoRow.spec.tsx | 31 +------- .../variant-analysis-filter-sort.test.ts | 75 ------------------- 10 files changed, 3 insertions(+), 186 deletions(-) delete mode 100644 extensions/ql-vscode/src/stories/common/LastUpdated.stories.tsx delete mode 100644 extensions/ql-vscode/src/view/common/LastUpdated.tsx diff --git a/docs/test-plan.md b/docs/test-plan.md index ad0e263b823..64d6658f32b 100644 --- a/docs/test-plan.md +++ b/docs/test-plan.md @@ -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 diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index c18bd6714a5..46cc6af7277 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -2,6 +2,7 @@ ## [UNRELEASED] +- Removed "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) diff --git a/extensions/ql-vscode/package.json b/extensions/ql-vscode/package.json index 11d864a7b64..9c5479587e5 100644 --- a/extensions/ql-vscode/package.json +++ b/extensions/ql-vscode/package.json @@ -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." diff --git a/extensions/ql-vscode/src/stories/common/LastUpdated.stories.tsx b/extensions/ql-vscode/src/stories/common/LastUpdated.stories.tsx deleted file mode 100644 index f0e2dfe24aa..00000000000 --- a/extensions/ql-vscode/src/stories/common/LastUpdated.stories.tsx +++ /dev/null @@ -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; - -const Template: StoryFn = (args) => ( - -); - -export const LastUpdated = Template.bind({}); - -LastUpdated.args = { - lastUpdated: new Date(Date.now() - 3_600_000).toISOString(), // 1 hour ago -}; diff --git a/extensions/ql-vscode/src/variant-analysis/shared/variant-analysis-filter-sort.ts b/extensions/ql-vscode/src/variant-analysis/shared/variant-analysis-filter-sort.ts index e0a05b4d22d..d6a21820714 100644 --- a/extensions/ql-vscode/src/variant-analysis/shared/variant-analysis-filter-sort.ts +++ b/extensions/ql-vscode/src/variant-analysis/shared/variant-analysis-filter-sort.ts @@ -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", { diff --git a/extensions/ql-vscode/src/view/common/LastUpdated.tsx b/extensions/ql-vscode/src/view/common/LastUpdated.tsx deleted file mode 100644 index 451a3adaeaf..00000000000 --- a/extensions/ql-vscode/src/view/common/LastUpdated.tsx +++ /dev/null @@ -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 ( -
- - - - {humanizeRelativeTime(date.getTime() - Date.now())} -
- ); -}; diff --git a/extensions/ql-vscode/src/view/variant-analysis/RepoRow.tsx b/extensions/ql-vscode/src/view/variant-analysis/RepoRow.tsx index 724c0a728c3..151e386d0cf 100644 --- a/extensions/ql-vscode/src/view/variant-analysis/RepoRow.tsx +++ b/extensions/ql-vscode/src/view/variant-analysis/RepoRow.tsx @@ -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 = ({
- {isExpanded && expandableContentLoaded && ( diff --git a/extensions/ql-vscode/src/view/variant-analysis/RepositoriesSort.tsx b/extensions/ql-vscode/src/view/variant-analysis/RepositoriesSort.tsx index 7c5670ed9d2..8005a146944 100644 --- a/extensions/ql-vscode/src/view/variant-analysis/RepositoriesSort.tsx +++ b/extensions/ql-vscode/src/view/variant-analysis/RepositoriesSort.tsx @@ -34,9 +34,6 @@ export const RepositoriesSort = ({ value, onChange, className }: Props) => { Number of results Popularity - - Most recent commit - ); }; diff --git a/extensions/ql-vscode/src/view/variant-analysis/__tests__/RepoRow.spec.tsx b/extensions/ql-vscode/src/view/variant-analysis/__tests__/RepoRow.spec.tsx index 24e233c98f5..88414b087ee 100644 --- a/extensions/ql-vscode/src/view/variant-analysis/__tests__/RepoRow.spec.tsx +++ b/extensions/ql-vscode/src/view/variant-analysis/__tests__/RepoRow.spec.tsx @@ -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 () => { diff --git a/extensions/ql-vscode/test/unit-tests/variant-analysis-filter-sort.test.ts b/extensions/ql-vscode/test/unit-tests/variant-analysis-filter-sort.test.ts index 7caffa20af6..88b39e678de 100644 --- a/extensions/ql-vscode/test/unit-tests/variant-analysis-filter-sort.test.ts +++ b/extensions/ql-vscode/test/unit-tests/variant-analysis-filter-sort.test.ts @@ -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, From 028415684e56b17addd4e9790a37f8a89eed19dc Mon Sep 17 00:00:00 2001 From: Charis Kyriakou Date: Tue, 25 Jul 2023 14:24:57 +0100 Subject: [PATCH 2/2] Update extensions/ql-vscode/CHANGELOG.md Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com> --- extensions/ql-vscode/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index 46cc6af7277..472b02026d7 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -2,7 +2,7 @@ ## [UNRELEASED] -- Removed "last updated" information and sorting from variant analysis results view. [#2637](https://github.com/github/vscode-codeql/pull/2637) +- 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)