Skip to content

Commit

Permalink
fix: refactor names
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Jul 9, 2024
1 parent 8fc9052 commit b0411e5
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormContext, FormContextType } from "@/context/FormContext";
import { fetchAction } from "@/widgets/views/Dashboard/dashboardHelper";
import { ShortcutApi } from "@/ui/FavouriteButton";

export const useFormIndicatorData = (actionId: number) => {
export const useFormGraphData = (actionId: number) => {
const [error, setError] = useState<any>();
const [loading, setLoading] = useState<boolean>(true);
const [actionData, setActionData] = useState<any>();
Expand Down
8 changes: 3 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ import { CodeEditor } from "@/widgets/custom/CodeEditor";
import { CommentsTimelineField } from "@/widgets/custom/Comments";
import { HTMLPreview } from "@/widgets/custom/HTMLPreview";
import { Alert } from "@/widgets/custom/Alert";
import {
DashboardGridItem,
DashboardGrid,
} from "@/widgets/views/DashboardGrid";
import { DashboardGrid } from "@/widgets/views/DashboardGrid";
import { GraphIndicator } from "@/widgets/views/Graph/GraphIndicator";

import type {
Expand Down Expand Up @@ -88,6 +85,7 @@ import Tab from "./views/tabs/Tab";
import ActionView from "./views/ActionView";
import { ErpAllFeatureKeys, ErpFeatureKeys } from "./models/erpFeature";
import type { ErpFeaturesMap } from "./models/erpFeature";
import { GraphCard } from "./widgets/views/Graph";

export {
Button,
Expand Down Expand Up @@ -154,7 +152,7 @@ export {
FavouriteButton,
Dashboard,
GraphIndicator,
DashboardGridItem,
GraphCard,
DashboardGrid,
Tags,
Tag,
Expand Down
16 changes: 5 additions & 11 deletions src/stories/dashboard/DashboardGrid.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { DashboardGridItem, DashboardGrid, GraphIndicator } from "../..";
import { GraphCard, DashboardGrid, GraphIndicator } from "../..";

import LocaleProvider from "../../context/LocaleContext";

Expand All @@ -11,10 +11,7 @@ export function Default(): React.ReactElement {
return (
<LocaleProvider lang="en_US">
<DashboardGrid>
<DashboardGridItem
title="test"
parms={{ w: 3, h: 9, x: 0, y: 0, id: 10 }}
>
<GraphCard title="test" parms={{ w: 3, h: 9, x: 0, y: 0, id: 10 }}>
<GraphIndicator
model="res.partner"
context={{}}
Expand All @@ -23,11 +20,8 @@ export function Default(): React.ReactElement {
showPercent={true}
// suffix={"€"}
/>
</DashboardGridItem>
<DashboardGridItem
title="test"
parms={{ w: 3, h: 9, x: 0, y: 0, id: 10 }}
>
</GraphCard>
<GraphCard title="test" parms={{ w: 3, h: 9, x: 0, y: 0, id: 10 }}>
<GraphIndicator
model="res.partner"
context={{}}
Expand All @@ -36,7 +30,7 @@ export function Default(): React.ReactElement {
showPercent={true}
// suffix={"€"}
/>
</DashboardGridItem>
</GraphCard>
</DashboardGrid>
</LocaleProvider>
);
Expand Down
10 changes: 5 additions & 5 deletions src/widgets/custom/Indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { WidgetProps } from "@/types";
import Field from "@/common/Field";
import { QuestionCircleOutlined } from "@ant-design/icons";
import iconMapper from "@/helpers/iconMapper";
import { useFormIndicatorData } from "@/hooks/useFormIndicatorData";
import { useFormGraphData } from "@/hooks/useFormGraphData";
import { CenteredSpinner } from "@/ui/CenteredSpinner";
import { ErrorAlert } from "@/ui/ErrorAlert";
import { Graph } from "../views/Graph/Graph";
import ErrorBoundary from "antd/es/alert/ErrorBoundary";
import { useFeatureIsEnabled } from "@/context/ConfigContext";
import { ErpFeatureKeys } from "@/models/erpFeature";
import { GraphServer } from "../views/Graph/GraphServer";
import { DashboardGridItem } from "../views/DashboardGrid";
import {
TabManagerContext,
TabManagerContextType,
} from "@/context/TabManagerContext";
import { GraphCard } from "../views/Graph";
const { useToken } = theme;

type IndicatorProps = WidgetProps & {
Expand Down Expand Up @@ -91,7 +91,7 @@ const GraphIndicatorInput = (props: IndicatorInputProps) => {
const { actionId } = ooui;

const { actionData, treeShortcut, loading, error } =
useFormIndicatorData(actionId);
useFormGraphData(actionId);
const readForViewEnabled = useFeatureIsEnabled(
ErpFeatureKeys.FEATURE_READFORVIEW,
);
Expand All @@ -113,7 +113,7 @@ const GraphIndicatorInput = (props: IndicatorInputProps) => {
const GraphComponent = readForViewEnabled ? GraphServer : Graph;

return (
<DashboardGridItem
<GraphCard
id={id}
parms={{}}
title={actionData.title}
Expand All @@ -127,6 +127,6 @@ const GraphIndicatorInput = (props: IndicatorInputProps) => {
domain={domain}
limit={limit}
/>
</DashboardGridItem>
</GraphCard>
);
};
8 changes: 4 additions & 4 deletions src/widgets/views/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { fetchAction } from "./dashboardHelper";
import "react-resizable/css/styles.css";
import "react-grid-layout/css/styles.css";
import { Graph } from "../Graph/Graph";
import { DashboardGrid, DashboardGridItem } from "../DashboardGrid";
import { DashboardGrid } from "../DashboardGrid";
import ConnectionProvider from "@/ConnectionProvider";
import { DashboardProps, FormView } from "@/types";
import { ErpFeatureKeys, One2manyItem } from "@/index";
import { ErpFeatureKeys, GraphCard, One2manyItem } from "@/index";
import { readObjectValues } from "@/helpers/one2manyHelper";
import { LoadingOutlined } from "@ant-design/icons";
import { Alert } from "antd";
Expand Down Expand Up @@ -387,7 +387,7 @@ function Dashboard(props: DashboardProps, ref: any) {
}

return (
<DashboardGridItem
<GraphCard
key={`griditem-${id}`}
id={id}
title={title}
Expand All @@ -396,7 +396,7 @@ function Dashboard(props: DashboardProps, ref: any) {
openAction={openAction}
>
{childContent}
</DashboardGridItem>
</GraphCard>
);
})}
</DashboardGrid>
Expand Down
2 changes: 0 additions & 2 deletions src/widgets/views/DashboardGrid/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from "./DashboardGrid";
export * from "./DashboardGridItem";
export * from "./DashboardGrid.types";
export * from "./DashboardGridItem.types";
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { DashboardGridItemProps } from "./DashboardGridItem.types";
import { ExportOutlined } from "@ant-design/icons";
import { Row, Col, Typography, theme } from "antd";
import ErrorBoundary from "antd/es/alert/ErrorBoundary";
import { GraphCardProps } from "./GraphCard.types";
const { useToken } = theme;

const { Text } = Typography;

export const DashboardGridItem = (props: DashboardGridItemProps) => {
export const GraphCard = (props: GraphCardProps) => {
const { title, children, action, openAction, parms } = props;
const { token } = useToken();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ShortcutApi } from "@/ui/FavouriteButton";

export type DashboardGridItemProps = {
export type GraphCardProps = {
title: string;
id: string;
children?: React.ReactNode;
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/views/Graph/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./GraphCard";
export * from "./GraphCard.types";

0 comments on commit b0411e5

Please sign in to comment.