Skip to content

Commit

Permalink
show full json
Browse files Browse the repository at this point in the history
  • Loading branch information
Nalin Patidar authored and Nalin Patidar committed Nov 8, 2024
1 parent 7d70f13 commit 4044ca4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
27 changes: 6 additions & 21 deletions thirdeye-ui/src/app/pages/namespace-configuration/api/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,13 @@ import { useNotificationProviderV1 } from "../../../platform/components";
import { useTranslation } from "react-i18next";
import { WorkspaceConfiguration } from "../../../rest/dto/workspace.interfaces";

type namespaceConfig = {
timezone: string | undefined;
dateTimePattern: string | undefined;
};

type WorkspaceApiReques = {
isError: boolean;
isLoading: boolean;
isUpdateDisabled: boolean;
namespaceConfig: namespaceConfig;
namespaceConfig: WorkspaceConfiguration | null;
workspaceConfiguration: WorkspaceConfiguration | null;
setNamespaceConfig: (config: namespaceConfig) => void;
setNamespaceConfig: (config: WorkspaceConfiguration) => void;
getWorkspaceConfiguration: () => Promise<
WorkspaceConfiguration | undefined
>;
Expand All @@ -49,10 +44,8 @@ type WorkspaceApiReques = {
};

export const useWorkspaceApiRequests = (): WorkspaceApiReques => {
const [namespaceConfig, setNamespaceConfig] = useState<namespaceConfig>({
timezone: "",
dateTimePattern: "",
});
const [namespaceConfig, setNamespaceConfig] =
useState<WorkspaceConfiguration | null>(null);

const { notify } = useNotificationProviderV1();
const { t } = useTranslation();
Expand Down Expand Up @@ -82,11 +75,7 @@ export const useWorkspaceApiRequests = (): WorkspaceApiReques => {

useEffect(() => {
if (!isEmpty(workspaceConfiguration)) {
setNamespaceConfig({
timezone: workspaceConfiguration?.timeConfiguration.timezone,
dateTimePattern:
workspaceConfiguration?.timeConfiguration.dateTimePattern,
});
setNamespaceConfig(workspaceConfiguration);
}
}, [workspaceConfiguration]);

Expand Down Expand Up @@ -136,11 +125,7 @@ export const useWorkspaceApiRequests = (): WorkspaceApiReques => {
updateStatus === ActionStatus.Working ||
resetStaus === ActionStatus.Working;

const isUpdateDisabled = isEqual(namespaceConfig, {
dateTimePattern:
workspaceConfiguration?.timeConfiguration.dateTimePattern,
timezone: workspaceConfiguration?.timeConfiguration.timezone,
});
const isUpdateDisabled = isEqual(namespaceConfig, workspaceConfiguration);

return {
isError,
Expand Down
13 changes: 1 addition & 12 deletions thirdeye-ui/src/app/pages/namespace-configuration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const NamespaceConfiguration = (): JSX.Element => {
isUpdateDisabled,
namespaceConfig,
setNamespaceConfig,
workspaceConfiguration,
resetWorkspaceConfiguration,
updateWorkspaceConfiguration,
} = useWorkspaceApiRequests();
Expand All @@ -44,17 +43,7 @@ export const NamespaceConfiguration = (): JSX.Element => {
resetWorkspaceConfiguration();
};
const handleUpdate = async (): Promise<void> => {
const updatedNamespaceConfig = {
...workspaceConfiguration,
timeConfiguration: {
...workspaceConfiguration?.templateConfiguration,
timezone: namespaceConfig.timezone,
dateTimePattern: namespaceConfig.dateTimePattern,
},
};
updateWorkspaceConfiguration(
updatedNamespaceConfig as WorkspaceConfiguration
);
updateWorkspaceConfiguration(namespaceConfig as WorkspaceConfiguration);
};

return (
Expand Down

0 comments on commit 4044ca4

Please sign in to comment.