mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-09-01 17:19:19 +00:00
Rename frontend directory (#472)
* Rename directory * Cleanup * Recover lost images * remove lint
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { createContext, useState, useContext } from "react";
|
||||
|
||||
export interface AppContextData {
|
||||
selectedRepo: string;
|
||||
setSelectedRepo: (newValue: string) => void;
|
||||
clusterMode: boolean;
|
||||
setClusterMode: (newValue: boolean) => void;
|
||||
}
|
||||
|
||||
const AppContext = createContext<AppContextData | undefined>(undefined);
|
||||
|
||||
export const useAppContext = (): AppContextData => {
|
||||
const context = useContext(AppContext);
|
||||
if (!context) {
|
||||
throw new Error("useAppContext must be used within a AppContextProvider");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
export const AppContextProvider = ({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) => {
|
||||
const [selectedRepo, setSelectedRepo] = useState("");
|
||||
const [clusterMode, setClusterMode] = useState(false);
|
||||
|
||||
const contextValue: AppContextData = {
|
||||
selectedRepo,
|
||||
setSelectedRepo,
|
||||
clusterMode,
|
||||
setClusterMode,
|
||||
};
|
||||
|
||||
return (
|
||||
<AppContext.Provider value={contextValue}>{children}</AppContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export default AppContext;
|
||||
@@ -0,0 +1,17 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import { createContext } from "react";
|
||||
|
||||
export interface ErrorAlert {
|
||||
title?: string;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
export const ErrorModalContext = createContext<{
|
||||
shouldShowErrorModal?: ErrorAlert;
|
||||
setShowErrorModal: (toggle?: ErrorAlert) => void;
|
||||
}>({
|
||||
shouldShowErrorModal: undefined,
|
||||
// in this case we allow Unexpected empty method
|
||||
//eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
setShowErrorModal: (toggle?: ErrorAlert) => {},
|
||||
});
|
||||
Reference in New Issue
Block a user