Skip to content

Commit

Permalink
✨ feat(portal): add data details portal
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed Nov 30, 2023
1 parent c58dd6a commit 08260e4
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/backend/data/data-access/RDBMS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export class RDBMSDataApiService extends BaseDataAccessService<Knex.QueryBuilder
queryFilter.operator === "and"
? query.where(builderQuery)
: query.orWhere(builderQuery);

if (queryFilter.modifyQuery) {
query = queryFilter.modifyQuery(query);
}
}
});
return query;
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/hooks/data/data.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { DataStates } from "frontend/lib/data/types";
import { useEntityCrudConfig } from "../entity/entity.config";
import { useMultipleEntityReferenceFields } from "../entity/entity.store";
import { isRouterParamEnabled } from "..";
import { DATA_MUTATION_QUERY_ENDPOINTS } from "./portal";

export const ENTITY_TABLE_PATH = (entity: string) =>
`/api/data/${entity}/table`;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
});
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/hooks/data/portal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DATA_MUTATION_QUERY_ENDPOINTS } from "./main";
6 changes: 6 additions & 0 deletions src/frontend/hooks/data/portal/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { noop } from "shared/lib/noop";

export const DATA_MUTATION_QUERY_ENDPOINTS = (entity: string) => {
noop(entity);
return [];
};
12 changes: 11 additions & 1 deletion src/frontend/views/data/Details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -34,8 +35,17 @@ export function EntityDetails() {
permission: META_USER_PERMISSIONS.NO_PERMISSION_REQUIRED,
});

const menuItems = useDetailsViewMenuItems({
entity,
entityId: id,
});

return (
<DetailsLayout entity={entity} menuKey={DETAILS_LAYOUT_KEY}>
<DetailsLayout
entity={entity}
menuKey={DETAILS_LAYOUT_KEY}
menuItems={menuItems}
>
<SectionBox
title={entityCrudConfig.TEXT_LANG.DETAILS}
backLink={backLink}
Expand Down
1 change: 1 addition & 0 deletions src/frontend/views/data/Details/portal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useDetailsViewMenuItems } from "./main";
14 changes: 14 additions & 0 deletions src/frontend/views/data/Details/portal/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { IDropDownMenuItem } from "frontend/design-system/components/DropdownMenu";
import { noop } from "shared/lib/noop";

export const useDetailsViewMenuItems = ({
entity,
entityId,
}: {
entity: string;
entityId: string;
}): IDropDownMenuItem[] => {
const menuItems: IDropDownMenuItem[] = [];
noop(entity, entityId);
return menuItems;
};
2 changes: 1 addition & 1 deletion src/frontend/views/data/Table/useTableMenuItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand Down
3 changes: 3 additions & 0 deletions src/shared/types/data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Knex } from "knex";

export enum FilterOperators {
GREATER_THAN = "g",
LESS_THAN = "l",
Expand Down Expand Up @@ -63,6 +65,7 @@ export type IPaginatedDataState<T> = {
export type QueryFilterSchema = {
operator: "and" | "or";
children: Array<FieldQueryFilter | QueryFilterSchema>;
modifyQuery?: (queryBuilder: Knex.QueryBuilder) => Knex.QueryBuilder;
};

export type ITableTab = {
Expand Down

0 comments on commit 08260e4

Please sign in to comment.