mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
Merge branch 'featrue/roles-permission' of https://github.com/bigcapitalhq/client into featrue/roles-permission
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import * as R from 'ramda';
|
|
||||||
import {
|
import {
|
||||||
useAuthenticatedAccount,
|
useAuthenticatedAccount,
|
||||||
useCurrentOrganization,
|
useCurrentOrganization,
|
||||||
@@ -10,9 +9,9 @@ import { useWatch, useWatchImmediate, useWhen } from '../../hooks';
|
|||||||
import { setCookie, getCookie } from '../../utils';
|
import { setCookie, getCookie } from '../../utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boots dashboard meta.
|
* Dashboard meta async booting.
|
||||||
*/
|
*/
|
||||||
function useDashboardMetaBoot() {
|
export function useDashboardMetaBoot() {
|
||||||
const {
|
const {
|
||||||
data: dashboardMeta,
|
data: dashboardMeta,
|
||||||
isLoading: isDashboardMetaLoading,
|
isLoading: isDashboardMetaLoading,
|
||||||
@@ -20,7 +19,7 @@ function useDashboardMetaBoot() {
|
|||||||
} = useDashboardMeta();
|
} = useDashboardMeta();
|
||||||
|
|
||||||
const [startLoading, stopLoading] = useSplashLoading();
|
const [startLoading, stopLoading] = useSplashLoading();
|
||||||
|
|
||||||
useWatchImmediate((value) => {
|
useWatchImmediate((value) => {
|
||||||
value && startLoading();
|
value && startLoading();
|
||||||
}, isDashboardMetaLoading);
|
}, isDashboardMetaLoading);
|
||||||
@@ -28,12 +27,26 @@ function useDashboardMetaBoot() {
|
|||||||
useWatchImmediate(() => {
|
useWatchImmediate(() => {
|
||||||
isDashboardMetaSuccess && stopLoading();
|
isDashboardMetaSuccess && stopLoading();
|
||||||
}, isDashboardMetaSuccess);
|
}, isDashboardMetaSuccess);
|
||||||
|
|
||||||
|
return {
|
||||||
|
isLoading: isDashboardMetaLoading,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dashboard async booting.
|
* Dashboard async booting.
|
||||||
|
* @returns {{ isLoading: boolean }}
|
||||||
*/
|
*/
|
||||||
export function DashboardBoot({ authenticatedUserId }) {
|
export function useDashboardBoot() {
|
||||||
|
const { isLoading } = useDashboardMetaBoot();
|
||||||
|
|
||||||
|
return { isLoading };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application async booting.
|
||||||
|
*/
|
||||||
|
export function useApplicationBoot() {
|
||||||
// Fetches the current user's organization.
|
// Fetches the current user's organization.
|
||||||
const {
|
const {
|
||||||
isSuccess: isCurrentOrganizationSuccess,
|
isSuccess: isCurrentOrganizationSuccess,
|
||||||
@@ -45,8 +58,6 @@ export function DashboardBoot({ authenticatedUserId }) {
|
|||||||
const { isSuccess: isAuthUserSuccess, isLoading: isAuthUserLoading } =
|
const { isSuccess: isAuthUserSuccess, isLoading: isAuthUserLoading } =
|
||||||
useAuthenticatedAccount();
|
useAuthenticatedAccount();
|
||||||
|
|
||||||
useDashboardMetaBoot();
|
|
||||||
|
|
||||||
// Initial locale cookie value.
|
// Initial locale cookie value.
|
||||||
const localeCookie = getCookie('locale');
|
const localeCookie = getCookie('locale');
|
||||||
|
|
||||||
@@ -109,5 +120,8 @@ export function DashboardBoot({ authenticatedUserId }) {
|
|||||||
isBooted.current = true;
|
isBooted.current = true;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return null;
|
|
||||||
|
return {
|
||||||
|
isLoading: isOrgLoading || isAuthUserLoading,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DashboardAbilityProvider } from '../../components';
|
import { DashboardAbilityProvider } from '../../components';
|
||||||
|
import { useDashboardBoot } from './DashboardBoot';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dashboard provider.
|
* Dashboard provider.
|
||||||
*/
|
*/
|
||||||
export default function DashboardProvider({ children }) {
|
export default function DashboardProvider({ children }) {
|
||||||
return <DashboardAbilityProvider>{children}</DashboardAbilityProvider>;
|
const { isLoading } = useDashboardBoot();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DashboardAbilityProvider>
|
||||||
|
{isLoading ? null : children}
|
||||||
|
</DashboardAbilityProvider>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import * as R from 'ramda';
|
|
||||||
|
|
||||||
import { DashboardBoot } from '../../components';
|
import { useApplicationBoot } from '../../components';
|
||||||
|
|
||||||
import withDashboard from '../../containers/Dashboard/withDashboard';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private pages provider.
|
* Private pages provider.
|
||||||
*/
|
*/
|
||||||
function PrivatePagesProviderComponent({
|
export function PrivatePagesProvider({
|
||||||
splashScreenCompleted,
|
|
||||||
|
|
||||||
// #ownProps
|
// #ownProps
|
||||||
children,
|
children,
|
||||||
}) {
|
}) {
|
||||||
return (
|
const { isLoading } = useApplicationBoot();
|
||||||
<React.Fragment>
|
|
||||||
<DashboardBoot />
|
|
||||||
{splashScreenCompleted ? children : null}
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PrivatePagesProvider = R.compose(
|
return <React.Fragment>{!isLoading ? children : null}</React.Fragment>;
|
||||||
withDashboard(({ splashScreenCompleted }) => ({
|
}
|
||||||
splashScreenCompleted,
|
|
||||||
})),
|
|
||||||
)(PrivatePagesProviderComponent);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user