-
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.
ui: add connected components for jobs pages
This commit adds "connected" components for the jobs pages. These components can be imported from the cluster-ui package into the managed service repo and used on the CC console. Release note: None
- Loading branch information
1 parent
ab9eabf
commit 046d6e6
Showing
28 changed files
with
775 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
// licenses/APL.txt. | ||
|
||
export * from "./jobDetails"; | ||
export * from "./jobDetailsConnected"; |
45 changes: 45 additions & 0 deletions
45
pkg/ui/workspaces/cluster-ui/src/jobs/jobDetailsPage/jobDetailsConnected.tsx
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,45 @@ | ||
// Copyright 2022 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 { connect } from "react-redux"; | ||
import { RouteComponentProps, withRouter } from "react-router-dom"; | ||
|
||
import { AppState } from "src/store"; | ||
import { selectJobState } from "../../store/jobDetails/job.selectors"; | ||
import { | ||
JobDetailsStateProps, | ||
JobDetailsDispatchProps, | ||
JobDetails, | ||
} from "./jobDetails"; | ||
import { JobRequest } from "src/api/jobsApi"; | ||
import { actions as jobActions } from "src/store/jobDetails"; | ||
|
||
const mapStateToProps = (state: AppState): JobDetailsStateProps => { | ||
const jobState = selectJobState(state); | ||
const job = jobState ? jobState.data : null; | ||
const jobLoading = jobState ? jobState.inFlight : false; | ||
const jobError = jobState ? jobState.lastError : null; | ||
return { | ||
job, | ||
jobLoading, | ||
jobError, | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = { | ||
refreshJob: (req: JobRequest) => jobActions.refresh(req), | ||
}; | ||
|
||
export const JobDetailsPageConnected = withRouter( | ||
connect<JobDetailsStateProps, JobDetailsDispatchProps, RouteComponentProps>( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
)(JobDetails), | ||
); |
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
99 changes: 99 additions & 0 deletions
99
pkg/ui/workspaces/cluster-ui/src/jobs/jobsPage/jobsPageConnected.tsx
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,99 @@ | ||
// Copyright 2022 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 { connect } from "react-redux"; | ||
import { RouteComponentProps, withRouter } from "react-router-dom"; | ||
|
||
import { AppState } from "src/store"; | ||
import { | ||
selectJobsState, | ||
selectShowSetting, | ||
selectSortSetting, | ||
selectTypeSetting, | ||
selectStatusSetting, | ||
} from "../../store/jobs/jobs.selectors"; | ||
import { | ||
JobsPageStateProps, | ||
JobsPageDispatchProps, | ||
JobsPage, | ||
} from "./jobsPage"; | ||
import { JobsRequest } from "src/api/jobsApi"; | ||
import { actions as jobsActions } from "src/store/jobs"; | ||
import { actions as localStorageActions } from "../../store/localStorage"; | ||
import { Dispatch } from "redux"; | ||
import { SortSetting } from "../../sortedtable"; | ||
|
||
const mapStateToProps = ( | ||
state: AppState, | ||
_: RouteComponentProps, | ||
): JobsPageStateProps => { | ||
const sort = selectSortSetting(state); | ||
const status = selectStatusSetting(state); | ||
const show = selectShowSetting(state); | ||
const type = selectTypeSetting(state); | ||
const jobsState = selectJobsState(state); | ||
const jobs = jobsState ? jobsState.data : null; | ||
const jobsLoading = jobsState ? jobsState.inFlight : false; | ||
const jobsError = jobsState ? jobsState.lastError : null; | ||
return { | ||
sort, | ||
status, | ||
show, | ||
type, | ||
jobs, | ||
jobsLoading, | ||
jobsError, | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch): JobsPageDispatchProps => ({ | ||
setShow: (showValue: string) => { | ||
dispatch( | ||
localStorageActions.update({ | ||
key: "showSetting/JobsPage", | ||
value: showValue, | ||
}), | ||
); | ||
}, | ||
setSort: (ss: SortSetting) => { | ||
dispatch( | ||
localStorageActions.update({ | ||
key: "sortSetting/JobsPage", | ||
value: ss, | ||
}), | ||
); | ||
}, | ||
setStatus: (statusValue: string) => { | ||
dispatch( | ||
localStorageActions.update({ | ||
key: "statusSetting/JobsPage", | ||
value: statusValue, | ||
}), | ||
); | ||
}, | ||
setType: (jobValue: number) => { | ||
dispatch( | ||
localStorageActions.update({ | ||
key: "typeSetting/JobsPage", | ||
value: jobValue, | ||
}), | ||
); | ||
}, | ||
refreshJobs: (req: JobsRequest) => dispatch(jobsActions.refresh(req)), | ||
onFilterChange: (req: JobsRequest) => | ||
dispatch(jobsActions.updateFilteredJobs(req)), | ||
}); | ||
|
||
export const JobsPageConnected = withRouter( | ||
connect<JobsPageStateProps, JobsPageDispatchProps, RouteComponentProps>( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
)(JobsPage), | ||
); |
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
Oops, something went wrong.