-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51910: ui: use StatementsPage from admin-ui-components r=koorosh a=koorosh Depends on cockroachdb/admin-ui-components#9 Depends on cockroachdb/yarn-vendored#27 Depends on cockroachdb/yarn-vendored#28 `StatementsPage` component is replaced with previously extracted version of StatementsPage in `admin-ui-components`. The new version (extracted) of `StatementsPage` has several changes that required to make the following adjustments: - `ActivateStatementDiagnostics` modal isn't connected components anymore so dispatching actions are pulled up to connected StatementsPage wrapper. - Previously, analytics functions (which track user interaction) were called directly from React components that made this functionality tightly coupled. Now, sagas used to watch actions related to user interaction and then call async logic in sagas. -- components expose only callback functions which are related to the the logic component is responsible; -- connected component is responsible to dispatch actions with proper payload to be properly then handled by sagas. Co-authored-by: Andrii Vorobiov <and.vorobiov@gmail.com>
- Loading branch information
Showing
16 changed files
with
222 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2020 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 { PayloadAction } from "src/interfaces/action"; | ||
|
||
export const TRACK_STATEMENTS_SEARCH = "cockroachui/analytics/TRACK_STATEMENTS_SEARCH"; | ||
export const TRACK_STATEMENTS_PAGINATION = "cockroachui/analytics/TRACK_STATEMENTS_PAGINATION"; | ||
export const TRACK_TABLE_SORT = "cockroachui/analytics/TRACK_TABLE_SORT"; | ||
|
||
export interface TableSortActionPayload { | ||
tableName: string; | ||
columnName: string; | ||
ascending?: boolean; | ||
} | ||
|
||
export function trackStatementsSearchAction(searchResults: number): PayloadAction<number> { | ||
return { | ||
type: TRACK_STATEMENTS_SEARCH, | ||
payload: searchResults, | ||
}; | ||
} | ||
|
||
export function trackStatementsPaginationAction(pageNum: number): PayloadAction<number> { | ||
return { | ||
type: TRACK_STATEMENTS_PAGINATION, | ||
payload: pageNum, | ||
}; | ||
} | ||
|
||
export function trackTableSortAction(tableName: string, columnName: string, ascending?: boolean): PayloadAction<TableSortActionPayload> { | ||
return { | ||
type: TRACK_TABLE_SORT, | ||
payload: { | ||
tableName, | ||
columnName, | ||
ascending, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2020 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 { all, call, takeEvery } from "redux-saga/effects"; | ||
import { PayloadAction } from "src/interfaces/action"; | ||
import { | ||
CREATE_STATEMENT_DIAGNOSTICS_REPORT, | ||
DiagnosticsReportPayload, | ||
OPEN_STATEMENT_DIAGNOSTICS_MODAL, | ||
} from "src/redux/statements"; | ||
import { | ||
trackActivateDiagnostics, | ||
trackDiagnosticsModalOpen, | ||
trackPaginate, | ||
trackSearch, | ||
trackTableSort, | ||
} from "src/util/analytics"; | ||
import { | ||
TRACK_STATEMENTS_SEARCH, | ||
TRACK_STATEMENTS_PAGINATION, | ||
TRACK_TABLE_SORT, | ||
TableSortActionPayload, | ||
} from "./analyticsActions"; | ||
|
||
export function* trackActivateStatementsDiagnostics(action: PayloadAction<DiagnosticsReportPayload>) { | ||
const { statementFingerprint } = action.payload; | ||
yield call(trackActivateDiagnostics, statementFingerprint); | ||
} | ||
|
||
export function* trackOpenStatementsDiagnostics(action: PayloadAction<DiagnosticsReportPayload>) { | ||
const { statementFingerprint } = action.payload; | ||
yield call(trackDiagnosticsModalOpen, statementFingerprint); | ||
} | ||
|
||
export function* trackStatementsSearch(action: PayloadAction<number>) { | ||
yield call(trackSearch, action.payload); | ||
} | ||
|
||
export function* trackStatementsPagination(action: PayloadAction<number>) { | ||
yield call(trackPaginate, action.payload); | ||
} | ||
|
||
export function* trackTableSortChange(action: PayloadAction<TableSortActionPayload>) { | ||
const { tableName, columnName, ascending } = action.payload; | ||
yield call(trackTableSort, tableName, columnName, ascending); | ||
} | ||
|
||
export function* analyticsSaga() { | ||
yield all([ | ||
takeEvery(CREATE_STATEMENT_DIAGNOSTICS_REPORT, trackActivateStatementsDiagnostics), | ||
takeEvery(OPEN_STATEMENT_DIAGNOSTICS_MODAL, trackOpenStatementsDiagnostics), | ||
takeEvery(TRACK_STATEMENTS_SEARCH, trackStatementsSearch), | ||
takeEvery(TRACK_STATEMENTS_PAGINATION, trackStatementsPagination), | ||
takeEvery(TRACK_TABLE_SORT, trackTableSortChange), | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.