diff --git a/pkg/ui/BUILD.bazel b/pkg/ui/BUILD.bazel index a471736adaf7..52ed7644956e 100644 --- a/pkg/ui/BUILD.bazel +++ b/pkg/ui/BUILD.bazel @@ -12,6 +12,7 @@ go_library( "//pkg/base", "//pkg/build", "//pkg/server/serverpb", + "//pkg/settings", "//pkg/util/httputil", "//pkg/util/log", ], diff --git a/pkg/ui/ui.go b/pkg/ui/ui.go index bfe6ade224e4..f49ec8944156 100644 --- a/pkg/ui/ui.go +++ b/pkg/ui/ui.go @@ -28,10 +28,31 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/build" "github.com/cockroachdb/cockroach/pkg/server/serverpb" + "github.com/cockroachdb/cockroach/pkg/settings" "github.com/cockroachdb/cockroach/pkg/util/httputil" "github.com/cockroachdb/cockroach/pkg/util/log" ) +const ( + utc int64 = iota + americaNewYork +) + +var _ = settings.RegisterEnumSetting( + settings.SystemOnly, + "ui.display_timezone", + "the timezone used to format timestamps in the ui", + "Etc/UTC", + map[int64]string{ + utc: "Etc/UTC", + americaNewYork: "America/New_York", + // Adding new timezones? + // Add them to the allowlist of included timezones! + // See pkg/ui/workspaces/cluster-ui/webpack.config.js + // and pkg/ui/workspaces/db-console/webpack.config.js. + }, +) + // Assets is used for embedded JS assets required for UI. // In case the binary is built without UI, it provides single index.html file with // the same content as indexHTML as a fallback. diff --git a/pkg/ui/workspaces/cluster-ui/.gitignore b/pkg/ui/workspaces/cluster-ui/.gitignore index f06235c460c2..cc60cbf013c2 100644 --- a/pkg/ui/workspaces/cluster-ui/.gitignore +++ b/pkg/ui/workspaces/cluster-ui/.gitignore @@ -1,2 +1,3 @@ node_modules dist +timezones diff --git a/pkg/ui/workspaces/cluster-ui/BUILD.bazel b/pkg/ui/workspaces/cluster-ui/BUILD.bazel index e15356159c8d..152d5bdedce5 100644 --- a/pkg/ui/workspaces/cluster-ui/BUILD.bazel +++ b/pkg/ui/workspaces/cluster-ui/BUILD.bazel @@ -98,7 +98,10 @@ DEPENDENCIES = [ "@npm_cluster_ui//less", "@npm_cluster_ui//less-loader", "@npm_cluster_ui//long", + "@npm_cluster_ui//moment", + "@npm_cluster_ui//moment-timezone", "@npm_cluster_ui//moment-locales-webpack-plugin", + "@npm_cluster_ui//moment-timezone-data-webpack-plugin", "@npm_cluster_ui//npm-run-all", "@npm_cluster_ui//prettier", "@npm_cluster_ui//protobufjs", @@ -162,6 +165,7 @@ ts_project( "@npm_cluster_ui//classnames", "@npm_cluster_ui//connected-react-router", "@npm_cluster_ui//moment", + "@npm_cluster_ui//moment-timezone", "@npm_cluster_ui//protobufjs", "@npm_cluster_ui//redux", "@npm_cluster_ui//redux-saga", @@ -278,6 +282,7 @@ tsc_test( "@npm_cluster_ui//classnames", "@npm_cluster_ui//connected-react-router", "@npm_cluster_ui//moment", + "@npm_cluster_ui//moment-timezone", "@npm_cluster_ui//protobufjs", "@npm_cluster_ui//redux", "@npm_cluster_ui//redux-saga", diff --git a/pkg/ui/workspaces/cluster-ui/package.json b/pkg/ui/workspaces/cluster-ui/package.json index 6863116ce901..4bc44d652415 100644 --- a/pkg/ui/workspaces/cluster-ui/package.json +++ b/pkg/ui/workspaces/cluster-ui/package.json @@ -119,7 +119,10 @@ "less": "^3.12.2", "less-loader": "^6.2.0", "long": "^4.0.0", + "moment": "^2.29.4", "moment-locales-webpack-plugin": "^1.2.0", + "moment-timezone": "^0.5.42", + "moment-timezone-data-webpack-plugin": "^1.5.1", "npm-run-all": "^4.1.5", "prettier": "^2.6.2", "protobufjs": "6.8.6", diff --git a/pkg/ui/workspaces/cluster-ui/src/api/clusterLocksApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/clusterLocksApi.ts index b7660d295986..c5827c5b4984 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/clusterLocksApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/clusterLocksApi.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { executeInternalSql, LONG_TIMEOUT, diff --git a/pkg/ui/workspaces/cluster-ui/src/api/contentionApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/contentionApi.ts index 128ce0e4732b..65e7e06ec53d 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/contentionApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/contentionApi.ts @@ -18,7 +18,7 @@ import { formatApiResult, } from "./sqlApi"; import { ContentionDetails } from "src/insights"; -import moment from "moment"; +import moment from "moment-timezone"; export type ContentionFilters = { waitingTxnID?: string; diff --git a/pkg/ui/workspaces/cluster-ui/src/api/databaseDetailsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/databaseDetailsApi.ts index c8db0e7e6803..5376c6230dd8 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/databaseDetailsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/databaseDetailsApi.ts @@ -23,7 +23,7 @@ import { } from "./sqlApi"; import { IndexUsageStatistic, recommendDropUnusedIndex } from "../insights"; import { Format, Identifier, QualifiedIdentifier } from "./safesql"; -import moment from "moment"; +import moment from "moment-timezone"; import { fromHexString, withTimeout } from "./util"; import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; diff --git a/pkg/ui/workspaces/cluster-ui/src/api/databasesApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/databasesApi.ts index 1d8d5d070dfa..0aa9a5e5b0b8 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/databasesApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/databasesApi.ts @@ -16,7 +16,7 @@ import { sqlResultsAreEmpty, } from "./sqlApi"; import { withTimeout } from "./util"; -import moment from "moment"; +import moment from "moment-timezone"; export type DatabasesColumns = { database_name: string; diff --git a/pkg/ui/workspaces/cluster-ui/src/api/eventsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/eventsApi.ts index abfd401f37a6..443b202f2046 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/eventsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/eventsApi.ts @@ -18,7 +18,7 @@ import { formatApiResult, } from "./sqlApi"; import { withTimeout } from "./util"; -import moment from "moment"; +import moment from "moment-timezone"; // defaultEventsNumLimit is the default number of events to be returned. export const defaultEventsNumLimit = 1000; diff --git a/pkg/ui/workspaces/cluster-ui/src/api/indexDetailsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/indexDetailsApi.ts index d6f6a29f0b51..420bdb6eda78 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/indexDetailsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/indexDetailsApi.ts @@ -19,7 +19,7 @@ import { sqlResultsAreEmpty, StatementRawFormat, } from "src/api"; -import moment from "moment"; +import moment from "moment-timezone"; import { TimeScale, toRoundedDateRange } from "../timeScaleDropdown"; import { AggregateStatistics } from "../statementsTable"; import { INTERNAL_APP_NAME_PREFIX } from "../recentExecutions/recentStatementUtils"; diff --git a/pkg/ui/workspaces/cluster-ui/src/api/schedulesApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/schedulesApi.ts index bf4907ff5c50..3833c5375b56 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/schedulesApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/schedulesApi.ts @@ -9,7 +9,7 @@ // licenses/APL.txt. import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; import { executeInternalSql, SqlExecutionRequest, diff --git a/pkg/ui/workspaces/cluster-ui/src/api/statementDiagnosticsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/statementDiagnosticsApi.ts index 0b1b8df1e639..f290fb534372 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/statementDiagnosticsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/statementDiagnosticsApi.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { executeInternalSql, SqlExecutionRequest, diff --git a/pkg/ui/workspaces/cluster-ui/src/api/statementsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/statementsApi.ts index e637684f6abe..9bde8db1fc9f 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/statementsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/statementsApi.ts @@ -18,7 +18,7 @@ import { stringToTimestamp, } from "src/util"; import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; import { AggregateStatistics } from "../statementsTable"; const STATEMENTS_PATH = "/_status/combinedstmts"; diff --git a/pkg/ui/workspaces/cluster-ui/src/api/stmtInsightsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/stmtInsightsApi.ts index 7b5d303a06e8..c273b5803808 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/stmtInsightsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/stmtInsightsApi.ts @@ -25,7 +25,7 @@ import { StatementStatus, StmtInsightEvent, } from "src/insights"; -import moment from "moment"; +import moment from "moment-timezone"; import { INTERNAL_APP_NAME_PREFIX } from "src/util/constants"; import { FixFingerprintHexValue } from "../util"; import { getContentionDetailsApi } from "./contentionApi"; diff --git a/pkg/ui/workspaces/cluster-ui/src/api/tableDetailsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/tableDetailsApi.ts index 8613e7a5375b..e76721bba6b0 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/tableDetailsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/tableDetailsApi.ts @@ -21,7 +21,7 @@ import { SqlTxnResult, txnResultIsEmpty, } from "./sqlApi"; -import moment from "moment"; +import moment from "moment-timezone"; import { fromHexString, withTimeout } from "./util"; import { Format, Identifier, Join, SQL } from "./safesql"; import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; diff --git a/pkg/ui/workspaces/cluster-ui/src/api/txnInsightsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/txnInsightsApi.ts index 954ade64d19a..c38a8b6aa3c3 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/txnInsightsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/txnInsightsApi.ts @@ -31,7 +31,7 @@ import { TxnInsightDetails, TxnInsightEvent, } from "src/insights"; -import moment from "moment"; +import moment from "moment-timezone"; import { FixFingerprintHexValue } from "../util"; import { formatStmtInsights, diff --git a/pkg/ui/workspaces/cluster-ui/src/api/util.ts b/pkg/ui/workspaces/cluster-ui/src/api/util.ts index fd2cfa58d2d3..589a3e3a1fa2 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/util.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/util.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; export const PROMISE_TIMEOUT = moment.duration(30, "s"); // seconds diff --git a/pkg/ui/workspaces/cluster-ui/src/contexts/index.ts b/pkg/ui/workspaces/cluster-ui/src/contexts/index.ts index f252008a33d3..177f9097c585 100644 --- a/pkg/ui/workspaces/cluster-ui/src/contexts/index.ts +++ b/pkg/ui/workspaces/cluster-ui/src/contexts/index.ts @@ -9,3 +9,4 @@ // licenses/APL.txt. export * from "./cockroachCloudContext"; +export * from "./timezoneContext"; diff --git a/pkg/ui/workspaces/cluster-ui/src/contexts/timezoneContext.tsx b/pkg/ui/workspaces/cluster-ui/src/contexts/timezoneContext.tsx new file mode 100644 index 000000000000..dfe6deb91f9a --- /dev/null +++ b/pkg/ui/workspaces/cluster-ui/src/contexts/timezoneContext.tsx @@ -0,0 +1,33 @@ +// Copyright 2023 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +import React from "react"; +import { createContext, useContext } from "react"; + +export const CoordinatedUniversalTime = "Etc/UTC"; +export const TimezoneContext = createContext(CoordinatedUniversalTime); + +interface WithTimezoneProps { + timezone: string; +} + +// WithTimezone wraps a class component to provide the +// context's timezone value as a component prop. +export function WithTimezone( + Component: React.ComponentType, +) { + return (props: T) => { + // This lambda is a React function component. + // It is safe to call a hook here. + // eslint-disable-next-line + const timezone = useContext(TimezoneContext); + return ; + }; +} diff --git a/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.stories.tsx b/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.stories.tsx index c8e5852aaf29..8e91151cce0f 100644 --- a/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.stories.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.stories.tsx @@ -26,7 +26,7 @@ import { } from "./databaseDetailsPage"; import * as H from "history"; -import moment from "moment"; +import moment from "moment-timezone"; import { defaultFilters } from "src/queryFilter"; const history = H.createHashHistory(); diff --git a/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx b/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx index a18f026a036c..3c3706aa69cf 100644 --- a/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx @@ -37,7 +37,7 @@ import { mvccGarbage, syncHistory, unique } from "../util"; import styles from "./databaseDetailsPage.module.scss"; import sortableTableStyles from "src/sortedtable/sortedtable.module.scss"; import { baseHeadingClasses } from "src/transactionsPage/transactionsPageClasses"; -import { Moment } from "moment"; +import { Moment } from "moment-timezone"; import { Caution } from "@cockroachlabs/icons"; import { Anchor } from "../anchor"; import LoadingError from "../sqlActivity/errorComponent"; diff --git a/pkg/ui/workspaces/cluster-ui/src/databaseTablePage/databaseTablePage.stories.tsx b/pkg/ui/workspaces/cluster-ui/src/databaseTablePage/databaseTablePage.stories.tsx index c633133ec538..2b52828a5a24 100644 --- a/pkg/ui/workspaces/cluster-ui/src/databaseTablePage/databaseTablePage.stories.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/databaseTablePage/databaseTablePage.stories.tsx @@ -19,7 +19,7 @@ import { randomTablePrivilege, } from "src/storybook/fixtures"; import { DatabaseTablePage, DatabaseTablePageProps } from "./databaseTablePage"; -import moment from "moment"; +import moment from "moment-timezone"; import * as H from "history"; const history = H.createHashHistory(); diff --git a/pkg/ui/workspaces/cluster-ui/src/databaseTablePage/databaseTablePage.tsx b/pkg/ui/workspaces/cluster-ui/src/databaseTablePage/databaseTablePage.tsx index 4b0bef8dad98..c4a49f718879 100644 --- a/pkg/ui/workspaces/cluster-ui/src/databaseTablePage/databaseTablePage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/databaseTablePage/databaseTablePage.tsx @@ -49,7 +49,7 @@ import { import styles from "./databaseTablePage.module.scss"; import { commonStyles } from "src/common"; import { baseHeadingClasses } from "src/transactionsPage/transactionsPageClasses"; -import moment, { Moment } from "moment"; +import moment, { Moment } from "moment-timezone"; import { Search as IndexIcon } from "@cockroachlabs/icons"; import booleanSettingStyles from "../settings/booleanSetting.module.scss"; import { CircleFilled } from "../icon"; diff --git a/pkg/ui/workspaces/cluster-ui/src/dateRangeMenu/dateRangeMenu.tsx b/pkg/ui/workspaces/cluster-ui/src/dateRangeMenu/dateRangeMenu.tsx index d89fe8dbad36..86fe826f08b0 100644 --- a/pkg/ui/workspaces/cluster-ui/src/dateRangeMenu/dateRangeMenu.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/dateRangeMenu/dateRangeMenu.tsx @@ -14,7 +14,7 @@ import "antd/lib/time-picker/style"; import "antd/lib/icon/style"; import "antd/lib/date-picker/style"; import "antd/lib/alert/style"; -import moment, { Moment } from "moment"; +import moment, { Moment } from "moment-timezone"; import classNames from "classnames/bind"; import { Time as TimeIcon, ErrorCircleFilled } from "@cockroachlabs/icons"; import { Button } from "src/button"; diff --git a/pkg/ui/workspaces/cluster-ui/src/delayed/delayed.tsx b/pkg/ui/workspaces/cluster-ui/src/delayed/delayed.tsx index 38b26b377432..9f2abad6afb7 100644 --- a/pkg/ui/workspaces/cluster-ui/src/delayed/delayed.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/delayed/delayed.tsx @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import React, { useState, useEffect } from "react"; type Props = { diff --git a/pkg/ui/workspaces/cluster-ui/src/graphs/utils/domain.ts b/pkg/ui/workspaces/cluster-ui/src/graphs/utils/domain.ts index b9226375c923..37fd4728aa05 100644 --- a/pkg/ui/workspaces/cluster-ui/src/graphs/utils/domain.ts +++ b/pkg/ui/workspaces/cluster-ui/src/graphs/utils/domain.ts @@ -9,7 +9,7 @@ // licenses/APL.txt. import _ from "lodash"; -import moment from "moment"; +import moment from "moment-timezone"; import { BytesFitScale, diff --git a/pkg/ui/workspaces/cluster-ui/src/indexDetailsPage/indexDetailsPage.stories.tsx b/pkg/ui/workspaces/cluster-ui/src/indexDetailsPage/indexDetailsPage.stories.tsx index 5dee11534706..5578ce43b129 100644 --- a/pkg/ui/workspaces/cluster-ui/src/indexDetailsPage/indexDetailsPage.stories.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/indexDetailsPage/indexDetailsPage.stories.tsx @@ -14,7 +14,7 @@ import { storiesOf } from "@storybook/react"; import { withBackground, withRouterProvider } from "src/storybook/decorators"; import { randomName } from "src/storybook/fixtures"; import { IndexDetailsPage, IndexDetailsPageProps } from "./indexDetailsPage"; -import moment from "moment"; +import moment from "moment-timezone"; const withData: IndexDetailsPageProps = { databaseName: randomName(), diff --git a/pkg/ui/workspaces/cluster-ui/src/indexDetailsPage/indexDetailsPage.tsx b/pkg/ui/workspaces/cluster-ui/src/indexDetailsPage/indexDetailsPage.tsx index 38ed29b30fec..6d6b725e7e4e 100644 --- a/pkg/ui/workspaces/cluster-ui/src/indexDetailsPage/indexDetailsPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/indexDetailsPage/indexDetailsPage.tsx @@ -28,7 +28,7 @@ import "antd/lib/col/style"; import "antd/lib/row/style"; import "antd/lib/tooltip/style"; import { SummaryCard } from "../summaryCard"; -import moment, { Moment } from "moment"; +import moment, { Moment } from "moment-timezone"; import { Heading } from "@cockroachlabs/ui-components"; import { Anchor } from "../anchor"; import { diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/schemaInsights/indexUsageStatsRec.spec.ts b/pkg/ui/workspaces/cluster-ui/src/insights/schemaInsights/indexUsageStatsRec.spec.ts index 8b37657e9636..ce5640735271 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/schemaInsights/indexUsageStatsRec.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/insights/schemaInsights/indexUsageStatsRec.spec.ts @@ -14,7 +14,7 @@ import { recommendDropUnusedIndex, } from "./indexUsageStatsRec"; import { ClusterIndexUsageStatistic } from "../../api"; -import moment from "moment"; +import moment from "moment-timezone"; describe("recommendDropUnusedIndex", () => { const mockCurrentTime = moment(); diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/schemaInsights/indexUsageStatsRec.ts b/pkg/ui/workspaces/cluster-ui/src/insights/schemaInsights/indexUsageStatsRec.ts index b573d8ea548f..f9322dbe163f 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/schemaInsights/indexUsageStatsRec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/insights/schemaInsights/indexUsageStatsRec.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; export const indexNeverUsedReason = "This index has not been used and can be removed for better write performance."; diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/types.ts b/pkg/ui/workspaces/cluster-ui/src/insights/types.ts index 64fc4ac6584f..e88fc568cd10 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/types.ts +++ b/pkg/ui/workspaces/cluster-ui/src/insights/types.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import { Moment } from "moment"; +import { Moment } from "moment-timezone"; import { Filters } from "../queryFilter"; // This enum corresponds to the string enum for `problems` in `cluster_execution_insights` diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/utils.spec.ts b/pkg/ui/workspaces/cluster-ui/src/insights/utils.spec.ts index 63d5a20703ba..de9b03fdcb42 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/utils.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/insights/utils.spec.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { filterStatementInsights, filterTransactionInsights, diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsView.tsx b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsView.tsx index ccdce17da67f..051a548163f6 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsView.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsights/statementInsights/statementInsightsView.tsx @@ -51,7 +51,7 @@ import { timeScaleRangeToObj, } from "../../../timeScaleDropdown"; import { StmtInsightsReq } from "src/api/stmtInsightsApi"; -import moment from "moment"; +import moment from "moment-timezone"; import styles from "src/statementsPage/statementsPage.module.scss"; import sortableTableStyles from "src/sortedtable/sortedtable.module.scss"; diff --git a/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.fixture.tsx b/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.fixture.tsx index e56039ef6ee3..62995fb1ab34 100644 --- a/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.fixture.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.fixture.tsx @@ -12,7 +12,7 @@ import * as protos from "@cockroachlabs/crdb-protobuf-client"; import { createMemoryHistory } from "history"; import Long from "long"; import { JobsPageProps } from "./jobsPage"; -import moment from "moment"; +import moment from "moment-timezone"; import JobsResponse = cockroach.server.serverpb.JobsResponse; import Job = cockroach.server.serverpb.IJobResponse; diff --git a/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.spec.tsx b/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.spec.tsx index 15ce5dfaae2a..5dc0b12c0c55 100644 --- a/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.spec.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.spec.tsx @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; import { JobsPage, JobsPageProps } from "./jobsPage"; import { formatDuration } from "../util/duration"; diff --git a/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.tsx b/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.tsx index 2dead1f7a2b8..4d23b6d482b9 100644 --- a/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPage.tsx @@ -9,7 +9,7 @@ // licenses/APL.txt. import { cockroach, google } from "@cockroachlabs/crdb-protobuf-client"; import { InlineAlert } from "@cockroachlabs/ui-components"; -import moment from "moment"; +import moment from "moment-timezone"; import React from "react"; import { Helmet } from "react-helmet"; import { RouteComponentProps } from "react-router-dom"; diff --git a/pkg/ui/workspaces/cluster-ui/src/jobs/util/duration.tsx b/pkg/ui/workspaces/cluster-ui/src/jobs/util/duration.tsx index 29200a43cac0..db8470134ac0 100644 --- a/pkg/ui/workspaces/cluster-ui/src/jobs/util/duration.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/jobs/util/duration.tsx @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; -import moment from "moment"; +import moment from "moment-timezone"; import React from "react"; import { TimestampToMoment } from "src/util"; diff --git a/pkg/ui/workspaces/cluster-ui/src/jobs/util/highwaterTimestamp.tsx b/pkg/ui/workspaces/cluster-ui/src/jobs/util/highwaterTimestamp.tsx index bf3049718a0d..ab5ccd0fa34d 100644 --- a/pkg/ui/workspaces/cluster-ui/src/jobs/util/highwaterTimestamp.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/jobs/util/highwaterTimestamp.tsx @@ -9,7 +9,7 @@ // licenses/APL.txt. import { google } from "@cockroachlabs/crdb-protobuf-client"; import { Tooltip } from "@cockroachlabs/ui-components"; -import moment from "moment"; +import moment from "moment-timezone"; import React from "react"; import { DATE_FORMAT_24_UTC } from "src/util/format"; diff --git a/pkg/ui/workspaces/cluster-ui/src/network/identity.ts b/pkg/ui/workspaces/cluster-ui/src/network/identity.ts index 21d8abe0c62d..ae6c998f210c 100644 --- a/pkg/ui/workspaces/cluster-ui/src/network/identity.ts +++ b/pkg/ui/workspaces/cluster-ui/src/network/identity.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; export interface Identity { nodeID: number; diff --git a/pkg/ui/workspaces/cluster-ui/src/recentExecutions/recentStatementUtils.spec.ts b/pkg/ui/workspaces/cluster-ui/src/recentExecutions/recentStatementUtils.spec.ts index 97377cf932c2..9e3d960985ef 100644 --- a/pkg/ui/workspaces/cluster-ui/src/recentExecutions/recentStatementUtils.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/recentExecutions/recentStatementUtils.spec.ts @@ -19,7 +19,7 @@ import { ExecutionStatus, } from "./types"; import * as protos from "@cockroachlabs/crdb-protobuf-client"; -import moment from "moment"; +import moment from "moment-timezone"; import { TimestampToMoment } from "../util"; import Long from "long"; import { diff --git a/pkg/ui/workspaces/cluster-ui/src/recentExecutions/recentStatementUtils.ts b/pkg/ui/workspaces/cluster-ui/src/recentExecutions/recentStatementUtils.ts index c88d6a0eac04..6a322d2c8d44 100644 --- a/pkg/ui/workspaces/cluster-ui/src/recentExecutions/recentStatementUtils.ts +++ b/pkg/ui/workspaces/cluster-ui/src/recentExecutions/recentStatementUtils.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { byteArrayToUuid } from "src/sessions"; import { TimestampToMoment, unset } from "src/util"; import { RecentTransaction } from "."; diff --git a/pkg/ui/workspaces/cluster-ui/src/recentExecutions/types.ts b/pkg/ui/workspaces/cluster-ui/src/recentExecutions/types.ts index 931a23c8ac84..862856484048 100644 --- a/pkg/ui/workspaces/cluster-ui/src/recentExecutions/types.ts +++ b/pkg/ui/workspaces/cluster-ui/src/recentExecutions/types.ts @@ -9,7 +9,7 @@ // licenses/APL.txt. import * as protos from "@cockroachlabs/crdb-protobuf-client"; -import { Moment } from "moment"; +import { Moment } from "moment-timezone"; import { Filters } from "src/queryFilter"; export type SessionsResponse = diff --git a/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.fixture.tsx b/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.fixture.tsx index f9c2b738ee8d..46dcd0d1f53a 100644 --- a/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.fixture.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.fixture.tsx @@ -10,7 +10,7 @@ import * as protos from "@cockroachlabs/crdb-protobuf-client"; import { createMemoryHistory } from "history"; import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; import { SchedulesPageProps } from "./schedulesPage"; import { Schedule } from "src/api/schedulesApi"; diff --git a/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.spec.tsx b/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.spec.tsx index cf6b818d5f2c..e37f5bd533c8 100644 --- a/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.spec.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.spec.tsx @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; import { SchedulesPage, SchedulesPageProps } from "./schedulesPage"; import { allSchedulesFixture } from "./schedulesPage.fixture"; diff --git a/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.tsx b/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.tsx index b213844fd3b5..1431341f5bde 100644 --- a/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/schedules/schedulesPage/schedulesPage.tsx @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. import { InlineAlert } from "@cockroachlabs/ui-components"; -import moment from "moment"; +import moment from "moment-timezone"; import React, { useEffect } from "react"; import { Helmet } from "react-helmet"; import { RouteComponentProps } from "react-router-dom"; diff --git a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionDetails.tsx b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionDetails.tsx index a4b82c830437..f4e2984f1497 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionDetails.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionDetails.tsx @@ -55,7 +55,7 @@ import classNames from "classnames/bind"; import { commonStyles } from "src/common"; import { CircleFilled } from "../icon"; import { createTimeScaleFromDateRange, TimeScale } from "src/timeScaleDropdown"; -import moment from "moment"; +import moment from "moment-timezone"; const cx = classNames.bind(styles); const statementsPageCx = classNames.bind(statementsPageStyles); diff --git a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPage.tsx b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPage.tsx index 3fde145b7787..794192582267 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPage.tsx @@ -58,7 +58,7 @@ import ColumnsSelector, { SelectOption, } from "../columnsSelector/columnsSelector"; import { TimestampToMoment, unset } from "src/util"; -import moment from "moment"; +import moment from "moment-timezone"; import { getLabel, StatisticTableColumnKeys, diff --git a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsTable.tsx b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsTable.tsx index 03e8378e1c7f..56af237a8358 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsTable.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsTable.tsx @@ -20,7 +20,7 @@ import { BytesWithPrecision, Count } from "src/util/format"; import { Link } from "react-router-dom"; import React from "react"; -import moment from "moment"; +import moment from "moment-timezone"; import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; type ISession = cockroach.server.serverpb.Session; diff --git a/pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx b/pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx index 4a0c26ec9fc9..d87ccf7e823d 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx @@ -12,7 +12,7 @@ import React from "react"; import _ from "lodash"; import * as Long from "long"; import { History } from "history"; -import { Moment } from "moment"; +import { Moment } from "moment-timezone"; import { createSelector } from "reselect"; import times from "lodash/times"; diff --git a/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsUtils.ts b/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsUtils.ts index 284fee783eb8..4b21c4539952 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsUtils.ts +++ b/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsUtils.ts @@ -11,7 +11,7 @@ import { isUndefined } from "lodash"; import { DiagnosticStatuses } from "src/statementsDiagnostics"; import { StatementDiagnosticsReport } from "../../api"; -import moment from "moment"; +import moment from "moment-timezone"; export function getDiagnosticsStatus( diagnosticsRequest: StatementDiagnosticsReport, diff --git a/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsView.spec.tsx b/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsView.spec.tsx index 752741838f3b..abc206afd9c6 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsView.spec.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsView.spec.tsx @@ -18,7 +18,7 @@ import { DiagnosticsView } from "./diagnosticsView"; import { Table } from "src/table"; import { TestStoreProvider } from "src/test-utils"; import { StatementDiagnosticsReport } from "../../api"; -import moment from "moment"; +import moment from "moment-timezone"; const activateDiagnosticsRef = { current: { showModalFor: jest.fn() } }; diff --git a/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsView.tsx b/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsView.tsx index 5b2e6f0ea3a3..0c67216295b6 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsView.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementDetails/diagnostics/diagnosticsView.tsx @@ -10,7 +10,7 @@ import React from "react"; import { Link } from "react-router-dom"; -import moment from "moment"; +import moment from "moment-timezone"; import classnames from "classnames/bind"; import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; import { Button, Icon } from "@cockroachlabs/ui-components"; diff --git a/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.fixture.ts b/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.fixture.ts index 418a31684542..585592888572 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.fixture.ts +++ b/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.fixture.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import Long from "long"; import { createMemoryHistory } from "history"; import { noop } from "lodash"; diff --git a/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.selectors.ts index 7ee7f3d6c2b2..402c6bb417d4 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.selectors.ts @@ -22,7 +22,7 @@ import { import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; import { TimeScale, toRoundedDateRange } from "../timeScaleDropdown"; import { selectTimeScale } from "../store/utils/selectors"; -import moment from "moment"; +import moment from "moment-timezone"; type StatementDetailsResponseMessage = cockroach.server.serverpb.StatementDetailsResponse; diff --git a/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx b/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx index 303acbac3143..c29d8bdca885 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx @@ -72,7 +72,7 @@ import { generateCPUTimeseries, } from "./timeseriesUtils"; import { Delayed } from "../delayed"; -import moment from "moment"; +import moment from "moment-timezone"; import { InsertStmtDiagnosticRequest, InsightRecommendation, diff --git a/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.fixture.ts b/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.fixture.ts index c63da702fd4f..d9f501d4f6fe 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.fixture.ts +++ b/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.fixture.ts @@ -10,7 +10,7 @@ /* eslint-disable prettier/prettier */ import { StatementsPageProps } from "./statementsPage"; -import moment from "moment"; +import moment from "moment-timezone"; import { createMemoryHistory } from "history"; import Long from "long"; import { noop } from "lodash"; diff --git a/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx b/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx index 09a61a9182d0..75d18004ca1d 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx @@ -74,7 +74,7 @@ import { import { commonStyles } from "../common"; import { isSelectedColumn } from "src/columnsSelector/utils"; import { StatementViewType } from "./statementPageTypes"; -import moment from "moment"; +import moment from "moment-timezone"; import { InsertStmtDiagnosticRequest, StatementDiagnosticsReport, diff --git a/pkg/ui/workspaces/cluster-ui/src/statementsTable/statementsTableContent.tsx b/pkg/ui/workspaces/cluster-ui/src/statementsTable/statementsTableContent.tsx index 617889e816d4..dea19b2d43dc 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementsTable/statementsTableContent.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementsTable/statementsTableContent.tsx @@ -31,7 +31,7 @@ import styles from "./statementsTableContent.module.scss"; import { EllipsisVertical } from "@cockroachlabs/icons"; import { getBasePath } from "src/api/basePath"; import { StatementDiagnosticsReport } from "src/api/statementDiagnosticsApi"; -import moment from "moment"; +import moment from "moment-timezone"; export type NodeNames = { [nodeId: string]: string }; const cx = classNames.bind(styles); diff --git a/pkg/ui/workspaces/cluster-ui/src/statsTableUtil/statsTableUtil.tsx b/pkg/ui/workspaces/cluster-ui/src/statsTableUtil/statsTableUtil.tsx index 052b2b4bd737..0bbeae40c7c6 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statsTableUtil/statsTableUtil.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statsTableUtil/statsTableUtil.tsx @@ -10,7 +10,7 @@ import React from "react"; import { Anchor } from "src/anchor"; -import moment from "moment"; +import moment from "moment-timezone"; import { Tooltip } from "@cockroachlabs/ui-components"; import { diff --git a/pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.saga.ts b/pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.saga.ts index edcd0f3eb54b..7db9f7638598 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.saga.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.saga.ts @@ -12,7 +12,7 @@ import { all, call, put, takeLatest } from "redux-saga/effects"; import { actions } from "./databasesList.reducers"; import { getDatabasesList } from "src/api"; -import moment from "moment"; +import moment from "moment-timezone"; export function* refreshDatabasesListSaga() { yield put(actions.request()); diff --git a/pkg/ui/workspaces/cluster-ui/src/store/insightDetails/transactionInsightDetails/transactionInsightDetails.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/insightDetails/transactionInsightDetails/transactionInsightDetails.reducer.ts index 47b2b0dc37cc..d72924552cef 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/insightDetails/transactionInsightDetails/transactionInsightDetails.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/insightDetails/transactionInsightDetails/transactionInsightDetails.reducer.ts @@ -10,7 +10,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { DOMAIN_NAME } from "src/store/utils"; -import moment, { Moment } from "moment"; +import moment, { Moment } from "moment-timezone"; import { ErrorWithKey } from "src/api/statementsApi"; import { TxnInsightDetailsRequest, diff --git a/pkg/ui/workspaces/cluster-ui/src/store/insights/statementFingerprintInsights/statementFingerprintInsights.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/insights/statementFingerprintInsights/statementFingerprintInsights.reducer.ts index 9bf74468e78f..4a1f72de5db2 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/insights/statementFingerprintInsights/statementFingerprintInsights.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/insights/statementFingerprintInsights/statementFingerprintInsights.reducer.ts @@ -10,7 +10,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { DOMAIN_NAME } from "../../utils"; -import moment, { Moment } from "moment"; +import moment, { Moment } from "moment-timezone"; import { SqlApiResponse, ErrorWithKey, StmtInsightsReq } from "src/api"; import { StmtInsightEvent } from "../../../insights"; diff --git a/pkg/ui/workspaces/cluster-ui/src/store/insights/statementInsights/statementInsights.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/insights/statementInsights/statementInsights.reducer.ts index dfe722d50fc8..7bc22a501e0a 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/insights/statementInsights/statementInsights.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/insights/statementInsights/statementInsights.reducer.ts @@ -12,7 +12,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { DOMAIN_NAME } from "../../utils"; import { StmtInsightEvent } from "src/insights"; import { SqlApiResponse, StmtInsightsReq } from "src/api"; -import moment from "moment"; +import moment from "moment-timezone"; export type StmtInsightsState = { data: SqlApiResponse; diff --git a/pkg/ui/workspaces/cluster-ui/src/store/insights/transactionInsights/transactionInsights.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/insights/transactionInsights/transactionInsights.reducer.ts index dd2a8170602f..981bb8c36553 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/insights/transactionInsights/transactionInsights.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/insights/transactionInsights/transactionInsights.reducer.ts @@ -11,7 +11,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { DOMAIN_NAME } from "../../utils"; import { TxnInsightEvent } from "src/insights"; -import moment, { Moment } from "moment"; +import moment, { Moment } from "moment-timezone"; import { SqlApiResponse, TxnInsightsRequest } from "src/api"; export type TxnInsightsState = { diff --git a/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.reducer.ts index 1198f103eb39..9e62032bd4e6 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.reducer.ts @@ -11,7 +11,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { JobsRequest, JobsResponse } from "src/api/jobsApi"; import { DOMAIN_NAME } from "../utils"; -import moment from "moment"; +import moment from "moment-timezone"; export type JobsState = { data: JobsResponse; diff --git a/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.sagas.spec.ts b/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.sagas.spec.ts index ba3abac87b62..b7b5d0cb48ba 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.sagas.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.sagas.spec.ts @@ -24,7 +24,7 @@ import { allJobsFixture, earliestRetainedTime, } from "../../jobs/jobsPage/jobsPage.fixture"; -import moment from "moment"; +import moment from "moment-timezone"; describe("jobs sagas", () => { const lastUpdated = moment.utc(new Date("2023-02-21T12:00:00.000Z")); diff --git a/pkg/ui/workspaces/cluster-ui/src/store/schemaInsights/schemaInsights.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/schemaInsights/schemaInsights.reducer.ts index a415afb0f844..3aa0cb1ffe2a 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/schemaInsights/schemaInsights.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/schemaInsights/schemaInsights.reducer.ts @@ -10,7 +10,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { DOMAIN_NAME, noopReducer } from "../utils"; -import moment, { Moment } from "moment"; +import moment, { Moment } from "moment-timezone"; import { InsightRecommendation } from "../../insights"; import { SqlApiResponse } from "src/api"; diff --git a/pkg/ui/workspaces/cluster-ui/src/store/schemaInsights/schemaInsights.sagas.spec.ts b/pkg/ui/workspaces/cluster-ui/src/store/schemaInsights/schemaInsights.sagas.spec.ts index 57bad0d0c1da..610c4ba18f0c 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/schemaInsights/schemaInsights.sagas.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/schemaInsights/schemaInsights.sagas.spec.ts @@ -15,7 +15,7 @@ import { throwError, } from "redux-saga-test-plan/providers"; import * as matchers from "redux-saga-test-plan/matchers"; -import moment from "moment"; +import moment from "moment-timezone"; import { getSchemaInsights, SqlApiResponse } from "../../api"; import { refreshSchemaInsightsSaga, diff --git a/pkg/ui/workspaces/cluster-ui/src/store/sessions/sessions.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/sessions/sessions.reducer.ts index fe1f765fc011..615552b56329 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/sessions/sessions.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/sessions/sessions.reducer.ts @@ -11,7 +11,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; import { DOMAIN_NAME, noopReducer } from "../utils"; -import moment, { Moment } from "moment"; +import moment, { Moment } from "moment-timezone"; type SessionsResponse = cockroach.server.serverpb.ListSessionsResponse; diff --git a/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.reducer.ts index 61ba8d1ed005..c05a2fecd8e1 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.reducer.ts @@ -13,7 +13,7 @@ import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; import { DOMAIN_NAME } from "../utils"; import { StatementsRequest } from "src/api/statementsApi"; import { TimeScale } from "../../timeScaleDropdown"; -import moment from "moment"; +import moment from "moment-timezone"; export type StatementsResponse = cockroach.server.serverpb.StatementsResponse; diff --git a/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.sagas.spec.ts b/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.sagas.spec.ts index e07206d6c020..7df6bff40c03 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.sagas.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/sqlStats/sqlStats.sagas.spec.ts @@ -27,7 +27,7 @@ import { import { actions, reducer, SQLStatsState } from "./sqlStats.reducer"; import { actions as sqlDetailsStatsActions } from "../statementDetails/statementDetails.reducer"; import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; const lastUpdated = moment(); diff --git a/pkg/ui/workspaces/cluster-ui/src/store/statementDetails/statementDetails.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/statementDetails/statementDetails.reducer.ts index 77aec1076ef6..65d7ddf2fecb 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/statementDetails/statementDetails.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/statementDetails/statementDetails.reducer.ts @@ -17,7 +17,7 @@ import { StatementDetailsResponseWithKey, } from "src/api/statementsApi"; import { generateStmtDetailsToID } from "../../util"; -import moment from "moment"; +import moment from "moment-timezone"; export type SQLDetailsStatsState = { data: StatementDetailsResponse; diff --git a/pkg/ui/workspaces/cluster-ui/src/store/statementDetails/statementDetails.sagas.spec.ts b/pkg/ui/workspaces/cluster-ui/src/store/statementDetails/statementDetails.sagas.spec.ts index 4a17d3d85fd3..14f71b8fa56f 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/statementDetails/statementDetails.sagas.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/statementDetails/statementDetails.sagas.spec.ts @@ -29,7 +29,7 @@ import { SQLDetailsStatsReducerState, } from "./statementDetails.reducer"; -import moment from "moment"; +import moment from "moment-timezone"; const lastUpdated = moment(); diff --git a/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.sagas.spec.ts b/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.sagas.spec.ts index 2748d871ee60..0872a6a5ae40 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.sagas.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.sagas.spec.ts @@ -28,7 +28,7 @@ import { CancelStmtDiagnosticRequest, CancelStmtDiagnosticResponse, } from "src/api/statementDiagnosticsApi"; -import moment from "moment"; +import moment from "moment-timezone"; describe("statementsDiagnostics sagas", () => { describe("createDiagnosticsReportSaga", () => { diff --git a/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.selectors.spec.ts b/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.selectors.spec.ts index d7e03a69db68..dd5f2ae7f091 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.selectors.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.selectors.spec.ts @@ -11,7 +11,7 @@ import { assert } from "chai"; import { selectDiagnosticsReportsPerStatement } from "./statementDiagnostics.selectors"; import { StatementDiagnosticsReport } from "../../api"; -import moment from "moment"; +import moment from "moment-timezone"; const reports: StatementDiagnosticsReport[] = [ { diff --git a/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.selectors.ts index f44a2f5ecc96..92f662967856 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/statementDiagnostics/statementDiagnostics.selectors.ts @@ -12,7 +12,7 @@ import { createSelector } from "reselect"; import { chain, orderBy } from "lodash"; import { AppState } from "../reducers"; import { StatementDiagnosticsReport } from "../../api"; -import moment from "moment"; +import moment from "moment-timezone"; export const statementDiagnostics = createSelector( (state: AppState) => state.adminUI, diff --git a/pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.reducer.ts b/pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.reducer.ts index 71731100874c..d3b6ed1c5507 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.reducer.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.reducer.ts @@ -12,7 +12,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { DOMAIN_NAME } from "../utils"; import { StatementsRequest } from "src/api/statementsApi"; import { TimeScale } from "../../timeScaleDropdown"; -import moment from "moment"; +import moment from "moment-timezone"; import { StatementsResponse } from "../sqlStats"; export type TxnStatsState = { diff --git a/pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.sagas.spec.ts b/pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.sagas.spec.ts index 7f88306fa492..09dcad9d55ad 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.sagas.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/transactionStats/txnStats.sagas.spec.ts @@ -21,7 +21,7 @@ import { getFlushedTxnStatsApi } from "src/api/statementsApi"; import { refreshTxnStatsSaga, requestTxnStatsSaga } from "./txnStats.sagas"; import { actions, reducer, TxnStatsState } from "./txnStats.reducer"; import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; const lastUpdated = moment(); diff --git a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/rangeSelect.tsx b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/rangeSelect.tsx index 574c46bee145..87adb4f4ca40 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/rangeSelect.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/rangeSelect.tsx @@ -12,7 +12,7 @@ import React, { useState, useRef } from "react"; import { Button, Dropdown } from "antd"; import "antd/lib/button/style"; import "antd/lib/dropdown/style"; -import moment, { Moment } from "moment"; +import moment, { Moment } from "moment-timezone"; import { DateRangeMenu } from "src/dateRangeMenu"; import { CaretDown } from "src/icon/caretDown"; import classNames from "classnames/bind"; diff --git a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.spec.tsx b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.spec.tsx index 5266d4cb2ec4..cbcbfd93b983 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.spec.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.spec.tsx @@ -19,7 +19,7 @@ import { TimeScaleDropdown, } from "./timeScaleDropdown"; import * as timescale from "./timeScaleTypes"; -import moment from "moment"; +import moment from "moment-timezone"; import { MemoryRouter } from "react-router"; import TimeFrameControls from "./timeFrameControls"; import RangeSelect from "./rangeSelect"; diff --git a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.stories.tsx b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.stories.tsx index 2deb7f19844d..52935833bc4d 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.stories.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.stories.tsx @@ -12,7 +12,7 @@ import React, { useState } from "react"; import { storiesOf } from "@storybook/react"; import { TimeScaleDropdown } from "./timeScaleDropdown"; import { defaultTimeScaleOptions, defaultTimeScaleSelected } from "./utils"; -import moment from "moment"; +import moment from "moment-timezone"; export function TimeScaleDropdownWrapper({ initialTimeScale = defaultTimeScaleSelected, diff --git a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.tsx b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.tsx index 46be340fd099..676b26662c58 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleDropdown.tsx @@ -9,7 +9,7 @@ // licenses/APL.txt. import React, { useMemo } from "react"; -import moment from "moment"; +import moment from "moment-timezone"; import classNames from "classnames/bind"; import { ArrowDirection, diff --git a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleTypes.ts b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleTypes.ts index 1160a65d55cf..d46c3cf05388 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleTypes.ts +++ b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleTypes.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { defaultTimeScaleOptions } from "./utils"; /** diff --git a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/utils.spec.tsx b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/utils.spec.tsx index f8520f8e7099..9ef8e5b9b7cb 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/utils.spec.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/utils.spec.tsx @@ -9,7 +9,7 @@ // licenses/APL.txt. import { TimeScale } from "./timeScaleTypes"; -import moment from "moment"; +import moment from "moment-timezone"; import { defaultTimeScaleOptions, findClosestTimeScale, diff --git a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/utils.ts b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/utils.ts index 83951f038ba1..d193bd335940 100644 --- a/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/utils.ts +++ b/pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/utils.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { TimeScale, TimeScaleOption, TimeScaleOptions } from "./timeScaleTypes"; import { dateFormat, timeFormat } from "./timeScaleDropdown"; diff --git a/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanComponent.tsx b/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanComponent.tsx index b4c4fa71c833..deeda0bf4306 100644 --- a/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanComponent.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanComponent.tsx @@ -9,7 +9,7 @@ // licenses/APL.txt. import React, { useCallback, useMemo, useState } from "react"; -import moment from "moment"; +import moment from "moment-timezone"; import { Helmet } from "react-helmet"; import { commonStyles } from "src/common"; import classNames from "classnames/bind"; diff --git a/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanMetadataTable.tsx b/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanMetadataTable.tsx index 118b23b2040b..5e809443379c 100644 --- a/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanMetadataTable.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanMetadataTable.tsx @@ -7,7 +7,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import React, { useState } from "react"; import { Nodes } from "@cockroachlabs/icons"; import { NamedOperationMetadata } from "src/api/tracezApi"; diff --git a/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanTable.tsx b/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanTable.tsx index 0c809da2572d..bb3764a56d19 100644 --- a/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanTable.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/tracez/snapshot/spanTable.tsx @@ -7,7 +7,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import React, { useState } from "react"; import { Nodes, Caution, Plus, Minus } from "@cockroachlabs/icons"; import { Span, Snapshot } from "src/api/tracezApi"; diff --git a/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.fixture.ts b/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.fixture.ts index 2d089bc04080..46aee6711958 100644 --- a/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.fixture.ts +++ b/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.fixture.ts @@ -9,7 +9,7 @@ // licenses/APL.txt. import { RequestError } from "../util"; -import moment from "moment"; +import moment from "moment-timezone"; import { createMemoryHistory } from "history"; import Long from "long"; import * as protos from "@cockroachlabs/crdb-protobuf-client"; diff --git a/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.stories.tsx b/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.stories.tsx index 4d65ceb5384d..89372da9bfc1 100644 --- a/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.stories.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.stories.tsx @@ -23,7 +23,7 @@ import { } from "./transactionDetails.fixture"; import { TransactionDetails } from "."; -import moment from "moment"; +import moment from "moment-timezone"; storiesOf("Transactions Details", module) .addDecorator(storyFn => {storyFn()}) diff --git a/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.tsx b/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.tsx index 63eb25d3b9be..9b0be2396d8c 100644 --- a/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.tsx @@ -80,7 +80,7 @@ import { timeScaleToString, toRoundedDateRange, } from "../timeScaleDropdown"; -import moment from "moment"; +import moment from "moment-timezone"; import timeScaleStyles from "../timeScaleDropdown/timeScale.module.scss"; import insightTableStyles from "../insightsTable/insightsTable.module.scss"; diff --git a/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactions.fixture.ts b/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactions.fixture.ts index 96f096e82e43..492e81ab6a41 100644 --- a/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactions.fixture.ts +++ b/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactions.fixture.ts @@ -11,7 +11,7 @@ import { createMemoryHistory } from "history"; import { cockroach } from "@cockroachlabs/crdb-protobuf-client"; import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; import * as protos from "@cockroachlabs/crdb-protobuf-client"; import { SortSetting } from "../sortedtable"; import { Filters } from "../queryFilter"; diff --git a/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.tsx b/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.tsx index ef2b43a165d3..225eca0e2b9a 100644 --- a/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.tsx @@ -75,7 +75,7 @@ import { import { InlineAlert } from "@cockroachlabs/ui-components"; import { TransactionViewType } from "./transactionsPageTypes"; import { isSelectedColumn } from "../columnsSelector/utils"; -import moment from "moment"; +import moment from "moment-timezone"; import { STATS_LONG_LOADING_DURATION, txnRequestSortOptions, diff --git a/pkg/ui/workspaces/cluster-ui/src/util/constants.ts b/pkg/ui/workspaces/cluster-ui/src/util/constants.ts index a6ad8e301aae..dd4fe9d01122 100644 --- a/pkg/ui/workspaces/cluster-ui/src/util/constants.ts +++ b/pkg/ui/workspaces/cluster-ui/src/util/constants.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import { duration } from "moment"; +import { duration } from "moment-timezone"; export const aggregatedTsAttr = "aggregated_ts"; export const appAttr = "app"; diff --git a/pkg/ui/workspaces/cluster-ui/src/util/convert.spec.ts b/pkg/ui/workspaces/cluster-ui/src/util/convert.spec.ts index 1e6f684cf893..be540d197d46 100644 --- a/pkg/ui/workspaces/cluster-ui/src/util/convert.spec.ts +++ b/pkg/ui/workspaces/cluster-ui/src/util/convert.spec.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import * as protos from "@cockroachlabs/crdb-protobuf-client"; import { NanoToMilli, diff --git a/pkg/ui/workspaces/cluster-ui/src/util/convert.ts b/pkg/ui/workspaces/cluster-ui/src/util/convert.ts index 782a17368969..d43f93dcbbf0 100644 --- a/pkg/ui/workspaces/cluster-ui/src/util/convert.ts +++ b/pkg/ui/workspaces/cluster-ui/src/util/convert.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import * as protos from "@cockroachlabs/crdb-protobuf-client"; import { fromNumber } from "long"; diff --git a/pkg/ui/workspaces/cluster-ui/src/util/format.ts b/pkg/ui/workspaces/cluster-ui/src/util/format.ts index f06c0458367b..526890b40b91 100644 --- a/pkg/ui/workspaces/cluster-ui/src/util/format.ts +++ b/pkg/ui/workspaces/cluster-ui/src/util/format.ts @@ -8,6 +8,8 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. +import moment from "moment-timezone"; +import { CoordinatedUniversalTime } from "src/contexts"; import { longToInt } from "./fixLong"; export const kibi = 1024; @@ -191,9 +193,18 @@ export const DATE_WITH_SECONDS_AND_MILLISECONDS_FORMAT = */ export const DATE_FORMAT_24_UTC = "MMM DD, YYYY [at] H:mm UTC"; export const DATE_WITH_SECONDS_FORMAT_24_UTC = "MMM DD, YYYY [at] H:mm:ss UTC"; +export const DATE_WITH_SECONDS_FORMAT_24_TZ = "MMM DD, YYYY [at] H:mm:ss z"; export const DATE_WITH_SECONDS_AND_MILLISECONDS_FORMAT_24_UTC = "MMM DD, YYYY [at] H:mm:ss:ms UTC"; +export function FormatWithTimezone( + m: moment.Moment, + formatString = DATE_WITH_SECONDS_FORMAT_24_TZ, + timezone = CoordinatedUniversalTime, +): string { + return moment.tz(m, timezone).format(formatString); +} + export function RenderCount(yesCount: Long, totalCount: Long): string { if (longToInt(yesCount) == 0) { return "No"; diff --git a/pkg/ui/workspaces/cluster-ui/src/util/formatDate.ts b/pkg/ui/workspaces/cluster-ui/src/util/formatDate.ts index e88070e8b9ac..60ba34c7cfe3 100644 --- a/pkg/ui/workspaces/cluster-ui/src/util/formatDate.ts +++ b/pkg/ui/workspaces/cluster-ui/src/util/formatDate.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import { Moment } from "moment"; +import { Moment } from "moment-timezone"; export const dateFormat = "Y-MM-DD HH:mm:ss"; diff --git a/pkg/ui/workspaces/cluster-ui/src/util/hooks.spec.tsx b/pkg/ui/workspaces/cluster-ui/src/util/hooks.spec.tsx index 0b34f1099a5a..d43fea551be4 100644 --- a/pkg/ui/workspaces/cluster-ui/src/util/hooks.spec.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/util/hooks.spec.tsx @@ -17,7 +17,7 @@ import { fireEvent, waitFor, } from "@testing-library/react"; -import moment from "moment"; +import moment from "moment-timezone"; describe("useScheduleFunction", () => { let mockFn: jest.Mock; diff --git a/pkg/ui/workspaces/cluster-ui/src/util/sqlActivityConstants.ts b/pkg/ui/workspaces/cluster-ui/src/util/sqlActivityConstants.ts index ee9a52a30f9d..780081aca520 100644 --- a/pkg/ui/workspaces/cluster-ui/src/util/sqlActivityConstants.ts +++ b/pkg/ui/workspaces/cluster-ui/src/util/sqlActivityConstants.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import { duration } from "moment"; +import { duration } from "moment-timezone"; import { SqlStatsSortOptions, SqlStatsSortType } from "src/api/statementsApi"; import { getLabel, diff --git a/pkg/ui/workspaces/cluster-ui/webpack.config.js b/pkg/ui/workspaces/cluster-ui/webpack.config.js index 342ad269e1cd..dc1f0634cf95 100644 --- a/pkg/ui/workspaces/cluster-ui/webpack.config.js +++ b/pkg/ui/workspaces/cluster-ui/webpack.config.js @@ -12,8 +12,11 @@ const path = require("path"); const webpack = require("webpack"); const WebpackBar = require("webpackbar"); const MomentLocalesPlugin = require("moment-locales-webpack-plugin"); +const MomentTimezoneDataPlugin = require("moment-timezone-data-webpack-plugin") const { ESBuildMinifyPlugin } = require("esbuild-loader"); +const currentYear = new Date().getFullYear(); + // tslint:disable:object-literal-sort-keys module.exports = (env, argv) => { env = env || {}; @@ -168,6 +171,16 @@ module.exports = (env, argv) => { /node_modules\/antd\/lib\/style\/index\.less/, path.resolve(__dirname, "src/core/antd-patch.less"), ), + + // Use MomentTimezoneDataPlugin to remove timezone data that we don't need. + new MomentTimezoneDataPlugin({ + matchZones: ['Etc/UTC', 'America/New_York'], + startYear: 2021, + endYear: currentYear + 10, + // We have to tell the plugin where to store the pruned file + // otherwise webpack can't find it. + cacheDir: path.resolve(__dirname, "timezones"), + }) ], // When importing a module whose path matches one of the following, just diff --git a/pkg/ui/workspaces/cluster-ui/yarn.lock b/pkg/ui/workspaces/cluster-ui/yarn.lock index 162341d1e55b..9b86130a8dbd 100644 --- a/pkg/ui/workspaces/cluster-ui/yarn.lock +++ b/pkg/ui/workspaces/cluster-ui/yarn.lock @@ -9827,6 +9827,15 @@ find-cache-dir@^2.1.0: make-dir "^2.0.0" pkg-dir "^3.0.0" +find-cache-dir@^3.0.0: + version "3.3.2" + resolved "https://storage.googleapis.com/cockroach-npm-deps/find-cache-dir/-/find-cache-dir-3.3.2.tgz#b30c5b6eff0730731aea9bbd9dbecbd80256d64b" + integrity sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig== + dependencies: + commondir "^1.0.1" + make-dir "^3.0.2" + pkg-dir "^4.1.0" + find-cache-dir@^3.3.1: version "3.3.1" resolved "https://storage.googleapis.com/cockroach-npm-deps/find-cache-dir/-/find-cache-dir-3.3.1.tgz#89b33fad4a4670daa94f855f7fbe31d6d84fe880" @@ -13486,6 +13495,21 @@ moment-locales-webpack-plugin@^1.2.0: dependencies: lodash.difference "^4.5.0" +moment-timezone-data-webpack-plugin@^1.5.1: + version "1.5.1" + resolved "https://storage.googleapis.com/cockroach-npm-deps/moment-timezone-data-webpack-plugin/-/moment-timezone-data-webpack-plugin-1.5.1.tgz#9d35dfd3768db55058e1e809d77a2b64bd6d03a4" + integrity sha512-1le6a35GgYdWMVYFzrfpE/F6Pk4bj0M3QKD6Iv6ba9LqWGoVqHQRHyCTLvLis5E1J98Sz40ET6yhZzMVakwpjg== + dependencies: + find-cache-dir "^3.0.0" + make-dir "^3.0.0" + +moment-timezone@^0.5.42: + version "0.5.42" + resolved "https://storage.googleapis.com/cockroach-npm-deps/moment-timezone/-/moment-timezone-0.5.42.tgz#c59f2aa00442d0dcd1d258d2182873d637b4e17b" + integrity sha512-tjI9goqwzkflKSTxJo+jC/W8riTFwEjjunssmFvAWlvNVApjbkJM7UHggyKO0q1Fd/kZVKY77H7C9A0XKhhAFw== + dependencies: + moment "^2.29.4" + moment@2.x: version "2.29.1" resolved "https://storage.googleapis.com/cockroach-npm-deps/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3" @@ -13496,6 +13520,11 @@ moment@^2.24.0: resolved "https://storage.googleapis.com/cockroach-npm-deps/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3" integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ== +moment@^2.29.4: + version "2.29.4" + resolved "https://storage.googleapis.com/cockroach-npm-deps/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" + integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w== + moo-color@^1.0.2: version "1.0.3" resolved "https://storage.googleapis.com/cockroach-npm-deps/moo-color/-/moo-color-1.0.3.tgz#d56435f8359c8284d83ac58016df7427febece74" diff --git a/pkg/ui/workspaces/db-console/.gitignore b/pkg/ui/workspaces/db-console/.gitignore index 8b6198bb7ce7..5c46559c402c 100644 --- a/pkg/ui/workspaces/db-console/.gitignore +++ b/pkg/ui/workspaces/db-console/.gitignore @@ -19,3 +19,4 @@ dist*/** cypress/screenshots/* cypress/videos/* cypress/snapshots/**/__diff_output__ +timezones diff --git a/pkg/ui/workspaces/db-console/BUILD.bazel b/pkg/ui/workspaces/db-console/BUILD.bazel index f4898591dbdc..33d05101aa9f 100644 --- a/pkg/ui/workspaces/db-console/BUILD.bazel +++ b/pkg/ui/workspaces/db-console/BUILD.bazel @@ -104,6 +104,7 @@ DEV_DEPENDENCIES = [ "@npm_db_console//sinon", "@npm_db_console//source-map-loader", "@npm_db_console//string-replace-webpack-plugin", + "@npm_db_console//moment-timezone-data-webpack-plugin", "@npm_db_console//style-loader", "@npm_db_console//stylint", "@npm_db_console//stylus", @@ -141,6 +142,7 @@ DEPENDENCIES = [ "@npm_db_console//list.js", "@npm_db_console//mini-create-react-context", "@npm_db_console//moment", + "@npm_db_console//moment-timezone", "@npm_db_console//nvd3", "@npm_db_console//popper.js", "@npm_db_console//raw-loader", @@ -307,6 +309,7 @@ tsc_test( "@npm_db_console//connected-react-router", "@npm_db_console//highlight.js", "@npm_db_console//moment", + "@npm_db_console//moment-timezone", "@npm_db_console//protobufjs", "@npm_db_console//redux", "@npm_db_console//redux-saga", diff --git a/pkg/ui/workspaces/db-console/ccl/src/views/clusterviz/containers/map/nodeView.tsx b/pkg/ui/workspaces/db-console/ccl/src/views/clusterviz/containers/map/nodeView.tsx index 832f244d100e..b7cad0659c22 100644 --- a/pkg/ui/workspaces/db-console/ccl/src/views/clusterviz/containers/map/nodeView.tsx +++ b/pkg/ui/workspaces/db-console/ccl/src/views/clusterviz/containers/map/nodeView.tsx @@ -7,7 +7,7 @@ // https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt import React from "react"; -import moment from "moment"; +import moment from "moment-timezone"; import { Link } from "react-router-dom"; import { INodeStatus } from "src/util/proto"; diff --git a/pkg/ui/workspaces/db-console/ccl/src/views/reports/containers/stores/encryption.tsx b/pkg/ui/workspaces/db-console/ccl/src/views/reports/containers/stores/encryption.tsx index a8fd1a87f951..16f75eaf9abf 100644 --- a/pkg/ui/workspaces/db-console/ccl/src/views/reports/containers/stores/encryption.tsx +++ b/pkg/ui/workspaces/db-console/ccl/src/views/reports/containers/stores/encryption.tsx @@ -9,7 +9,7 @@ import React from "react"; import _ from "lodash"; import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; import * as protos from "src/js/protos"; import * as protosccl from "@cockroachlabs/crdb-protobuf-client-ccl"; diff --git a/pkg/ui/workspaces/db-console/package.json b/pkg/ui/workspaces/db-console/package.json index f2111db5cb4e..790c144385e0 100644 --- a/pkg/ui/workspaces/db-console/package.json +++ b/pkg/ui/workspaces/db-console/package.json @@ -35,6 +35,7 @@ "long": "^4.0.0", "mini-create-react-context": "^0.3.2", "moment": "^2.19.3", + "moment-timezone": "^0.5.42", "nvd3": "^1.8.5", "popper.js": "^1.14.4", "raw-loader": "^0.5.1", @@ -150,6 +151,7 @@ "less-loader": "6.2.0", "minimist": "^1.2.0", "mocha": "^6.2.1", + "moment-timezone-data-webpack-plugin": "^1.5.1", "nib": "^1.1.2", "prettier": "^2.6.2", "pretty-format": "^27.3.1", diff --git a/pkg/ui/workspaces/db-console/src/app.tsx b/pkg/ui/workspaces/db-console/src/app.tsx index b126b6b64955..69f9703ce6fc 100644 --- a/pkg/ui/workspaces/db-console/src/app.tsx +++ b/pkg/ui/workspaces/db-console/src/app.tsx @@ -86,6 +86,7 @@ import StatementInsightDetailsPage from "./views/insights/statementInsightDetail import { CockroachCloudContext } from "@cockroachlabs/cluster-ui"; import { SnapshotRouter } from "src/views/tracez_v2/snapshotRoutes"; import KeyVisualizerPage from "src/views/keyVisualizer"; +import { TimezoneProvider } from "src/contexts/timezoneProvider"; // NOTE: If you are adding a new path to the router, and that path contains any // components that are personally identifying information, you MUST update the @@ -109,349 +110,363 @@ export const App: React.FC = (props: AppProps) => { - - {/* login */} - {createLoginRoute()} - {createLogoutRoute(store)} - - - - - {/* overview page */} - {visualizationRoutes()} + + + {/* login */} + {createLoginRoute()} + {createLogoutRoute(store)} + + + + + {/* overview page */} + {visualizationRoutes()} - {/* time series metrics */} - - - - - + {/* time series metrics */} + + + + + - {/* node details */} - - - + {/* node details */} + + + - {/* events & jobs */} - - - + {/* events & jobs */} + + + - - + + - {/* databases */} - - - - + {/* databases */} + + + + - - - - - - + + + + + + - {/* data distribution */} - + {/* data distribution */} + - {/* SQL activity */} - + {/* SQL activity */} + - {/* Active executions */} - + {/* Active executions */} + - + - {/* statement statistics */} - - - - - - - - - + {/* statement statistics */} + + + + + + + + + - {/* sessions */} - - + {/* sessions */} + + - {/* transactions */} - - - + {/* transactions */} + + + - {/* Insights */} - - - + {/* Insights */} + + + - {/* debug pages */} - - - - - - - - - - - - - - - - - - + {/* debug pages */} + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - {/* hot ranges */} - - {/* old route redirects */} - - - - - - - + + + + + + + + + + + + + {/* hot ranges */} + + {/* old route redirects */} + + + + + + + - + - {/* 404 */} - - - - - + {/* 404 */} + + + + + + diff --git a/pkg/ui/workspaces/db-console/src/components/rangeCalendar/dateRangeLabel.tsx b/pkg/ui/workspaces/db-console/src/components/rangeCalendar/dateRangeLabel.tsx index 6d9ad90a3dbf..bf6cbdb8e5e5 100644 --- a/pkg/ui/workspaces/db-console/src/components/rangeCalendar/dateRangeLabel.tsx +++ b/pkg/ui/workspaces/db-console/src/components/rangeCalendar/dateRangeLabel.tsx @@ -9,7 +9,7 @@ // licenses/APL.txt. import React from "react"; -import { Moment } from "moment"; +import { Moment } from "moment-timezone"; import { Text, TextTypes } from "src/components"; export interface DateRangeLabelProps { diff --git a/pkg/ui/workspaces/db-console/src/contexts/timezoneProvider.tsx b/pkg/ui/workspaces/db-console/src/contexts/timezoneProvider.tsx new file mode 100644 index 000000000000..ac5951c5671c --- /dev/null +++ b/pkg/ui/workspaces/db-console/src/contexts/timezoneProvider.tsx @@ -0,0 +1,35 @@ +// Copyright 2023 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +import React, { useEffect } from "react"; +import { useDispatch, useSelector } from "react-redux"; +import { + selectClusterSettings, + selectTimezoneSetting, +} from "src/redux/clusterSettings"; +import { refreshSettings } from "src/redux/apiReducers"; +import { TimezoneContext } from "@cockroachlabs/cluster-ui"; + +export const TimezoneProvider = (props: any) => { + // Refresh cluster settings if needed. + const dispatch = useDispatch(); + const settings = useSelector(selectClusterSettings); + useEffect(() => { + dispatch(refreshSettings()); + }, [settings, dispatch]); + + // Grab the timezone value from the store, and pass it to our context. + const timezone = useSelector(selectTimezoneSetting); + return ( + + {props.children} + + ); +}; diff --git a/pkg/ui/workspaces/db-console/src/redux/alerts.spec.ts b/pkg/ui/workspaces/db-console/src/redux/alerts.spec.ts index 2a4ac0b7f386..ed8ec55b89b3 100644 --- a/pkg/ui/workspaces/db-console/src/redux/alerts.spec.ts +++ b/pkg/ui/workspaces/db-console/src/redux/alerts.spec.ts @@ -9,7 +9,7 @@ // licenses/APL.txt. import { Store } from "redux"; -import moment from "moment"; +import moment from "moment-timezone"; import { createHashHistory } from "history"; import * as protos from "src/js/protos"; diff --git a/pkg/ui/workspaces/db-console/src/redux/alerts.ts b/pkg/ui/workspaces/db-console/src/redux/alerts.ts index 3f95346c2783..9a8102d64f1f 100644 --- a/pkg/ui/workspaces/db-console/src/redux/alerts.ts +++ b/pkg/ui/workspaces/db-console/src/redux/alerts.ts @@ -14,7 +14,7 @@ */ import _ from "lodash"; -import moment from "moment"; +import moment from "moment-timezone"; import { createSelector } from "reselect"; import { Store, Dispatch, Action, AnyAction } from "redux"; import { ThunkAction } from "redux-thunk"; diff --git a/pkg/ui/workspaces/db-console/src/redux/apiReducers.ts b/pkg/ui/workspaces/db-console/src/redux/apiReducers.ts index 1e1a39c6bd5f..176e4c0f744f 100644 --- a/pkg/ui/workspaces/db-console/src/redux/apiReducers.ts +++ b/pkg/ui/workspaces/db-console/src/redux/apiReducers.ts @@ -11,7 +11,7 @@ import _ from "lodash"; import { Action, combineReducers } from "redux"; import { ThunkAction, ThunkDispatch } from "redux-thunk"; -import moment from "moment"; +import moment from "moment-timezone"; import { api as clusterUiApi, util, diff --git a/pkg/ui/workspaces/db-console/src/redux/cachedDataReducer.spec.ts b/pkg/ui/workspaces/db-console/src/redux/cachedDataReducer.spec.ts index b23ddaa84361..7d5b33af3bfb 100644 --- a/pkg/ui/workspaces/db-console/src/redux/cachedDataReducer.spec.ts +++ b/pkg/ui/workspaces/db-console/src/redux/cachedDataReducer.spec.ts @@ -10,7 +10,7 @@ import _ from "lodash"; import { Action } from "redux"; -import moment from "moment"; +import moment from "moment-timezone"; import { CachedDataReducer, CachedDataReducerState, diff --git a/pkg/ui/workspaces/db-console/src/redux/cachedDataReducer.ts b/pkg/ui/workspaces/db-console/src/redux/cachedDataReducer.ts index 98d5557f6a22..c3ec3d75acbc 100644 --- a/pkg/ui/workspaces/db-console/src/redux/cachedDataReducer.ts +++ b/pkg/ui/workspaces/db-console/src/redux/cachedDataReducer.ts @@ -17,7 +17,7 @@ import _ from "lodash"; import { Action } from "redux"; import assert from "assert"; -import moment from "moment"; +import moment from "moment-timezone"; import { push } from "connected-react-router"; import { ThunkAction, ThunkDispatch } from "redux-thunk"; diff --git a/pkg/ui/workspaces/db-console/src/redux/clusterSettings/clusterSettings.selectors.ts b/pkg/ui/workspaces/db-console/src/redux/clusterSettings/clusterSettings.selectors.ts index efb446a5bed4..4ca8ae9ff95a 100644 --- a/pkg/ui/workspaces/db-console/src/redux/clusterSettings/clusterSettings.selectors.ts +++ b/pkg/ui/workspaces/db-console/src/redux/clusterSettings/clusterSettings.selectors.ts @@ -11,8 +11,8 @@ import { createSelector } from "reselect"; import { AdminUIState } from "src/redux/state"; import { cockroach } from "src/js/protos"; -import moment from "moment"; -import { util } from "@cockroachlabs/cluster-ui"; +import moment from "moment-timezone"; +import { CoordinatedUniversalTime, util } from "@cockroachlabs/cluster-ui"; export const selectClusterSettings = createSelector( (state: AdminUIState) => state.cachedData.settings?.data, @@ -20,6 +20,16 @@ export const selectClusterSettings = createSelector( settings?.key_values, ); +export const selectTimezoneSetting = createSelector( + selectClusterSettings, + settings => { + if (!settings) { + return CoordinatedUniversalTime; + } + return settings["ui.display_timezone"]?.value || CoordinatedUniversalTime; + }, +); + export const selectResolution10sStorageTTL = createSelector( selectClusterSettings, (settings): moment.Duration | undefined => { diff --git a/pkg/ui/workspaces/db-console/src/redux/hover.ts b/pkg/ui/workspaces/db-console/src/redux/hover.ts index 9ed725fc371b..8850b94bf811 100644 --- a/pkg/ui/workspaces/db-console/src/redux/hover.ts +++ b/pkg/ui/workspaces/db-console/src/redux/hover.ts @@ -12,7 +12,7 @@ * Monitors the currently hovered chart and point in time. */ -import moment from "moment"; +import moment from "moment-timezone"; import { Action } from "redux"; import { PayloadAction } from "src/interfaces/action"; diff --git a/pkg/ui/workspaces/db-console/src/redux/queryManager/reducer.spec.ts b/pkg/ui/workspaces/db-console/src/redux/queryManager/reducer.spec.ts index 9956baf49c09..52fe6e0edb55 100644 --- a/pkg/ui/workspaces/db-console/src/redux/queryManager/reducer.spec.ts +++ b/pkg/ui/workspaces/db-console/src/redux/queryManager/reducer.spec.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { managedQueryReducer, diff --git a/pkg/ui/workspaces/db-console/src/redux/queryManager/reducer.ts b/pkg/ui/workspaces/db-console/src/redux/queryManager/reducer.ts index 700b910c0327..c85aaaae0618 100644 --- a/pkg/ui/workspaces/db-console/src/redux/queryManager/reducer.ts +++ b/pkg/ui/workspaces/db-console/src/redux/queryManager/reducer.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { Action } from "redux"; import nextState from "src/util/nextState"; diff --git a/pkg/ui/workspaces/db-console/src/redux/queryManager/saga.spec.ts b/pkg/ui/workspaces/db-console/src/redux/queryManager/saga.spec.ts index 83c9f067b881..fdbb0ff68cc1 100644 --- a/pkg/ui/workspaces/db-console/src/redux/queryManager/saga.spec.ts +++ b/pkg/ui/workspaces/db-console/src/redux/queryManager/saga.spec.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { channel } from "redux-saga"; import { delay, call } from "redux-saga/effects"; diff --git a/pkg/ui/workspaces/db-console/src/redux/queryManager/saga.ts b/pkg/ui/workspaces/db-console/src/redux/queryManager/saga.ts index 20e3c557e9d0..b302f9c7df7b 100644 --- a/pkg/ui/workspaces/db-console/src/redux/queryManager/saga.ts +++ b/pkg/ui/workspaces/db-console/src/redux/queryManager/saga.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import { Action } from "redux"; import { channel, Task, Channel } from "redux-saga"; import { diff --git a/pkg/ui/workspaces/db-console/src/redux/statements/statementsSelectors.ts b/pkg/ui/workspaces/db-console/src/redux/statements/statementsSelectors.ts index 88a5802cf0ba..7f4d5c97d5ee 100644 --- a/pkg/ui/workspaces/db-console/src/redux/statements/statementsSelectors.ts +++ b/pkg/ui/workspaces/db-console/src/redux/statements/statementsSelectors.ts @@ -12,7 +12,7 @@ import { chain, orderBy } from "lodash"; import { createSelector } from "reselect"; import { AdminUIState } from "src/redux/state"; import { api as clusterUiApi } from "@cockroachlabs/cluster-ui"; -import moment from "moment"; +import moment from "moment-timezone"; export const selectStatementByFingerprint = createSelector( (state: AdminUIState) => state.cachedData.statements.data?.statements, diff --git a/pkg/ui/workspaces/db-console/src/redux/timeScale.spec.ts b/pkg/ui/workspaces/db-console/src/redux/timeScale.spec.ts index 289a3bb5a22d..e3eaa4409bf0 100644 --- a/pkg/ui/workspaces/db-console/src/redux/timeScale.spec.ts +++ b/pkg/ui/workspaces/db-console/src/redux/timeScale.spec.ts @@ -10,7 +10,7 @@ import { defaultTimeScaleOptions, TimeScale } from "@cockroachlabs/cluster-ui"; import * as timeScale from "./timeScale"; -import moment from "moment"; +import moment from "moment-timezone"; describe("time scale reducer", function () { describe("actions", function () { diff --git a/pkg/ui/workspaces/db-console/src/redux/timeScale.ts b/pkg/ui/workspaces/db-console/src/redux/timeScale.ts index 9cef25cf17f7..5f5e024ebed9 100644 --- a/pkg/ui/workspaces/db-console/src/redux/timeScale.ts +++ b/pkg/ui/workspaces/db-console/src/redux/timeScale.ts @@ -18,7 +18,7 @@ import { put, takeEvery, all } from "redux-saga/effects"; import { PayloadAction } from "src/interfaces/action"; import _ from "lodash"; import { defaultTimeScaleOptions, TimeScale } from "@cockroachlabs/cluster-ui"; -import moment from "moment"; +import moment from "moment-timezone"; import { createSelector } from "reselect"; import { AdminUIState } from "src/redux/state"; import { diff --git a/pkg/ui/workspaces/db-console/src/util/api.spec.ts b/pkg/ui/workspaces/db-console/src/util/api.spec.ts index 1ee05efb8dab..e53fb4a55498 100644 --- a/pkg/ui/workspaces/db-console/src/util/api.spec.ts +++ b/pkg/ui/workspaces/db-console/src/util/api.spec.ts @@ -9,7 +9,7 @@ // licenses/APL.txt. import _ from "lodash"; -import moment from "moment"; +import moment from "moment-timezone"; import Long from "long"; import fetchMock from "./fetch-mock"; diff --git a/pkg/ui/workspaces/db-console/src/util/api.ts b/pkg/ui/workspaces/db-console/src/util/api.ts index b51f7c43fdbc..a64fbf0db5db 100644 --- a/pkg/ui/workspaces/db-console/src/util/api.ts +++ b/pkg/ui/workspaces/db-console/src/util/api.ts @@ -13,7 +13,7 @@ */ import _ from "lodash"; -import moment from "moment"; +import moment from "moment-timezone"; import * as protos from "src/js/protos"; import { FixLong } from "src/util/fixLong"; diff --git a/pkg/ui/workspaces/db-console/src/util/cockroachlabsAPI.ts b/pkg/ui/workspaces/db-console/src/util/cockroachlabsAPI.ts index 2967359b75e4..c161a81ad1d5 100644 --- a/pkg/ui/workspaces/db-console/src/util/cockroachlabsAPI.ts +++ b/pkg/ui/workspaces/db-console/src/util/cockroachlabsAPI.ts @@ -12,7 +12,7 @@ * This module contains all the REST endpoints for communicating with the admin UI. */ -import moment from "moment"; +import moment from "moment-timezone"; import { VersionList, VersionCheckRequest } from "src/interfaces/cockroachlabs"; import { withTimeout } from "./api"; diff --git a/pkg/ui/workspaces/db-console/src/util/fakeApi.ts b/pkg/ui/workspaces/db-console/src/util/fakeApi.ts index 8954391d9b26..cf640e01e451 100644 --- a/pkg/ui/workspaces/db-console/src/util/fakeApi.ts +++ b/pkg/ui/workspaces/db-console/src/util/fakeApi.ts @@ -14,7 +14,7 @@ import { api as clusterUiApi } from "@cockroachlabs/cluster-ui"; import { cockroach } from "src/js/protos"; import { API_PREFIX, STATUS_PREFIX } from "src/util/api"; import fetchMock from "src/util/fetch-mock"; -import moment from "moment"; +import moment from "moment-timezone"; const { SettingsResponse, diff --git a/pkg/ui/workspaces/db-console/src/views/app/containers/metricsTimeManager/index.tsx b/pkg/ui/workspaces/db-console/src/views/app/containers/metricsTimeManager/index.tsx index 78433f318ee8..a0f456f19e28 100644 --- a/pkg/ui/workspaces/db-console/src/views/app/containers/metricsTimeManager/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/app/containers/metricsTimeManager/index.tsx @@ -10,7 +10,7 @@ import React from "react"; import { connect } from "react-redux"; -import moment from "moment"; +import moment from "moment-timezone"; import { AdminUIState } from "src/redux/state"; import * as timewindow from "src/redux/timeScale"; diff --git a/pkg/ui/workspaces/db-console/src/views/app/containers/metricsTimeManager/metricsTimeManager.spec.tsx b/pkg/ui/workspaces/db-console/src/views/app/containers/metricsTimeManager/metricsTimeManager.spec.tsx index 9060531b8731..cee80556c302 100644 --- a/pkg/ui/workspaces/db-console/src/views/app/containers/metricsTimeManager/metricsTimeManager.spec.tsx +++ b/pkg/ui/workspaces/db-console/src/views/app/containers/metricsTimeManager/metricsTimeManager.spec.tsx @@ -10,7 +10,7 @@ import React from "react"; import { shallow } from "enzyme"; -import moment from "moment"; +import moment from "moment-timezone"; import _ from "lodash"; import { MetricsTimeManagerUnconnected as MetricsTimeManager } from "./"; diff --git a/pkg/ui/workspaces/db-console/src/views/cluster/components/linegraph/index.tsx b/pkg/ui/workspaces/db-console/src/views/cluster/components/linegraph/index.tsx index d0db7ef15182..f322073f7c86 100644 --- a/pkg/ui/workspaces/db-console/src/views/cluster/components/linegraph/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/cluster/components/linegraph/index.tsx @@ -9,7 +9,7 @@ // licenses/APL.txt. import React from "react"; -import moment from "moment"; +import moment from "moment-timezone"; import { createSelector } from "reselect"; import { hoverOff, hoverOn, HoverState } from "src/redux/hover"; diff --git a/pkg/ui/workspaces/db-console/src/views/cluster/containers/events/index.tsx b/pkg/ui/workspaces/db-console/src/views/cluster/containers/events/index.tsx index 1c5bab561d93..453223667a95 100644 --- a/pkg/ui/workspaces/db-console/src/views/cluster/containers/events/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/cluster/containers/events/index.tsx @@ -9,7 +9,7 @@ // licenses/APL.txt. import _ from "lodash"; -import moment from "moment"; +import moment from "moment-timezone"; import React from "react"; import { Helmet } from "react-helmet"; import { Link, RouteComponentProps, withRouter } from "react-router-dom"; diff --git a/pkg/ui/workspaces/db-console/src/views/cluster/containers/nodeGraphs/index.tsx b/pkg/ui/workspaces/db-console/src/views/cluster/containers/nodeGraphs/index.tsx index 71758bddf2d0..8c9f8b5e8f32 100644 --- a/pkg/ui/workspaces/db-console/src/views/cluster/containers/nodeGraphs/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/cluster/containers/nodeGraphs/index.tsx @@ -81,7 +81,7 @@ import { TimeScale, } from "@cockroachlabs/cluster-ui"; import { reduceStorageOfTimeSeriesDataOperationalFlags } from "src/util/docs"; -import moment from "moment"; +import moment from "moment-timezone"; import { selectResolution10sStorageTTL, selectResolution30mStorageTTL, diff --git a/pkg/ui/workspaces/db-console/src/views/cluster/containers/nodesOverview/index.tsx b/pkg/ui/workspaces/db-console/src/views/cluster/containers/nodesOverview/index.tsx index df5465defd37..14171645f03e 100644 --- a/pkg/ui/workspaces/db-console/src/views/cluster/containers/nodesOverview/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/cluster/containers/nodesOverview/index.tsx @@ -11,7 +11,7 @@ import React from "react"; import { Link } from "react-router-dom"; import { connect } from "react-redux"; -import moment, { Moment } from "moment"; +import moment, { Moment } from "moment-timezone"; import { createSelector } from "reselect"; import _ from "lodash"; diff --git a/pkg/ui/workspaces/db-console/src/views/cluster/containers/timeScaleDropdownWithSearchParams/index.tsx b/pkg/ui/workspaces/db-console/src/views/cluster/containers/timeScaleDropdownWithSearchParams/index.tsx index 2106692fd979..2f08dca892fb 100644 --- a/pkg/ui/workspaces/db-console/src/views/cluster/containers/timeScaleDropdownWithSearchParams/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/cluster/containers/timeScaleDropdownWithSearchParams/index.tsx @@ -22,7 +22,7 @@ import { findClosestTimeScale, } from "@cockroachlabs/cluster-ui"; import { createSelector } from "reselect"; -import moment from "moment"; +import moment from "moment-timezone"; // The time scale dropdown from cluster-ui that updates route params as // options are selected. diff --git a/pkg/ui/workspaces/db-console/src/views/databases/databaseDetailsPage/redux.spec.ts b/pkg/ui/workspaces/db-console/src/views/databases/databaseDetailsPage/redux.spec.ts index c14da8130dbe..9e2a98f22636 100644 --- a/pkg/ui/workspaces/db-console/src/views/databases/databaseDetailsPage/redux.spec.ts +++ b/pkg/ui/workspaces/db-console/src/views/databases/databaseDetailsPage/redux.spec.ts @@ -25,7 +25,7 @@ import { AdminUIState, createAdminUIStore } from "src/redux/state"; import { databaseNameAttr } from "src/util/constants"; import * as fakeApi from "src/util/fakeApi"; import { mapStateToProps, mapDispatchToProps } from "./redux"; -import moment from "moment"; +import moment from "moment-timezone"; function fakeRouteComponentProps( key: string, diff --git a/pkg/ui/workspaces/db-console/src/views/databases/databaseTablePage/redux.spec.ts b/pkg/ui/workspaces/db-console/src/views/databases/databaseTablePage/redux.spec.ts index f42e1970bd0f..731652833fdf 100644 --- a/pkg/ui/workspaces/db-console/src/views/databases/databaseTablePage/redux.spec.ts +++ b/pkg/ui/workspaces/db-console/src/views/databases/databaseTablePage/redux.spec.ts @@ -26,7 +26,7 @@ import { databaseNameAttr, tableNameAttr } from "src/util/constants"; import * as fakeApi from "src/util/fakeApi"; import { mapStateToProps, mapDispatchToProps } from "./redux"; import { makeTimestamp } from "src/views/databases/utils"; -import moment from "moment"; +import moment from "moment-timezone"; function fakeRouteComponentProps( k1: string, diff --git a/pkg/ui/workspaces/db-console/src/views/databases/indexDetailsPage/redux.spec.ts b/pkg/ui/workspaces/db-console/src/views/databases/indexDetailsPage/redux.spec.ts index fb9a7b0dd4ee..083a3a037ab4 100644 --- a/pkg/ui/workspaces/db-console/src/views/databases/indexDetailsPage/redux.spec.ts +++ b/pkg/ui/workspaces/db-console/src/views/databases/indexDetailsPage/redux.spec.ts @@ -27,7 +27,7 @@ import { } from "src/util/constants"; import * as fakeApi from "src/util/fakeApi"; import { mapStateToProps, mapDispatchToProps } from "./redux"; -import moment from "moment"; +import moment from "moment-timezone"; import { makeTimestamp } from "src/views/databases/utils"; function fakeRouteComponentProps( diff --git a/pkg/ui/workspaces/db-console/src/views/keyVisualizer/timeWindow.tsx b/pkg/ui/workspaces/db-console/src/views/keyVisualizer/timeWindow.tsx index 2bccede57db8..5fdc7d072151 100644 --- a/pkg/ui/workspaces/db-console/src/views/keyVisualizer/timeWindow.tsx +++ b/pkg/ui/workspaces/db-console/src/views/keyVisualizer/timeWindow.tsx @@ -11,7 +11,7 @@ import React from "react"; import { TimeScaleOptions } from "@cockroachlabs/cluster-ui"; import TimeScaleDropdown from "src/views/cluster/containers/timeScaleDropdownWithSearchParams"; -import moment from "moment"; +import moment from "moment-timezone"; export const KeyVisualizerTimeWindow = () => { const keyVisualizerTimeScaleOptions: TimeScaleOptions = { diff --git a/pkg/ui/workspaces/db-console/src/views/reports/containers/enqueueRange/index.tsx b/pkg/ui/workspaces/db-console/src/views/reports/containers/enqueueRange/index.tsx index 47bd9dda766e..e6422ab81c52 100644 --- a/pkg/ui/workspaces/db-console/src/views/reports/containers/enqueueRange/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/reports/containers/enqueueRange/index.tsx @@ -11,7 +11,7 @@ import React, { Fragment } from "react"; import Helmet from "react-helmet"; import { RouteComponentProps, withRouter } from "react-router-dom"; -import moment from "moment"; +import moment from "moment-timezone"; import { enqueueRange } from "src/util/api"; import { cockroach } from "src/js/protos"; diff --git a/pkg/ui/workspaces/db-console/src/views/reports/containers/hotranges/index.tsx b/pkg/ui/workspaces/db-console/src/views/reports/containers/hotranges/index.tsx index 4533a36b31c8..59ee443f03b0 100644 --- a/pkg/ui/workspaces/db-console/src/views/reports/containers/hotranges/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/reports/containers/hotranges/index.tsx @@ -10,7 +10,7 @@ import React, { useCallback, useEffect, useState } from "react"; import { RouteComponentProps, withRouter } from "react-router-dom"; -import moment from "moment"; +import moment from "moment-timezone"; import { Button } from "@cockroachlabs/ui-components"; import { cockroach } from "src/js/protos"; import { getHotRanges } from "src/util/api"; diff --git a/pkg/ui/workspaces/db-console/src/views/reports/containers/network/index.tsx b/pkg/ui/workspaces/db-console/src/views/reports/containers/network/index.tsx index 6307c072922b..e079034dc189 100644 --- a/pkg/ui/workspaces/db-console/src/views/reports/containers/network/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/reports/containers/network/index.tsx @@ -10,7 +10,7 @@ import { deviation as d3Deviation, mean as d3Mean } from "d3"; import _, { capitalize } from "lodash"; -import moment from "moment"; +import moment from "moment-timezone"; import React, { Fragment } from "react"; import { Helmet } from "react-helmet"; import { connect } from "react-redux"; diff --git a/pkg/ui/workspaces/db-console/src/views/reports/containers/network/latency/latency.fixtures.ts b/pkg/ui/workspaces/db-console/src/views/reports/containers/network/latency/latency.fixtures.ts index 1978ae30a58e..5c2365d8558a 100644 --- a/pkg/ui/workspaces/db-console/src/views/reports/containers/network/latency/latency.fixtures.ts +++ b/pkg/ui/workspaces/db-console/src/views/reports/containers/network/latency/latency.fixtures.ts @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -import moment from "moment"; +import moment from "moment-timezone"; import Long from "long"; import { ILatencyProps } from "."; diff --git a/pkg/ui/workspaces/db-console/src/views/reports/containers/nodeHistory/decommissionedNodeHistory.tsx b/pkg/ui/workspaces/db-console/src/views/reports/containers/nodeHistory/decommissionedNodeHistory.tsx index 27dd63be8ddb..5d27c71cbb0c 100644 --- a/pkg/ui/workspaces/db-console/src/views/reports/containers/nodeHistory/decommissionedNodeHistory.tsx +++ b/pkg/ui/workspaces/db-console/src/views/reports/containers/nodeHistory/decommissionedNodeHistory.tsx @@ -12,7 +12,7 @@ import * as React from "react"; import { Helmet } from "react-helmet"; import { connect } from "react-redux"; import { RouteComponentProps, withRouter } from "react-router-dom"; -import { Moment } from "moment"; +import { Moment } from "moment-timezone"; import _ from "lodash"; import { AdminUIState } from "src/redux/state"; diff --git a/pkg/ui/workspaces/db-console/src/views/reports/containers/nodes/index.tsx b/pkg/ui/workspaces/db-console/src/views/reports/containers/nodes/index.tsx index c8d283494980..77e092ed400e 100644 --- a/pkg/ui/workspaces/db-console/src/views/reports/containers/nodes/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/reports/containers/nodes/index.tsx @@ -11,7 +11,7 @@ import classNames from "classnames"; import _ from "lodash"; import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; import React from "react"; import { Helmet } from "react-helmet"; import { connect } from "react-redux"; diff --git a/pkg/ui/workspaces/db-console/src/views/reports/containers/range/print.ts b/pkg/ui/workspaces/db-console/src/views/reports/containers/range/print.ts index 7e4e7edb4016..3f5b8fbe1980 100644 --- a/pkg/ui/workspaces/db-console/src/views/reports/containers/range/print.ts +++ b/pkg/ui/workspaces/db-console/src/views/reports/containers/range/print.ts @@ -10,7 +10,7 @@ import _ from "lodash"; import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; import * as protos from "src/js/protos"; import { util } from "@cockroachlabs/cluster-ui"; diff --git a/pkg/ui/workspaces/db-console/src/views/reports/containers/range/rangeTable.tsx b/pkg/ui/workspaces/db-console/src/views/reports/containers/range/rangeTable.tsx index 3882f6808339..c327df20afc1 100644 --- a/pkg/ui/workspaces/db-console/src/views/reports/containers/range/rangeTable.tsx +++ b/pkg/ui/workspaces/db-console/src/views/reports/containers/range/rangeTable.tsx @@ -11,7 +11,7 @@ import classNames from "classnames"; import _ from "lodash"; import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; import React from "react"; import * as protos from "src/js/protos"; import { cockroach } from "src/js/protos"; diff --git a/pkg/ui/workspaces/db-console/src/views/reports/containers/statementDiagnosticsHistory/index.tsx b/pkg/ui/workspaces/db-console/src/views/reports/containers/statementDiagnosticsHistory/index.tsx index 6c31352686e1..93f6c496f707 100644 --- a/pkg/ui/workspaces/db-console/src/views/reports/containers/statementDiagnosticsHistory/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/reports/containers/statementDiagnosticsHistory/index.tsx @@ -11,7 +11,7 @@ import React from "react"; import { Helmet } from "react-helmet"; import { connect } from "react-redux"; -import moment from "moment"; +import moment from "moment-timezone"; import { Link } from "react-router-dom"; import { isUndefined } from "lodash"; diff --git a/pkg/ui/workspaces/db-console/src/views/shared/containers/metricDataProvider/index.tsx b/pkg/ui/workspaces/db-console/src/views/shared/containers/metricDataProvider/index.tsx index e38e899bbb10..350b35f09a2b 100644 --- a/pkg/ui/workspaces/db-console/src/views/shared/containers/metricDataProvider/index.tsx +++ b/pkg/ui/workspaces/db-console/src/views/shared/containers/metricDataProvider/index.tsx @@ -10,7 +10,7 @@ import _ from "lodash"; import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; import React from "react"; import { connect } from "react-redux"; import { createSelector } from "reselect"; diff --git a/pkg/ui/workspaces/db-console/src/views/statements/statementDetails.tsx b/pkg/ui/workspaces/db-console/src/views/statements/statementDetails.tsx index 5268377f8e0d..7e0f337f331a 100644 --- a/pkg/ui/workspaces/db-console/src/views/statements/statementDetails.tsx +++ b/pkg/ui/workspaces/db-console/src/views/statements/statementDetails.tsx @@ -52,7 +52,7 @@ import { getMatchParamByName, queryByName } from "src/util/query"; import { appNamesAttr, statementAttr } from "src/util/constants"; import { selectTimeScale } from "src/redux/timeScale"; import { api as clusterUiApi } from "@cockroachlabs/cluster-ui"; -import moment from "moment"; +import moment from "moment-timezone"; const { generateStmtDetailsToID } = util; diff --git a/pkg/ui/workspaces/db-console/src/views/statements/statements.spec.tsx b/pkg/ui/workspaces/db-console/src/views/statements/statements.spec.tsx index 83052686f871..842777790e0e 100644 --- a/pkg/ui/workspaces/db-console/src/views/statements/statements.spec.tsx +++ b/pkg/ui/workspaces/db-console/src/views/statements/statements.spec.tsx @@ -9,7 +9,7 @@ // licenses/APL.txt. import Long from "long"; -import moment from "moment"; +import moment from "moment-timezone"; import { RouteComponentProps } from "react-router-dom"; import * as H from "history"; import { merge } from "lodash"; diff --git a/pkg/ui/workspaces/db-console/webpack.config.js b/pkg/ui/workspaces/db-console/webpack.config.js index 848cb747652b..f17616955d3c 100644 --- a/pkg/ui/workspaces/db-console/webpack.config.js +++ b/pkg/ui/workspaces/db-console/webpack.config.js @@ -15,9 +15,12 @@ const rimraf = require("rimraf"); const webpack = require("webpack"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const StringReplacePlugin = require("string-replace-webpack-plugin"); +const MomentTimezoneDataPlugin = require("moment-timezone-data-webpack-plugin"); const WebpackBar = require("webpackbar"); const { ESBuildMinifyPlugin } = require("esbuild-loader"); +const currentYear = new Date().getFullYear(); + const proxyPrefixes = ["/_admin", "/_status", "/ts", "/login", "/logout"]; function shouldProxy(reqPath) { if (reqPath === "/") { @@ -48,6 +51,16 @@ module.exports = (env, argv) => { reporters: [ "basic" ], profile: true, }), + + // Use MomentTimezoneDataPlugin to remove timezone data that we don't need. + new MomentTimezoneDataPlugin({ + matchZones: ["Etc/UTC", "America/New_York"], + startYear: 2021, + endYear: currentYear + 10, + // We have to tell the plugin where to store the pruned file + // otherwise webpack can't find it. + cacheDir: path.resolve(__dirname, "timezones"), + }), ]; // First check for local modules, then for third-party modules from diff --git a/pkg/ui/workspaces/db-console/yarn.lock b/pkg/ui/workspaces/db-console/yarn.lock index d0af549227d9..3900ab9daada 100644 --- a/pkg/ui/workspaces/db-console/yarn.lock +++ b/pkg/ui/workspaces/db-console/yarn.lock @@ -14899,6 +14899,21 @@ mocha@^6.2.1: yargs-parser "13.1.2" yargs-unparser "1.6.0" +moment-timezone-data-webpack-plugin@^1.5.1: + version "1.5.1" + resolved "https://storage.googleapis.com/cockroach-npm-deps/moment-timezone-data-webpack-plugin/-/moment-timezone-data-webpack-plugin-1.5.1.tgz#9d35dfd3768db55058e1e809d77a2b64bd6d03a4" + integrity sha512-1le6a35GgYdWMVYFzrfpE/F6Pk4bj0M3QKD6Iv6ba9LqWGoVqHQRHyCTLvLis5E1J98Sz40ET6yhZzMVakwpjg== + dependencies: + find-cache-dir "^3.0.0" + make-dir "^3.0.0" + +moment-timezone@^0.5.42: + version "0.5.42" + resolved "https://storage.googleapis.com/cockroach-npm-deps/moment-timezone/-/moment-timezone-0.5.42.tgz#c59f2aa00442d0dcd1d258d2182873d637b4e17b" + integrity sha512-tjI9goqwzkflKSTxJo+jC/W8riTFwEjjunssmFvAWlvNVApjbkJM7UHggyKO0q1Fd/kZVKY77H7C9A0XKhhAFw== + dependencies: + moment "^2.29.4" + moment@2.x: version "2.29.1" resolved "https://storage.googleapis.com/cockroach-npm-deps/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3" @@ -14914,6 +14929,11 @@ moment@^2.24.0: resolved "https://storage.googleapis.com/cockroach-npm-deps/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3" integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ== +moment@^2.29.4: + version "2.29.4" + resolved "https://storage.googleapis.com/cockroach-npm-deps/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" + integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w== + moo-color@^1.0.2: version "1.0.3" resolved "https://storage.googleapis.com/cockroach-npm-deps/moo-color/-/moo-color-1.0.3.tgz#d56435f8359c8284d83ac58016df7427febece74"