mirror of
https://github.com/wassname/talk.git
synced 2026-09-10 12:43:11 +08:00
[CORL-139, CORL-140] Community (#2239)
* feat: Add table ui component * feat: community user table * feat: filters and role change * fix: add some comments * fix: user viewer * fix: snapshots * test: add tests * fix: better popover experience * fix: test * chore: use enum * feat: prevent server side setting your own role * fix: cleanup
This commit is contained in:
@@ -18,6 +18,9 @@ export interface TalkContext {
|
||||
/** relayEnvironment for our relay framework. */
|
||||
relayEnvironment: Environment;
|
||||
|
||||
/** locales */
|
||||
locales: string[];
|
||||
|
||||
/** localeBundles for our i18n framework. */
|
||||
localeBundles: FluentBundle[];
|
||||
|
||||
@@ -61,12 +64,14 @@ export interface TalkContext {
|
||||
clearSession: () => Promise<void>;
|
||||
}
|
||||
|
||||
const { Provider, Consumer } = React.createContext<TalkContext>({} as any);
|
||||
export const TalkReactContext = React.createContext<TalkContext>({} as any);
|
||||
|
||||
export const useTalkContext = () => React.useContext(TalkReactContext);
|
||||
|
||||
/**
|
||||
* Allows consuming the provided context using the React Context API.
|
||||
*/
|
||||
export const TalkContextConsumer = Consumer;
|
||||
export const TalkContextConsumer = TalkReactContext.Consumer;
|
||||
|
||||
/**
|
||||
* In addition to just providing the context, TalkContextProvider also
|
||||
@@ -75,7 +80,7 @@ export const TalkContextConsumer = Consumer;
|
||||
export const TalkContextProvider: StatelessComponent<{
|
||||
value: TalkContext;
|
||||
}> = ({ value, children }) => (
|
||||
<Provider value={value}>
|
||||
<TalkReactContext.Provider value={value}>
|
||||
<LocalizationProvider bundles={value.localeBundles}>
|
||||
<UIContext.Provider
|
||||
value={{
|
||||
@@ -87,5 +92,5 @@ export const TalkContextProvider: StatelessComponent<{
|
||||
{children}
|
||||
</UIContext.Provider>
|
||||
</LocalizationProvider>
|
||||
</Provider>
|
||||
</TalkReactContext.Provider>
|
||||
);
|
||||
|
||||
@@ -238,6 +238,7 @@ export default async function createManaged({
|
||||
// Assemble context.
|
||||
const context: TalkContext = {
|
||||
relayEnvironment: environment,
|
||||
locales,
|
||||
localeBundles,
|
||||
timeagoFormatter,
|
||||
pym,
|
||||
|
||||
@@ -2,6 +2,8 @@ export {
|
||||
TalkContext,
|
||||
TalkContextConsumer,
|
||||
TalkContextProvider,
|
||||
TalkReactContext,
|
||||
useTalkContext,
|
||||
} from "./TalkContext";
|
||||
export { default as createManaged } from "./createManaged";
|
||||
export { default as withContext } from "./withContext";
|
||||
|
||||
Reference in New Issue
Block a user