-
Notifications
You must be signed in to change notification settings - Fork 4
/
TroubleshootingTabContainer.tsx
68 lines (62 loc) · 1.76 KB
/
TroubleshootingTabContainer.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import * as React from "react";
import { Store } from "@reduxjs/toolkit";
import * as PropTypes from "prop-types";
import { State } from "../reducers/index";
import {
TabContainer,
TabContainerProps,
TabContainerContext,
} from "./TabContainer";
import TroubleshootingCategoryPage from "./TroubleshootingCategoryPage";
export interface TroubleshootingTabContainerProps extends TabContainerProps {
goToTab: (tabName: string) => void;
subtab?: string;
}
export default class TroubleshootingTabContainer extends TabContainer<
TroubleshootingTabContainerProps
> {
context: TabContainerContext;
static contextTypes: React.ValidationMap<TabContainerContext> = {
router: PropTypes.object.isRequired,
pathFor: PropTypes.func.isRequired,
};
tabs() {
return {
diagnostics: (
<TroubleshootingCategoryPage
subtab={
this.props.tab === "diagnostics"
? this.props.subtab
: "coverage_provider"
}
type="diagnostics"
/>
),
"self-tests": (
<TroubleshootingCategoryPage
subtab={
this.props.tab === "self-tests" ? this.props.subtab : "collections"
}
type="self-tests"
/>
),
};
}
UNSAFE_componentWillReceiveProps(newProps: TroubleshootingTabContainerProps) {
newProps.tab !== this.props.tab &&
this.route(newProps.tab, newProps.subtab);
}
handleSelect(event) {
const tab = event.currentTarget.dataset.tabkey;
const subtab = this.props.subtab;
this.props.goToTab(tab);
this.route(tab, subtab);
}
route(tab: string, subtab: string) {
if (this.context.router) {
this.context.router.push(
"/admin/web/troubleshooting/" + tab + "/" + subtab
);
}
}
}