♻️ Add version reading by package file
This commit is contained in:
@@ -8,8 +8,8 @@ import Layout from '../components/layout/Layout';
|
||||
import { useInitConfig } from '../config/init';
|
||||
import { getFallbackConfig } from '../tools/config/getFallbackConfig';
|
||||
import { getFrontendConfig } from '../tools/config/getFrontendConfig';
|
||||
import { getServerSideTranslations } from '../tools/getServerSideTranslations';
|
||||
import { dashboardNamespaces } from '../tools/translation-namespaces';
|
||||
import { getServerSideTranslations } from '../tools/server/getServerSideTranslations';
|
||||
import { dashboardNamespaces } from '../tools/server/translation-namespaces';
|
||||
import { ConfigType } from '../types/config';
|
||||
import { DashboardServerSideProps } from '../types/dashboardPageType';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { GetServerSidePropsContext } from 'next';
|
||||
import { appWithTranslation } from 'next-i18next';
|
||||
import { AppProps } from 'next/app';
|
||||
import Head from 'next/head';
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
||||
import { ChangeAppPositionModal } from '../components/Dashboard/Modals/ChangePosition/ChangeAppPositionModal';
|
||||
import { ChangeWidgetPositionModal } from '../components/Dashboard/Modals/ChangePosition/ChangeWidgetPositionModal';
|
||||
@@ -22,8 +22,16 @@ import '../styles/global.scss';
|
||||
import { ColorTheme } from '../tools/color';
|
||||
import { queryClient } from '../tools/queryClient';
|
||||
import { theme } from '../tools/theme';
|
||||
import {
|
||||
getServiceSidePackageAttributes,
|
||||
ServerSidePackageAttributesType,
|
||||
} from '../tools/server/getPackageVersion';
|
||||
import { usePackageAttributesStore } from '../tools/client/zustands/usePackageAttributesStore';
|
||||
|
||||
function App(this: any, props: AppProps & { colorScheme: ColorScheme }) {
|
||||
function App(
|
||||
this: any,
|
||||
props: AppProps & { colorScheme: ColorScheme; packageAttributes: ServerSidePackageAttributesType }
|
||||
) {
|
||||
const { Component, pageProps } = props;
|
||||
const [primaryColor, setPrimaryColor] = useState<MantineTheme['primaryColor']>('red');
|
||||
const [secondaryColor, setSecondaryColor] = useState<MantineTheme['primaryColor']>('orange');
|
||||
@@ -46,6 +54,12 @@ function App(this: any, props: AppProps & { colorScheme: ColorScheme }) {
|
||||
getInitialValueInEffect: true,
|
||||
});
|
||||
|
||||
const { setInitialPackageAttributes } = usePackageAttributesStore();
|
||||
|
||||
useEffect(() => {
|
||||
setInitialPackageAttributes(props.packageAttributes);
|
||||
}, []);
|
||||
|
||||
const toggleColorScheme = (value?: ColorScheme) =>
|
||||
setColorScheme(value || (colorScheme === 'dark' ? 'light' : 'dark'));
|
||||
|
||||
@@ -111,6 +125,7 @@ function App(this: any, props: AppProps & { colorScheme: ColorScheme }) {
|
||||
|
||||
App.getInitialProps = ({ ctx }: { ctx: GetServerSidePropsContext }) => ({
|
||||
colorScheme: getCookie('color-scheme', ctx) || 'light',
|
||||
packageAttributes: getServiceSidePackageAttributes(),
|
||||
});
|
||||
|
||||
export default appWithTranslation(App);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { getCookie, setCookie } from 'cookies-next';
|
||||
import fs from 'fs';
|
||||
import { GetServerSidePropsContext } from 'next';
|
||||
|
||||
import fs from 'fs';
|
||||
import { LoadConfigComponent } from '../components/Config/LoadConfig';
|
||||
import { Dashboard } from '../components/Dashboard/Dashboard';
|
||||
import Layout from '../components/layout/Layout';
|
||||
import { useInitConfig } from '../config/init';
|
||||
import { getFrontendConfig } from '../tools/config/getFrontendConfig';
|
||||
import { getServerSideTranslations } from '../tools/getServerSideTranslations';
|
||||
import { dashboardNamespaces } from '../tools/translation-namespaces';
|
||||
import { getServerSideTranslations } from '../tools/server/getServerSideTranslations';
|
||||
import { dashboardNamespaces } from '../tools/server/translation-namespaces';
|
||||
import { DashboardServerSideProps } from '../types/dashboardPageType';
|
||||
import { LoadConfigComponent } from '../components/Config/LoadConfig';
|
||||
|
||||
export async function getServerSideProps({
|
||||
req,
|
||||
@@ -47,11 +47,14 @@ export async function getServerSideProps({
|
||||
}
|
||||
|
||||
const translations = await getServerSideTranslations(req, res, dashboardNamespaces, locale);
|
||||
|
||||
const config = getFrontendConfig(configName as string);
|
||||
|
||||
return {
|
||||
props: { configName: configName as string, config, ...translations },
|
||||
props: {
|
||||
configName: configName as string,
|
||||
config,
|
||||
...translations,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useRouter } from 'next/router';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useForm } from '@mantine/form';
|
||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
||||
import { loginNamespaces } from '../tools/translation-namespaces';
|
||||
import { loginNamespaces } from '../tools/server/translation-namespaces';
|
||||
|
||||
// TODO: Add links to the wiki articles about the login process.
|
||||
export default function AuthenticationTitle() {
|
||||
|
||||
Reference in New Issue
Block a user