|
|
@@ -51,13 +51,13 @@ export interface GlobalContextType {
|
|
|
* 4) As a rule of thumb, Context should not be used for UI-related state
|
|
|
*/
|
|
|
class ContextProvider extends Component<PropsType, StateType> {
|
|
|
- state = {
|
|
|
- currentModal: null as string | null,
|
|
|
- currentModalData: null as any,
|
|
|
+ state: GlobalContextType = {
|
|
|
+ currentModal: null,
|
|
|
+ currentModalData: null,
|
|
|
setCurrentModal: (currentModal: string, currentModalData?: any) => {
|
|
|
this.setState({ currentModal, currentModalData });
|
|
|
},
|
|
|
- currentError: null as string | null,
|
|
|
+ currentError: null,
|
|
|
setCurrentError: (currentError: string) => {
|
|
|
this.setState({ currentError });
|
|
|
},
|
|
|
@@ -78,7 +78,7 @@ class ContextProvider extends Component<PropsType, StateType> {
|
|
|
callback && callback();
|
|
|
});
|
|
|
},
|
|
|
- currentProject: null as ProjectType | null,
|
|
|
+ currentProject: null,
|
|
|
setCurrentProject: (currentProject: ProjectType, callback?: any) => {
|
|
|
pushQueryParams(this.props, { project_id: currentProject.id.toString() });
|
|
|
if (currentProject) {
|
|
|
@@ -90,12 +90,12 @@ class ContextProvider extends Component<PropsType, StateType> {
|
|
|
callback && callback();
|
|
|
});
|
|
|
},
|
|
|
- projects: [] as ProjectType[],
|
|
|
+ projects: [],
|
|
|
setProjects: (projects: ProjectType[]) => {
|
|
|
projects.sort((a: any, b: any) => (a.name > b.name ? 1 : -1));
|
|
|
this.setState({ projects });
|
|
|
},
|
|
|
- user: null as any,
|
|
|
+ user: null,
|
|
|
setUser: (userId: number, email: string) => {
|
|
|
this.setState({ user: { userId, email } });
|
|
|
},
|
|
|
@@ -103,7 +103,7 @@ class ContextProvider extends Component<PropsType, StateType> {
|
|
|
setDevOpsMode: (devOpsMode: boolean) => {
|
|
|
this.setState({ devOpsMode });
|
|
|
},
|
|
|
- capabilities: null as CapabilityType,
|
|
|
+ capabilities: null,
|
|
|
setCapabilities: (capabilities: CapabilityType) => {
|
|
|
this.setState({ capabilities });
|
|
|
},
|