mirror of https://github.com/buster-so/buster.git
update imports for gloabl components
This commit is contained in:
parent
fb68215330
commit
447ae12478
|
@ -57,3 +57,6 @@ Cargo.lock
|
||||||
|
|
||||||
*.env
|
*.env
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# Node.js dependencies
|
||||||
|
node_modules/
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1 +0,0 @@
|
||||||
../web
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,6 +2,7 @@ import { BusterRoutes } from '@/routes/busterRoutes/busterRoutes';
|
||||||
import axios, { AxiosError } from 'axios';
|
import axios, { AxiosError } from 'axios';
|
||||||
import { rustErrorHandler } from './buster/errors';
|
import { rustErrorHandler } from './buster/errors';
|
||||||
import { AxiosRequestHeaders } from 'axios';
|
import { AxiosRequestHeaders } from 'axios';
|
||||||
|
import { isServer } from '@tanstack/react-query';
|
||||||
import { ReadonlyRequestCookies } from 'next/dist/server/web/spec-extension/adapters/request-cookies';
|
import { ReadonlyRequestCookies } from 'next/dist/server/web/spec-extension/adapters/request-cookies';
|
||||||
|
|
||||||
const AXIOS_TIMEOUT = 120000; // 2 minutes
|
const AXIOS_TIMEOUT = 120000; // 2 minutes
|
||||||
|
@ -22,7 +23,7 @@ export const createInstance = (baseURL: string) => {
|
||||||
(error: AxiosError) => {
|
(error: AxiosError) => {
|
||||||
// console.error(error);
|
// console.error(error);
|
||||||
//Redirect to login if 401 unauthorized error
|
//Redirect to login if 401 unauthorized error
|
||||||
if (error.status === 401 && typeof window !== 'undefined') {
|
if (error.status === 401 && !isServer) {
|
||||||
window.location.href = BusterRoutes.AUTH_LOGIN;
|
window.location.href = BusterRoutes.AUTH_LOGIN;
|
||||||
}
|
}
|
||||||
return Promise.reject(rustErrorHandler(error));
|
return Promise.reject(rustErrorHandler(error));
|
||||||
|
@ -40,7 +41,6 @@ export const defaultRequestHandler = async (
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
let token = '';
|
let token = '';
|
||||||
const isServer = typeof window === 'undefined';
|
|
||||||
if (isServer) {
|
if (isServer) {
|
||||||
const { cookies } = require('next/headers');
|
const { cookies } = require('next/headers');
|
||||||
const cookiesManager = cookies() as ReadonlyRequestCookies;
|
const cookiesManager = cookies() as ReadonlyRequestCookies;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { AppPasswordAccess } from '../_controllers/AppPasswordAccess';
|
||||||
import { AppNoPageAccess } from '../_controllers/AppNoPageAccess';
|
import { AppNoPageAccess } from '../_controllers/AppNoPageAccess';
|
||||||
import { BusterShareAssetType } from '@/api/busterv2';
|
import { BusterShareAssetType } from '@/api/busterv2';
|
||||||
import { useBusterSupabaseAuthMethods } from '@/hooks/useBusterSupabaseAuthMethods';
|
import { useBusterSupabaseAuthMethods } from '@/hooks/useBusterSupabaseAuthMethods';
|
||||||
import { ClientSideAnonCheck } from './_ClientSideAnonCheck';
|
import { ClientSideAnonCheck } from './ClientSideAnonCheck';
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
import { BusterRoutes, createBusterRoute } from '@/routes';
|
import { BusterRoutes, createBusterRoute } from '@/routes';
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import React from 'react';
|
||||||
import { AppLayout } from './_controllers/AppLayout';
|
import { AppLayout } from './_controllers/AppLayout';
|
||||||
import { BusterUserResponse } from '@/api/busterv2';
|
import { BusterUserResponse } from '@/api/busterv2';
|
||||||
import { useSupabaseServerContext } from '@/context/Supabase/useSupabaseContext';
|
import { useSupabaseServerContext } from '@/context/Supabase/useSupabaseContext';
|
||||||
import { GlobalErrorComponent } from './_components/GlobalErrorComponent';
|
import { GlobalErrorComponent } from '../../components/error';
|
||||||
|
|
||||||
export const AppLayoutClient = ({
|
export const AppLayoutClient = ({
|
||||||
children,
|
children,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import React from 'react';
|
||||||
import '../styles/styles.scss';
|
import '../styles/styles.scss';
|
||||||
|
|
||||||
import { BusterStyleProvider } from '@/context/BusterStyles/BusterStyles';
|
import { BusterStyleProvider } from '@/context/BusterStyles/BusterStyles';
|
||||||
import { GlobalErrorComponent } from './app/_components/GlobalErrorComponent';
|
import { GlobalErrorComponent } from '../components/error/GlobalErrorComponent';
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: 'Buster',
|
title: 'Buster',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { Alert, Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
import { Component, ErrorInfo, ReactNode, useEffect } from 'react';
|
import { Component, ErrorInfo, ReactNode } from 'react';
|
||||||
import { Title } from '@/components/text';
|
import { Title } from '@/components/text';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
|
@ -1 +1,2 @@
|
||||||
export * from './ErrorBoundary';
|
export * from './ErrorBoundary';
|
||||||
|
export * from './GlobalErrorComponent';
|
||||||
|
|
|
@ -120,8 +120,8 @@ export const AppCodeEditor = forwardRef<AppCodeEditorHandle, AppCodeEditorProps>
|
||||||
const onMountCodeEditor = useMemoizedFn(
|
const onMountCodeEditor = useMemoizedFn(
|
||||||
async (editor: editor.IStandaloneCodeEditor, monaco: typeof import('monaco-editor')) => {
|
async (editor: editor.IStandaloneCodeEditor, monaco: typeof import('monaco-editor')) => {
|
||||||
const [GithubLightTheme, NightOwlTheme] = await Promise.all([
|
const [GithubLightTheme, NightOwlTheme] = await Promise.all([
|
||||||
(await import('./Github_light')).default,
|
(await import('./themes/github_light_theme')).default,
|
||||||
(await import('./Tomorrow-Night')).default
|
(await import('./themes/tomorrow_night_theme')).default
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (language === 'yaml') {
|
if (language === 'yaml') {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import tailwind from '../../../../tailwind.config';
|
import tailwind from '../../../../../tailwind.config';
|
||||||
import type { editor } from 'monaco-editor';
|
import type { editor } from 'monaco-editor';
|
||||||
const colors = tailwind.theme.extend.colors;
|
const colors = tailwind.theme.extend.colors;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import tailwind from '../../../../tailwind.config';
|
import tailwind from '../../../../../tailwind.config';
|
||||||
const colors = tailwind.theme.extend.colors;
|
const colors = tailwind.theme.extend.colors;
|
||||||
|
|
||||||
const theme = {
|
const theme = {
|
|
@ -1,12 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Switch, SwitchProps } from 'antd';
|
|
||||||
|
|
||||||
export interface AppSwitchProps extends SwitchProps {
|
|
||||||
checked?: boolean;
|
|
||||||
defaultChecked?: boolean;
|
|
||||||
onChange: (checked: boolean) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AppSwitch: React.FC<AppSwitchProps> = (props) => {
|
|
||||||
return <Switch {...props} />;
|
|
||||||
};
|
|
|
@ -1,2 +1 @@
|
||||||
export * from './AppSwitch';
|
|
||||||
export * from './AppSearchInput';
|
export * from './AppSearchInput';
|
||||||
|
|
|
@ -38,8 +38,6 @@ export const PreventNavigation: React.FC<PreventNavigationProps> = React.memo(
|
||||||
|
|
||||||
// Used to make popstate event trigger when back button is clicked.
|
// Used to make popstate event trigger when back button is clicked.
|
||||||
// Without this, the popstate event will not fire because it needs there to be a href to return.
|
// Without this, the popstate event will not fire because it needs there to be a href to return.
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to prevent navigation when use click in navigation `<Link />` or `<a />`.
|
* Used to prevent navigation when use click in navigation `<Link />` or `<a />`.
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { PostHogConfig } from 'posthog-js';
|
||||||
import { isDev } from '@/config';
|
import { isDev } from '@/config';
|
||||||
import posthog from 'posthog-js';
|
import posthog from 'posthog-js';
|
||||||
import { useUserConfigContextSelector } from '../Users';
|
import { useUserConfigContextSelector } from '../Users';
|
||||||
|
import { isServer } from '@tanstack/react-query';
|
||||||
const POSTHOG_KEY = process.env.NEXT_PUBLIC_POSTHOG_KEY!;
|
const POSTHOG_KEY = process.env.NEXT_PUBLIC_POSTHOG_KEY!;
|
||||||
|
|
||||||
export const BusterPosthogProvider: React.FC<PropsWithChildren> = React.memo(({ children }) => {
|
export const BusterPosthogProvider: React.FC<PropsWithChildren> = React.memo(({ children }) => {
|
||||||
|
@ -38,7 +38,7 @@ const PosthogWrapper: React.FC<PropsWithChildren<{}>> = ({ children }) => {
|
||||||
const team = userTeams[0];
|
const team = userTeams[0];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (POSTHOG_KEY && typeof window !== 'undefined' && user && posthog && team) {
|
if (POSTHOG_KEY && !isServer && user && posthog && team) {
|
||||||
posthog.init(POSTHOG_KEY, options);
|
posthog.init(POSTHOG_KEY, options);
|
||||||
|
|
||||||
const email = user.email;
|
const email = user.email;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import memoize from 'lodash/memoize';
|
import memoize from 'lodash/memoize';
|
||||||
|
import { isServer } from '@tanstack/react-query';
|
||||||
const isBrowser = typeof window !== 'undefined';
|
|
||||||
|
|
||||||
let ctx: CanvasRenderingContext2D;
|
let ctx: CanvasRenderingContext2D;
|
||||||
const getCanvasContext = () => {
|
const getCanvasContext = () => {
|
||||||
|
@ -14,7 +13,7 @@ const getCanvasContext = () => {
|
||||||
|
|
||||||
export const measureTextWidth = memoize(
|
export const measureTextWidth = memoize(
|
||||||
(text: string, font: any = {}) => {
|
(text: string, font: any = {}) => {
|
||||||
if (isBrowser) {
|
if (!isServer) {
|
||||||
const { fontSize, fontFamily = 'sans-serif', fontWeight, fontStyle, fontVariant } = font;
|
const { fontSize, fontFamily = 'sans-serif', fontWeight, fontStyle, fontVariant } = font;
|
||||||
const ctx = getCanvasContext();
|
const ctx = getCanvasContext();
|
||||||
// @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/font
|
// @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/font
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import isNumber from 'lodash/isNumber';
|
import isNumber from 'lodash/isNumber';
|
||||||
import { formatNumber } from './numbers';
|
import { formatNumber } from './numbers';
|
||||||
|
|
||||||
const isBrowser = typeof window !== 'undefined';
|
|
||||||
|
|
||||||
export const inputHasText = (input: unknown): boolean => {
|
export const inputHasText = (input: unknown): boolean => {
|
||||||
if (typeof input !== 'string') {
|
if (typeof input !== 'string') {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue