Skip to content

Commit

Permalink
JNG-5841 fix aggregate refresh lifecycle (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg authored Jul 16, 2024
1 parent 1aa5467 commit 63f78ee
Show file tree
Hide file tree
Showing 24 changed files with 952 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
<source>src/containers/Planet/View/PlanetViewPageContainer.tsx</source>
<source>src/pages/God/God/Earth/AccessViewPage/index.tsx</source>
<source>src/pages/View/Star/Planets/RelationViewPage/index.tsx</source>
<source>src/dialogs/View/Galaxy/Stars/RelationViewPage/index.tsx</source>
</sources>
</configuration>
</plugin>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useViewPlanetViewGroup_2RightCreaturesPunishCreatureRelationTableCallSe
import { useViewPlanetViewGroup_2RightCreaturesRewardCreatureRelationTableCallSelector } from '~/dialogs/View/Planet/View/Group_2/Right/Creatures/RewardCreature/Relation/Table/CallSelector/hooks';
import { useViewPlanetViewGroup_2RightCreaturesTableAddSelectorPage } from '~/dialogs/View/Planet/View/Group_2/Right/Creatures/TableAddSelectorPage/hooks';
import { useViewPlanetViewGroup_2RightCreaturesTalkToGodRelationTableCallSelector } from '~/dialogs/View/Planet/View/Group_2/Right/Creatures/TalkToGod/Relation/Table/CallSelector/hooks';
import { useCRUDDialog, useSnacks, useViewData } from '~/hooks';
import { useCRUDDialog, useEventBus, useSnacks, useViewData } from '~/hooks';
import { routeToViewPlanetViewChooseTheMessiahOutputView } from '~/routes';
import { routeToViewPlanetViewHateGodOutputView } from '~/routes';
import { routeToViewPlanetViewLoveGodOutputView } from '~/routes';
Expand Down Expand Up @@ -54,7 +54,8 @@ const ViewPlanetViewPageContainer = lazy(() => import('~/containers/View/Planet/
// XMIID: God/(esm/_oaE_YM_fEe6fibzd7gNETg)/AccessViewPageDefinition
// Name: God::God::earth::AccessViewPage
export default function GodGodEarthAccessViewPage() {
const dataPath = '';
const dataPath: string = '';
const rootPageId: string | undefined = undefined;
const isDraft = false;
const owner = useRef<any>(null);

Expand All @@ -68,6 +69,7 @@ export default function GodGodEarthAccessViewPage() {
const { openFilterDialog } = useFilterDialog();
const { openConfirmDialog } = useConfirmDialog();
const { setLatestViewData, setRouterPageData } = useViewData();
const { publish, subscribe } = useEventBus();
const handleError = useErrorHandler();
const openCRUDDialog = useCRUDDialog();

Expand Down Expand Up @@ -211,6 +213,7 @@ export default function GodGodEarthAccessViewPage() {
}
setData(result);
setLatestViewData(result);
publish('God/(esm/_oaE_YM_fEe6fibzd7gNETg)/AccessViewPageDefinition:refreshed', result);
setRouterPageData(result);
if (customActions?.postRefreshAction) {
await customActions?.postRefreshAction(result, storeDiff, setValidation);
Expand Down Expand Up @@ -629,6 +632,16 @@ export default function GodGodEarthAccessViewPage() {
})();
}, []);

useEffect(() => {
const unsubscribe = subscribe('refresh:God/(esm/_oaE_YM_fEe6fibzd7gNETg)/AccessViewPageDefinition', async () => {
await refresh();
});

return () => {
unsubscribe();
};
}, [subscribe, data, editMode]);

return (
<ViewPlanetViewViewModelContext.Provider value={viewModel}>
<Suspense>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { useGodGodGalaxiesAccessFormPage } from '~/dialogs/God/God/Galaxies/Acce
import { useViewGalaxyTableCreateDarkMatterInputForm } from '~/dialogs/View/Galaxy/Table/CreateDarkMatter/Input/Form/hooks';
import { useViewGalaxyTableCreateIntergalacticDustInputForm } from '~/dialogs/View/Galaxy/Table/CreateIntergalacticDust/Input/Form/hooks';
import { useViewGalaxyTableCreateInterstellarMediumInputForm } from '~/dialogs/View/Galaxy/Table/CreateInterstellarMedium/Input/Form/hooks';
import { useCRUDDialog, useSnacks, useViewData } from '~/hooks';
import { useCRUDDialog, useEventBus, useSnacks, useViewData } from '~/hooks';
import { routeToGodGodGalaxiesAccessViewPage } from '~/routes';
import type { JudoIdentifiable } from '~/services/data-api/common/JudoIdentifiable';
import { draftIdentifierPrefix } from '~/services/data-api/common/utils';
Expand All @@ -43,7 +43,8 @@ const ViewGalaxyTablePageContainer = lazy(() => import('~/containers/View/Galaxy
// XMIID: God/(esm/_4pyPkM_cEe6fibzd7gNETg)/AccessTablePageDefinition
// Name: God::God::galaxies::AccessTablePage
export default function GodGodGalaxiesAccessTablePage() {
const dataPath = '';
const dataPath: string = '';
const rootPageId: string | undefined = undefined;
const isDraft = false;
const owner = useRef<any>(null);

Expand All @@ -57,6 +58,7 @@ export default function GodGodGalaxiesAccessTablePage() {
const { openFilterDialog } = useFilterDialog();
const { openConfirmDialog } = useConfirmDialog();
const { setLatestViewData, setRouterPageData } = useViewData();
const { publish, subscribe } = useEventBus();
const handleError = useErrorHandler();
const openCRUDDialog = useCRUDDialog();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useViewGalaxyViewCreateDarkMatterInputForm } from '~/dialogs/View/Galax
import { useViewGalaxyViewCreateIntergalacticDustInputForm } from '~/dialogs/View/Galaxy/View/CreateIntergalacticDust/Input/Form/hooks';
import { useViewGalaxyViewCreateInterstellarMediumInputForm } from '~/dialogs/View/Galaxy/View/CreateInterstellarMedium/Input/Form/hooks';
import { useViewGalaxyViewGroupDiscovererAstronomerLinkSetSelectorPage } from '~/dialogs/View/Galaxy/View/Group/Discoverer/Astronomer/LinkSetSelectorPage/hooks';
import { useCRUDDialog, useSnacks, useViewData } from '~/hooks';
import { useCRUDDialog, useEventBus, useSnacks, useViewData } from '~/hooks';
import { routeToViewGalaxyAstronomerRelationViewPage } from '~/routes';
import { routeToViewGalaxyMatterRelationTablePage } from '~/routes';
import type { JudoIdentifiable } from '~/services/data-api/common/JudoIdentifiable';
Expand Down Expand Up @@ -61,7 +61,8 @@ const ViewGalaxyViewPageContainer = lazy(() => import('~/containers/View/Galaxy/
// XMIID: God/(esm/_4pyPkM_cEe6fibzd7gNETg)/AccessViewPageDefinition
// Name: God::God::galaxies::AccessViewPage
export default function GodGodGalaxiesAccessViewPage() {
const dataPath = '';
const dataPath: string = '';
const rootPageId: string | undefined = undefined;
const isDraft = false;
const owner = useRef<any>(null);

Expand All @@ -78,6 +79,7 @@ export default function GodGodGalaxiesAccessViewPage() {
const { openFilterDialog } = useFilterDialog();
const { openConfirmDialog } = useConfirmDialog();
const { setLatestViewData, setRouterPageData } = useViewData();
const { publish, subscribe } = useEventBus();
const handleError = useErrorHandler();
const openCRUDDialog = useCRUDDialog();
const { exportFile } = fileHandling();
Expand Down Expand Up @@ -221,6 +223,7 @@ export default function GodGodGalaxiesAccessViewPage() {
}
setData(result);
setLatestViewData(result);
publish('God/(esm/_4pyPkM_cEe6fibzd7gNETg)/AccessViewPageDefinition:refreshed', result);
setRouterPageData(result);
if (customActions?.postRefreshAction) {
await customActions?.postRefreshAction(result, storeDiff, setValidation);
Expand Down Expand Up @@ -445,6 +448,7 @@ export default function GodGodGalaxiesAccessViewPage() {
isDraft: true,
ownerValidation: validate,
dataPath: `${dataPath ? dataPath + '.' : ''}stars[${itemIndex!}]`,
rootPageId: rootPageId ?? 'God/(esm/_4pyPkM_cEe6fibzd7gNETg)/AccessViewPageDefinition',
});
// we might need to differentiate result handling between operation inputs and crud relation creates
if (result === 'submit-draft' && returnedData) {
Expand Down Expand Up @@ -574,6 +578,16 @@ export default function GodGodGalaxiesAccessViewPage() {
})();
}, []);

useEffect(() => {
const unsubscribe = subscribe('refresh:God/(esm/_4pyPkM_cEe6fibzd7gNETg)/AccessViewPageDefinition', async () => {
await refresh();
});

return () => {
unsubscribe();
};
}, [subscribe, data, editMode]);

return (
<ViewGalaxyViewViewModelContext.Provider value={viewModel}>
<Suspense>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { useViewPlanetViewGroup_2RightCreaturesPunishCreatureRelationTableCallSe
import { useViewPlanetViewGroup_2RightCreaturesRewardCreatureRelationTableCallSelector } from '~/dialogs/View/Planet/View/Group_2/Right/Creatures/RewardCreature/Relation/Table/CallSelector/hooks';
import { useViewPlanetViewGroup_2RightCreaturesTableAddSelectorPage } from '~/dialogs/View/Planet/View/Group_2/Right/Creatures/TableAddSelectorPage/hooks';
import { useViewPlanetViewGroup_2RightCreaturesTalkToGodRelationTableCallSelector } from '~/dialogs/View/Planet/View/Group_2/Right/Creatures/TalkToGod/Relation/Table/CallSelector/hooks';
import { useCRUDDialog, useSnacks, useViewData } from '~/hooks';
import { useCRUDDialog, useEventBus, useSnacks, useViewData } from '~/hooks';
import { routeToViewPlanetViewChooseTheMessiahOutputView } from '~/routes';
import { routeToViewPlanetViewHateGodOutputView } from '~/routes';
import { routeToViewPlanetViewLoveGodOutputView } from '~/routes';
Expand Down Expand Up @@ -57,7 +57,8 @@ const ViewPlanetViewPageContainer = lazy(() => import('~/containers/View/Planet/
// XMIID: God/(esm/_Hfxf0E7sEeycO-gUAWxcVg)/RelationFeatureView
// Name: View::Star::planets::RelationViewPage
export default function ViewStarPlanetsRelationViewPage() {
const dataPath = '';
const dataPath: string = '';
const rootPageId: string | undefined = undefined;
const isDraft = false;
const owner = useRef<any>(null);

Expand All @@ -74,6 +75,7 @@ export default function ViewStarPlanetsRelationViewPage() {
const { openFilterDialog } = useFilterDialog();
const { openConfirmDialog } = useConfirmDialog();
const { setLatestViewData, setRouterPageData } = useViewData();
const { publish, subscribe } = useEventBus();
const handleError = useErrorHandler();
const openCRUDDialog = useCRUDDialog();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { useGodGodGalaxiesAccessFormPage } from '~/dialogs/God/God/Galaxies/Acce
import { useViewGalaxyTableCreateDarkMatterInputForm } from '~/dialogs/View/Galaxy/Table/CreateDarkMatter/Input/Form/hooks';
import { useViewGalaxyTableCreateIntergalacticDustInputForm } from '~/dialogs/View/Galaxy/Table/CreateIntergalacticDust/Input/Form/hooks';
import { useViewGalaxyTableCreateInterstellarMediumInputForm } from '~/dialogs/View/Galaxy/Table/CreateInterstellarMedium/Input/Form/hooks';
import { useCRUDDialog, useSnacks, useViewData } from '~/hooks';
import { useCRUDDialog, useEventBus, useSnacks, useViewData } from '~/hooks';
import { routeToGodGodGalaxiesAccessViewPage } from '~/routes';
import type { JudoIdentifiable } from '~/services/data-api/common/JudoIdentifiable';
import { draftIdentifierPrefix } from '~/services/data-api/common/utils';
Expand All @@ -43,7 +43,8 @@ const ViewGalaxyTablePageContainer = lazy(() => import('~/containers/View/Galaxy
// XMIID: God/(esm/_4pyPkM_cEe6fibzd7gNETg)/AccessTablePageDefinition
// Name: God::God::galaxies::AccessTablePage
export default function GodGodGalaxiesAccessTablePage() {
const dataPath = '';
const dataPath: string = '';
const rootPageId: string | undefined = undefined;
const isDraft = false;
const owner = useRef<any>(null);

Expand All @@ -57,6 +58,7 @@ export default function GodGodGalaxiesAccessTablePage() {
const { openFilterDialog } = useFilterDialog();
const { openConfirmDialog } = useConfirmDialog();
const { setLatestViewData, setRouterPageData } = useViewData();
const { publish, subscribe } = useEventBus();
const handleError = useErrorHandler();
const openCRUDDialog = useCRUDDialog();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { useViewGalaxyViewCreateDarkMatterInputForm } from '~/dialogs/View/Galax
import { useViewGalaxyViewCreateIntergalacticDustInputForm } from '~/dialogs/View/Galaxy/View/CreateIntergalacticDust/Input/Form/hooks';
import { useViewGalaxyViewCreateInterstellarMediumInputForm } from '~/dialogs/View/Galaxy/View/CreateInterstellarMedium/Input/Form/hooks';
import { useViewGalaxyViewGroupDiscovererAstronomerLinkSetSelectorPage } from '~/dialogs/View/Galaxy/View/Group/Discoverer/Astronomer/LinkSetSelectorPage/hooks';
import { useCRUDDialog, useSnacks, useViewData } from '~/hooks';
import { useCRUDDialog, useEventBus, useSnacks, useViewData } from '~/hooks';
import { routeToViewGalaxyAstronomerRelationViewPage } from '~/routes';
import { routeToViewGalaxyMatterRelationTablePage } from '~/routes';
import type { JudoIdentifiable } from '~/services/data-api/common/JudoIdentifiable';
Expand Down Expand Up @@ -61,7 +61,8 @@ const ViewGalaxyViewPageContainer = lazy(() => import('~/containers/View/Galaxy/
// XMIID: God/(esm/_4pyPkM_cEe6fibzd7gNETg)/AccessViewPageDefinition
// Name: God::God::galaxies::AccessViewPage
export default function GodGodGalaxiesAccessViewPage() {
const dataPath = '';
const dataPath: string = '';
const rootPageId: string | undefined = undefined;
const isDraft = false;
const owner = useRef<any>(null);

Expand All @@ -78,6 +79,7 @@ export default function GodGodGalaxiesAccessViewPage() {
const { openFilterDialog } = useFilterDialog();
const { openConfirmDialog } = useConfirmDialog();
const { setLatestViewData, setRouterPageData } = useViewData();
const { publish, subscribe } = useEventBus();
const handleError = useErrorHandler();
const openCRUDDialog = useCRUDDialog();
const { exportFile } = fileHandling();
Expand Down Expand Up @@ -221,6 +223,7 @@ export default function GodGodGalaxiesAccessViewPage() {
}
setData(result);
setLatestViewData(result);
publish('God/(esm/_4pyPkM_cEe6fibzd7gNETg)/AccessViewPageDefinition:refreshed', result);
setRouterPageData(result);
if (customActions?.postRefreshAction) {
await customActions?.postRefreshAction(result, storeDiff, setValidation);
Expand Down Expand Up @@ -445,6 +448,7 @@ export default function GodGodGalaxiesAccessViewPage() {
isDraft: true,
ownerValidation: validate,
dataPath: `${dataPath ? dataPath + '.' : ''}stars[${itemIndex!}]`,
rootPageId: rootPageId ?? 'God/(esm/_4pyPkM_cEe6fibzd7gNETg)/AccessViewPageDefinition',
});
// we might need to differentiate result handling between operation inputs and crud relation creates
if (result === 'submit-draft' && returnedData) {
Expand Down Expand Up @@ -574,6 +578,16 @@ export default function GodGodGalaxiesAccessViewPage() {
})();
}, []);

useEffect(() => {
const unsubscribe = subscribe('refresh:God/(esm/_4pyPkM_cEe6fibzd7gNETg)/AccessViewPageDefinition', async () => {
await refresh();
});

return () => {
unsubscribe();
};
}, [subscribe, data, editMode]);

return (
<ViewGalaxyViewViewModelContext.Provider value={viewModel}>
<Suspense>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,4 +519,11 @@ public static String pageHookCallParams(PageDefinition pageDefinition) {
}
return String.join(", ", params);
}

public static boolean pageIsRootStateOwner(PageDefinition pageDefinition) {
return pageDefinition.getContainer().isView()
&& pageDefinition.getDataElement() instanceof RelationType relationType
&& relationType.getIsRefreshable()
&& (relationType.getIsMemberTypeAccess() || relationType.getIsRelationKindAssociation());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,11 @@ public static String tableButtonVisibilityConditions(Button button, Table table,
return result;
}
if (button.getActionDefinition().isIsBulk()) {
return "selectionModel.length > 0";
String result = "selectionModel.length > 0";
if (container.isView() && button.getActionDefinition().getIsCallOperationAction()) {
return result + " && !editMode";
}
return result;
}
return "true";
}
Expand Down
37 changes: 20 additions & 17 deletions judo-ui-react/src/main/resources/actor/src/App.tsx.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,33 @@ import { BreadcrumbProvider, MdiIcon } from './components';
import { DialogProvider } from './components/dialog';
import { Layout } from './layout';
import { ScrollToTop } from './layout/ScrollToTop';
import { EventBusProvider } from './hooks/EventBusContext';
{{# if application.authentication }}
import { PrincipalProvider } from './auth';
{{/ if }}

function App() {
return (
<ScrollToTop>
{{# if application.authentication }}
<PrincipalProvider>
{{/ if }}
<SnackbarProvider maxSnack={3} action={(snackbarId) => (
<IconButton className="close-error-snackbar" style={ { color: '#fff' } } onClick={() => closeSnackbar(snackbarId)}>
<MdiIcon path="close" />
</IconButton>
)}>
<DialogProvider>
<BreadcrumbProvider>
<Layout />
</BreadcrumbProvider>
</DialogProvider>
</SnackbarProvider>
{{# if application.authentication }}
</PrincipalProvider>
{{/ if }}
<EventBusProvider>
{{# if application.authentication }}
<PrincipalProvider>
{{/ if }}
<SnackbarProvider maxSnack={3} action={(snackbarId) => (
<IconButton className="close-error-snackbar" style={ { color: '#fff' } } onClick={() => closeSnackbar(snackbarId)}>
<MdiIcon path="close" />
</IconButton>
)}>
<DialogProvider>
<BreadcrumbProvider>
<Layout />
</BreadcrumbProvider>
</DialogProvider>
</SnackbarProvider>
{{# if application.authentication }}
</PrincipalProvider>
{{/ if }}
</EventBusProvider>
</ScrollToTop>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ interface {{ pageName page }}HookProps {
maskRequest?: string;
{{/ unless }}
dataPath?: string;
rootPageId?: string;
}

export const use{{ pageName page }} = (): ({ ownerData{{# and (isPageDataElementUnmappedSingle page) page.container.view }}, data{{/ and }}{{# if page.container.isRelationSelector }}, alreadySelected{{/ if }}{{# unless page.container.isSelector }}, templateDataOverride{{/ unless }}, ownerValidation, isDraft{{# unless page.container.table}}, maskRequest{{/ unless }}, dataPath }: {{ pageName page }}HookProps) => Promise<DialogResult<
export const use{{ pageName page }} = (): ({ ownerData{{# and (isPageDataElementUnmappedSingle page) page.container.view }}, data{{/ and }}{{# if page.container.isRelationSelector }}, alreadySelected{{/ if }}{{# unless page.container.isSelector }}, templateDataOverride{{/ unless }}, ownerValidation, isDraft{{# unless page.container.table}}, maskRequest{{/ unless }}, dataPath, rootPageId }: {{ pageName page }}HookProps) => Promise<DialogResult<
{{# if (pageHasOutputTarget page) }}
{{# if (pageHasOutputTarget page) }}{{ classDataName (getPageOutputTarget page) 'Stored' }}{{ else }}void{{/ if }}
{{ else }}
Expand All @@ -29,7 +30,7 @@ export const use{{ pageName page }} = (): ({ ownerData{{# and (isPageDataElement

const {{ pageName page }} = lazy(() => import('~/dialogs/{{ pagePath page }}'));

return ({ ownerData{{# and (isPageDataElementUnmappedSingle page) page.container.view }}, data{{/ and }}{{# if page.container.isRelationSelector }}, alreadySelected{{/ if }}{{# unless page.container.isSelector }}, templateDataOverride{{/ unless }}, ownerValidation, isDraft{{# unless page.container.table}}, maskRequest{{/ unless }}, dataPath }: {{ pageName page }}HookProps) => new Promise((resolve) => {
return ({ ownerData{{# and (isPageDataElementUnmappedSingle page) page.container.view }}, data{{/ and }}{{# if page.container.isRelationSelector }}, alreadySelected{{/ if }}{{# unless page.container.isSelector }}, templateDataOverride{{/ unless }}, ownerValidation, isDraft{{# unless page.container.table}}, maskRequest{{/ unless }}, dataPath, rootPageId }: {{ pageName page }}HookProps) => new Promise((resolve) => {
createDialog({
{{# if page.dialogSize }}
fullWidth: true,
Expand Down Expand Up @@ -60,6 +61,7 @@ export const use{{ pageName page }} = (): ({ ownerData{{# and (isPageDataElement
ownerValidation={ownerValidation}
{{/ unless }}
dataPath={dataPath}
rootPageId={rootPageId}
onClose={async () => {
await closeDialog();
resolve({
Expand Down
Loading

0 comments on commit 63f78ee

Please sign in to comment.