Skip to content

Commit

Permalink
Deduplicate SCM providers for browser extension banner (gitpod-io#19677)
Browse files Browse the repository at this point in the history
* Deduplicate SCM providers for browser extension banner

* make lodash import more strict
  • Loading branch information
filiptronicek authored Apr 29, 2024
1 parent 85c8765 commit 4e9bb3f
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions components/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"file-saver": "^2.0.5",
"idb-keyval": "^6.2.0",
"js-cookie": "^3.0.1",
"lodash.debounce": "^4.0.8",
"lodash": "^4.17.21",
"lucide-react": "^0.287.0",
"monaco-editor": "^0.25.2",
"pretty-bytes": "^6.1.0",
Expand Down Expand Up @@ -75,7 +75,7 @@
"@types/file-saver": "^2.0.5",
"@types/jest": "^26.0.22",
"@types/js-cookie": "^2.2.7",
"@types/lodash.debounce": "^4.0.7",
"@types/lodash": "^4.17.0",
"@types/node": "^18.18.8",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.3",
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/components/WorkspaceLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import EventEmitter from "events";
import { useContext, useEffect, useMemo, useRef } from "react";
import { Terminal, ITerminalOptions, ITheme } from "xterm";
import debounce from "lodash.debounce";
import debounce from "lodash/debounce";
import { FitAddon } from "xterm-addon-fit";
import "xterm/css/xterm.css";
import { ThemeContext } from "../theme-context";
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/data/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { QueryCache, QueryClient, QueryKey } from "@tanstack/react-query";
import { Message } from "@bufbuild/protobuf";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { FunctionComponent } from "react";
import debounce from "lodash.debounce";
import debounce from "lodash/debounce";
// Need to import all the protobuf classes we want to support for hydration
import * as OrganizationClasses from "@gitpod/public-api/lib/gitpod/v1/organization_pb";
import * as WorkspaceClasses from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/hooks/use-debounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { useEffect, useMemo, useState } from "react";
import debounce from "lodash.debounce";
import debounce from "lodash/debounce";

type DebounceOptions = {
leading?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/hooks/use-state-with-debounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { useEffect, useMemo, useState } from "react";
import debounce from "lodash.debounce";
import debounce from "lodash/debounce";

export const useStateWithDebounce = <T>(initialValue: T, delay = 500): [T, (value: T) => void, T] => {
const [value, setValue] = useState<T>(initialValue);
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/projects/ProjectSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { useToast } from "../components/toasts/Toasts";
import classNames from "classnames";
import { InputField } from "../components/forms/InputField";
import { SelectInputField } from "../components/forms/SelectInputField";
import debounce from "lodash.debounce";
import debounce from "lodash/debounce";
import { Button } from "@podkit/buttons/Button";
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
import { PartialMessage } from "@bufbuild/protobuf";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { trackEvent } from "../Analytics";
import bitbucketButton from "../images/browser-extension/bitbucket.webp";
import githubButton from "../images/browser-extension/github.webp";
import gitlabButton from "../images/browser-extension/gitlab.webp";
import uniq from "lodash/uniq";

const browserExtensionImages = {
Bitbucket: bitbucketButton,
Expand Down Expand Up @@ -66,10 +67,12 @@ const getDeduplicatedScmProviders = (user: User, descriptions: AuthProviderDescr
.filter(isIdentity)
.map((provider) => provider.type);

return userProviders
const unifiedProviders = userProviders
.map((type) => unifyProviderType(type))
.filter(isAuthProviderType)
.sort();

return uniq(unifiedProviders);
};

const displayScmProviders = (providers: UnifiedAuthProvider[]): string => {
Expand Down
12 changes: 5 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3697,18 +3697,16 @@
dependencies:
"@types/lodash" "*"

"@types/lodash.debounce@^4.0.7":
version "4.0.7"
resolved "https://registry.yarnpkg.com/@types/lodash.debounce/-/lodash.debounce-4.0.7.tgz#0285879defb7cdb156ae633cecd62d5680eded9f"
integrity sha512-X1T4wMZ+gT000M2/91SYj0d/7JfeNZ9PeeOldSNoE/lunLeQXKvkmIumI29IaKMotU/ln/McOIvgzZcQ/3TrSA==
dependencies:
"@types/lodash" "*"

"@types/lodash@*":
version "4.14.176"
resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.176.tgz"
integrity sha512-xZmuPTa3rlZoIbtDUyJKZQimJV3bxCmzMIO2c9Pz9afyDro6kr7R79GwcB6mRhuoPmV2p1Vb66WOJH7F886WKQ==

"@types/lodash@^4.17.0":
version "4.17.0"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.0.tgz#d774355e41f372d5350a4d0714abb48194a489c3"
integrity sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==

"@types/[email protected]":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.0.tgz#719551d2352d301ac8b81db732acb6bdc28dbdef"
Expand Down

0 comments on commit 4e9bb3f

Please sign in to comment.