From 08260e4759ed2db463daae935c969ad5589d153e Mon Sep 17 00:00:00 2001 From: Ayobami Akingbade Date: Thu, 30 Nov 2023 02:47:58 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(portal):=20add=20data=20detail?= =?UTF-8?q?s=20portal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/data/data-access/RDBMS.ts | 4 ++++ src/frontend/hooks/data/data.store.ts | 4 ++++ src/frontend/hooks/data/portal/index.ts | 1 + src/frontend/hooks/data/portal/main.ts | 6 ++++++ src/frontend/views/data/Details/index.tsx | 12 +++++++++++- src/frontend/views/data/Details/portal/index.ts | 1 + src/frontend/views/data/Details/portal/main.ts | 14 ++++++++++++++ src/frontend/views/data/Table/useTableMenuItems.ts | 2 +- src/shared/types/data.ts | 3 +++ 9 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/frontend/hooks/data/portal/index.ts create mode 100644 src/frontend/hooks/data/portal/main.ts create mode 100644 src/frontend/views/data/Details/portal/index.ts create mode 100644 src/frontend/views/data/Details/portal/main.ts diff --git a/src/backend/data/data-access/RDBMS.ts b/src/backend/data/data-access/RDBMS.ts index f344deb6f..fa348b689 100644 --- a/src/backend/data/data-access/RDBMS.ts +++ b/src/backend/data/data-access/RDBMS.ts @@ -107,6 +107,10 @@ export class RDBMSDataApiService extends BaseDataAccessService `/api/data/${entity}/table`; @@ -157,6 +158,7 @@ export function useEntityDataCreationMutation(entity: string) { ENTITY_TABLE_PATH(entity), ENTITY_COUNT_PATH(entity), ENTITY_LIST_PATH(entity), + ...DATA_MUTATION_QUERY_ENDPOINTS(entity), ], smartSuccessMessage: ({ id }) => ({ message: entityCrudConfig.MUTATION_LANG.CREATE, @@ -183,6 +185,7 @@ export function useEntityDataUpdationMutation(entity: string, id: string) { ENTITY_TABLE_PATH(entity), ENTITY_DETAILS_PATH(entity, id), ENTITY_LIST_PATH(entity), + ...DATA_MUTATION_QUERY_ENDPOINTS(entity), ], successMessage: entityCrudConfig.MUTATION_LANG.EDIT, }); @@ -207,6 +210,7 @@ export function useEntityDataDeletionMutation( ENTITY_TABLE_PATH(entity), ENTITY_COUNT_PATH(entity), ENTITY_LIST_PATH(entity), + ...DATA_MUTATION_QUERY_ENDPOINTS(entity), ], onSuccessActionWithFormData: () => { if (redirectTo) { diff --git a/src/frontend/hooks/data/portal/index.ts b/src/frontend/hooks/data/portal/index.ts new file mode 100644 index 000000000..a8454a19f --- /dev/null +++ b/src/frontend/hooks/data/portal/index.ts @@ -0,0 +1 @@ +export { DATA_MUTATION_QUERY_ENDPOINTS } from "./main"; diff --git a/src/frontend/hooks/data/portal/main.ts b/src/frontend/hooks/data/portal/main.ts new file mode 100644 index 000000000..0b0ff00cd --- /dev/null +++ b/src/frontend/hooks/data/portal/main.ts @@ -0,0 +1,6 @@ +import { noop } from "shared/lib/noop"; + +export const DATA_MUTATION_QUERY_ENDPOINTS = (entity: string) => { + noop(entity); + return []; +}; diff --git a/src/frontend/views/data/Details/index.tsx b/src/frontend/views/data/Details/index.tsx index fdbe33da3..b4875da01 100644 --- a/src/frontend/views/data/Details/index.tsx +++ b/src/frontend/views/data/Details/index.tsx @@ -14,6 +14,7 @@ import { EntityDetailsView } from "./DetailsView"; import { DetailsLayout, DETAILS_LAYOUT_KEY } from "./_Layout"; import { useCanUserPerformCrudAction } from "../useCanUserPerformCrudAction"; import { DetailsCanvas } from "../Table/_WholeEntityTable/DetailsCanvas"; +import { useDetailsViewMenuItems } from "./portal"; export function EntityDetails() { const entityCrudConfig = useEntityCrudConfig(); @@ -34,8 +35,17 @@ export function EntityDetails() { permission: META_USER_PERMISSIONS.NO_PERMISSION_REQUIRED, }); + const menuItems = useDetailsViewMenuItems({ + entity, + entityId: id, + }); + return ( - + { + const menuItems: IDropDownMenuItem[] = []; + noop(entity, entityId); + return menuItems; +}; diff --git a/src/frontend/views/data/Table/useTableMenuItems.ts b/src/frontend/views/data/Table/useTableMenuItems.ts index 589ca3f7e..58c1ee3c9 100644 --- a/src/frontend/views/data/Table/useTableMenuItems.ts +++ b/src/frontend/views/data/Table/useTableMenuItems.ts @@ -18,7 +18,7 @@ export const useTableMenuItems = ( const entityCrudConfig = useEntityCrudConfig(entity); const canUserPerformCrudAction = useCanUserPerformCrudAction(entity); - const pluginTableMenuItems = usePluginTableMenuItems(entity, reference); + const pluginTableMenuItems = usePluginTableMenuItems(entity); if (entity === SLUG_LOADING_VALUE) { return []; diff --git a/src/shared/types/data.ts b/src/shared/types/data.ts index 05e63f45c..bae12ebcb 100644 --- a/src/shared/types/data.ts +++ b/src/shared/types/data.ts @@ -1,3 +1,5 @@ +import { Knex } from "knex"; + export enum FilterOperators { GREATER_THAN = "g", LESS_THAN = "l", @@ -63,6 +65,7 @@ export type IPaginatedDataState = { export type QueryFilterSchema = { operator: "and" | "or"; children: Array; + modifyQuery?: (queryBuilder: Knex.QueryBuilder) => Knex.QueryBuilder; }; export type ITableTab = {