mirror of
https://github.com/amir20/dozzle.git
synced 2026-01-02 11:07:26 +01:00
35 lines
771 B
TypeScript
35 lines
771 B
TypeScript
import { Container } from "@/models/Container";
|
|
|
|
type LogContext = {
|
|
streamConfig: { stdout: boolean; stderr: boolean };
|
|
containers: Container[];
|
|
loadingMore: boolean;
|
|
};
|
|
|
|
// export for testing
|
|
export const loggingContextKey = Symbol("loggingContext") as InjectionKey<LogContext>;
|
|
|
|
export const provideLoggingContext = (containers: Ref<Container[]>) => {
|
|
provide(
|
|
loggingContextKey,
|
|
reactive({
|
|
streamConfig: { stdout: true, stderr: true },
|
|
containers,
|
|
loadingMore: false,
|
|
}),
|
|
);
|
|
};
|
|
|
|
export const useLoggingContext = () => {
|
|
const context = inject(
|
|
loggingContextKey,
|
|
reactive({
|
|
streamConfig: { stdout: true, stderr: true },
|
|
containers: [],
|
|
loadingMore: false,
|
|
}),
|
|
);
|
|
|
|
return toRefs(context);
|
|
};
|