-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af58d52
commit 75bb6d0
Showing
17 changed files
with
2,050 additions
and
151 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
87 changes: 54 additions & 33 deletions
87
...+/$account+/env+/$environment+/workloads+/helm-chart+/$helmchart+/useHelmChartContext.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 |
---|---|---|
@@ -1,49 +1,70 @@ | ||
import { createContext, ReactNode, useContext, useEffect, useState } from "react"; | ||
import { HelmChartIn } from "~/root/src/generated/gql/server"; | ||
import { | ||
createContext, | ||
ReactNode, | ||
useContext, | ||
useEffect, | ||
useState, | ||
} from 'react'; | ||
import { HelmChartIn } from '~/root/src/generated/gql/server'; | ||
|
||
const HelmChartContext = createContext<{ | ||
helmChart: HelmChartIn, | ||
readOnlyHelmChart: HelmChartIn, | ||
setHelmChart: (helmChart: HelmChartIn) => void | ||
setReadOnlyHelmChart: (helmChart: HelmChartIn) => void | ||
helmChart: HelmChartIn; | ||
readOnlyHelmChart: HelmChartIn; | ||
setHelmChart: (helmChart: HelmChartIn) => void; | ||
setReadOnlyHelmChart: (helmChart: HelmChartIn) => void; | ||
}>({ | ||
helmChart: { | ||
displayName: "" | ||
}, readOnlyHelmChart: { | ||
displayName: "" | ||
}, setHelmChart: () => { }, setReadOnlyHelmChart() { | ||
|
||
displayName: '', | ||
}, | ||
readOnlyHelmChart: { | ||
displayName: '', | ||
}, | ||
}) | ||
setHelmChart: () => {}, | ||
setReadOnlyHelmChart() {}, | ||
}); | ||
|
||
const HelmChartContextProvider = ({ initialHelmChartState, children }: { | ||
initialHelmChartState: | ||
HelmChartIn, children?: ReactNode | ||
const HelmChartContextProvider = ({ | ||
initialHelmChartState, | ||
children, | ||
}: { | ||
initialHelmChartState: HelmChartIn; | ||
children?: ReactNode; | ||
}) => { | ||
const [helmChart, setHelmChart] = useState<HelmChartIn>(initialHelmChartState) | ||
const [readOnlyHelmChart, setReadOnlyHelmChart] = useState(initialHelmChartState) | ||
const [helmChart, setHelmChart] = useState<HelmChartIn>( | ||
initialHelmChartState | ||
); | ||
const [readOnlyHelmChart, setReadOnlyHelmChart] = useState( | ||
initialHelmChartState | ||
); | ||
|
||
useEffect(() => { | ||
setHelmChart(initialHelmChartState) | ||
setReadOnlyHelmChart(initialHelmChartState) | ||
setHelmChart(initialHelmChartState); | ||
setReadOnlyHelmChart(initialHelmChartState); | ||
|
||
console.log("put...pp") | ||
}, [initialHelmChartState]) | ||
console.log('put...pp'); | ||
}, [initialHelmChartState]); | ||
|
||
const putHelmChart = (h: HelmChartIn) => { | ||
setHelmChart(h) | ||
console.log("put") | ||
} | ||
setHelmChart(h); | ||
console.log('put'); | ||
}; | ||
|
||
return <HelmChartContext.Provider value={{ | ||
helmChart, readOnlyHelmChart, | ||
setHelmChart: putHelmChart, | ||
setReadOnlyHelmChart | ||
}}>{children}</HelmChartContext.Provider> | ||
} | ||
return ( | ||
<HelmChartContext.Provider | ||
value={{ | ||
helmChart, | ||
readOnlyHelmChart, | ||
setHelmChart: putHelmChart, | ||
setReadOnlyHelmChart, | ||
}} | ||
> | ||
{children} | ||
</HelmChartContext.Provider> | ||
); | ||
}; | ||
|
||
export const useHelmChartState = () => { | ||
return useContext(HelmChartContext) | ||
} | ||
return useContext(HelmChartContext); | ||
}; | ||
|
||
export default HelmChartContextProvider | ||
export default HelmChartContextProvider; |
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.