R: Remove .Provider from Contexts
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run

This commit is contained in:
Ivan 2024-12-12 21:58:19 +03:00
parent 56b7d3d71f
commit d0fbaa7148
13 changed files with 26 additions and 26 deletions

View File

@ -21,5 +21,5 @@ export const useAccessMode = () => {
export const AccessModeState = ({ children }: React.PropsWithChildren) => { export const AccessModeState = ({ children }: React.PropsWithChildren) => {
const [accessLevel, setAccessLevel] = useState<UserLevel>(UserLevel.READER); const [accessLevel, setAccessLevel] = useState<UserLevel>(UserLevel.READER);
return <AccessContext.Provider value={{ accessLevel, setAccessLevel }}>{children}</AccessContext.Provider>; return <AccessContext value={{ accessLevel, setAccessLevel }}>{children}</AccessContext>;
}; };

View File

@ -186,7 +186,7 @@ export const AuthState = ({ children }: React.PropsWithChildren) => {
}, [reload]); }, [reload]);
return ( return (
<AuthContext.Provider <AuthContext
value={{ value={{
user, user,
login, login,
@ -202,6 +202,6 @@ export const AuthState = ({ children }: React.PropsWithChildren) => {
}} }}
> >
{children} {children}
</AuthContext.Provider> </AuthContext>
); );
}; };

View File

@ -127,7 +127,7 @@ export const OptionsState = ({ children }: React.PropsWithChildren) => {
}, [noNavigation]); }, [noNavigation]);
return ( return (
<OptionsContext.Provider <OptionsContext
value={{ value={{
darkMode, darkMode,
adminMode, adminMode,
@ -169,6 +169,6 @@ export const OptionsState = ({ children }: React.PropsWithChildren) => {
{children} {children}
</> </>
</OptionsContext.Provider> </OptionsContext>
); );
}; };

View File

@ -87,7 +87,7 @@ export const GlobalOssState = ({ children }: React.PropsWithChildren) => {
); );
return ( return (
<GlobalOssContext.Provider <GlobalOssContext
value={{ value={{
schema, schema,
setID, setID,
@ -102,6 +102,6 @@ export const GlobalOssState = ({ children }: React.PropsWithChildren) => {
}} }}
> >
{children} {children}
</GlobalOssContext.Provider> </GlobalOssContext>
); );
}; };

View File

@ -291,7 +291,7 @@ export const LibraryState = ({ children }: React.PropsWithChildren) => {
); );
return ( return (
<LibraryContext.Provider <LibraryContext
value={{ value={{
items, items,
folders, folders,
@ -318,6 +318,6 @@ export const LibraryState = ({ children }: React.PropsWithChildren) => {
}} }}
> >
{children} {children}
</LibraryContext.Provider> </LibraryContext>
); );
}; };

View File

@ -93,7 +93,7 @@ export const NavigationState = ({ children }: React.PropsWithChildren) => {
}, [pathname, scrollTop]); }, [pathname, scrollTop]);
return ( return (
<NavigationContext.Provider <NavigationContext
value={{ value={{
push, push,
replace, replace,
@ -105,7 +105,7 @@ export const NavigationState = ({ children }: React.PropsWithChildren) => {
}} }}
> >
{children} {children}
</NavigationContext.Provider> </NavigationContext>
); );
}; };

View File

@ -358,7 +358,7 @@ export const OssState = ({ itemID, children }: React.PropsWithChildren<OssStateP
); );
return ( return (
<OssContext.Provider <OssContext
value={{ value={{
schema: ossData.schema, schema: ossData.schema,
itemID, itemID,
@ -385,6 +385,6 @@ export const OssState = ({ itemID, children }: React.PropsWithChildren<OssStateP
}} }}
> >
{children} {children}
</OssContext.Provider> </OssContext>
); );
}; };

View File

@ -549,7 +549,7 @@ export const RSFormState = ({ itemID, versionID, children }: React.PropsWithChil
); );
return ( return (
<RSFormContext.Provider <RSFormContext
value={{ value={{
schema: rsData.schema, schema: rsData.schema,
itemID, itemID,
@ -587,6 +587,6 @@ export const RSFormState = ({ itemID, versionID, children }: React.PropsWithChil
}} }}
> >
{children} {children}
</RSFormContext.Provider> </RSFormContext>
); );
}; };

View File

@ -76,8 +76,8 @@ export const UserProfileState = ({ children }: React.PropsWithChildren) => {
}, [reload]); }, [reload]);
return ( return (
<ProfileContext.Provider value={{ user, updateUser, error, loading, setError, processing, errorProcessing }}> <ProfileContext value={{ user, updateUser, error, loading, setError, processing, errorProcessing }}>
{children} {children}
</ProfileContext.Provider> </ProfileContext>
); );
}; };

View File

@ -81,7 +81,7 @@ export const UsersState = ({ children }: React.PropsWithChildren) => {
}, [reload]); }, [reload]);
return ( return (
<UsersContext.Provider <UsersContext
value={{ value={{
users, users,
reload, reload,
@ -89,6 +89,6 @@ export const UsersState = ({ children }: React.PropsWithChildren) => {
}} }}
> >
{children} {children}
</UsersContext.Provider> </UsersContext>
); );
}; };

View File

@ -82,7 +82,7 @@ const OssEditContext = createContext<IOssEditContext | null>(null);
export const useOssEdit = () => { export const useOssEdit = () => {
const context = useContext(OssEditContext); const context = useContext(OssEditContext);
if (context === null) { if (context === null) {
throw new Error('useOssEdit has to be used within <OssEditState.Provider>'); throw new Error('useOssEdit has to be used within <OssEditState>');
} }
return context; return context;
}; };
@ -384,7 +384,7 @@ export const OssEditState = ({ selected, setSelected, children }: React.PropsWit
); );
return ( return (
<OssEditContext.Provider <OssEditContext
value={{ value={{
schema: model.schema, schema: model.schema,
selected, selected,
@ -475,6 +475,6 @@ export const OssEditState = ({ selected, setSelected, children }: React.PropsWit
) : null} ) : null}
{children} {children}
</OssEditContext.Provider> </OssEditContext>
); );
}; };

View File

@ -114,7 +114,7 @@ const RSEditContext = createContext<IRSEditContext | null>(null);
export const useRSEdit = () => { export const useRSEdit = () => {
const context = useContext(RSEditContext); const context = useContext(RSEditContext);
if (context === null) { if (context === null) {
throw new Error('useRSEdit has to be used within <RSEditState.Provider>'); throw new Error('useRSEdit has to be used within <RSEditState>');
} }
return context; return context;
}; };
@ -628,7 +628,7 @@ export const RSEditState = ({
); );
return ( return (
<RSEditContext.Provider <RSEditContext
value={{ value={{
schema: model.schema, schema: model.schema,
updateSchema, updateSchema,
@ -785,7 +785,7 @@ export const RSEditState = ({
) : null} ) : null}
{children} {children}
</RSEditContext.Provider> </RSEditContext>
); );
}; };

View File

@ -1012,5 +1012,5 @@ export const prompts = {
// ============== INTERNAL LABELS FOR DEVELOPERS TEXT ================ // ============== INTERNAL LABELS FOR DEVELOPERS TEXT ================
export function contextOutsideScope(contextName: string, contextState: string): string { export function contextOutsideScope(contextName: string, contextState: string): string {
return `${contextName} has to be used within <${contextState}.Provider>`; return `${contextName} has to be used within <${contextState}>`;
} }