Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions src/components/ModelsSidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Col, Row, Space } from "antd";
import { PlusOutlined, ReloadOutlined } from "@ant-design/icons";
import { PlusOutlined } from "@ant-design/icons";
import { useTranslation } from "react-i18next";
import cn from "classnames";

Expand All @@ -14,7 +14,6 @@ import VersionPreview from "@/components/VersionPreview";
import BranchSelection from "@/components/BranchSelection";
import type { Branch, DataSourceInfo } from "@/types/dataSource";
import type { Dataschema } from "@/types/dataschema";
import { isSmartGenerated } from "@/utils/provenanceParser";

import TrashColoredIcon from "@/assets/trash-colored.svg";
import VerticalDots from "@/assets/dots-vertical.svg";
Expand Down Expand Up @@ -52,7 +51,6 @@ export interface ModelsSidebarProps {
onDataSourceChange: (dataSource: DataSourceInfo | null) => void;
versionsCount?: number;
onVersionsOpen?: () => void;
onReprofile?: (schema: Dataschema) => void;
}

const icons = {
Expand Down Expand Up @@ -82,7 +80,6 @@ const ModelsSidebar: FC<ModelsSidebarProps> = ({
dataSourceId,
versionsCount,
onVersionsOpen,
onReprofile,
}) => {
const { t } = useTranslation(["models", "common"]);

Expand Down Expand Up @@ -221,24 +218,6 @@ const ModelsSidebar: FC<ModelsSidebarProps> = ({
align="center"
size={8}
>
{onReprofile && isSmartGenerated(f.code || "") && (
<button
className={styles.fileControl}
title="Re-profile"
onClick={(e) => {
e.stopPropagation();
onReprofile(f);
}}
style={{
background: "none",
border: "none",
cursor: "pointer",
padding: 0,
}}
>
<ReloadOutlined style={{ fontSize: 12 }} />
</button>
)}
<PopoverButton
className={styles.edit}
trigger={["click"]}
Expand Down
40 changes: 2 additions & 38 deletions src/pages/Models/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import useModelsIde from "@/hooks/useModelsIde";
import useSources from "@/hooks/useSources";
import useCubeRegistry from "@/hooks/useCubeRegistry";
import useCheckResponse from "@/hooks/useCheckResponse";
import { parseProvenance } from "@/utils/provenanceParser";
import calcChecksum from "@/utils/helpers/dataschemasChecksum";
import getTables from "@/utils/helpers/getTables";
import getCurrentBranch from "@/utils/helpers/getCurrentBranch";
Expand Down Expand Up @@ -101,8 +100,6 @@ interface ModelsProps {
onConnect: () => void;
versionsCount?: number;
onVersionsOpen?: () => void;
onReprofile?: (schema: Dataschema) => void;
reprofileTarget?: { table: string; schema: string } | null;
cubeRegistry?: CubeRegistry;
onRefreshRegistry?: () => void;
}
Expand Down Expand Up @@ -145,8 +142,6 @@ export const Models: React.FC<ModelsProps> = ({
onConnect,
versionsCount,
onVersionsOpen,
onReprofile,
reprofileTarget,
cubeRegistry,
onRefreshRegistry,
}) => {
Expand Down Expand Up @@ -269,7 +264,6 @@ export const Models: React.FC<ModelsProps> = ({
dataSourceId={dataSource?.id}
versionsCount={versionsCount}
onVersionsOpen={onVersionsOpen}
onReprofile={onReprofile}
/>
</Spin>
}
Expand Down Expand Up @@ -333,16 +327,8 @@ export const Models: React.FC<ModelsProps> = ({
branches={branches}
onComplete={onSmartGenComplete}
onCancel={onModalClose}
initialTable={
reprofileTarget?.table ??
smartGenQueryTarget?.table ??
undefined
}
initialSchema={
reprofileTarget?.schema ??
smartGenQueryTarget?.schema ??
undefined
}
initialTable={smartGenQueryTarget?.table ?? undefined}
initialSchema={smartGenQueryTarget?.schema ?? undefined}
/>
</Modal>
</>
Expand Down Expand Up @@ -427,13 +413,7 @@ const ModelsWrapper: React.FC = () => {
variables: { branch_id: currentBranch?.id },
});

const [reprofileTarget, setReprofileTarget] = useState<{
table: string;
schema: string;
} | null>(null);

const onModalClose = (goBack: boolean = false) => {
setReprofileTarget(null);
if (history.state && goBack) {
history.back();
} else {
Expand Down Expand Up @@ -643,20 +623,6 @@ const ModelsWrapper: React.FC = () => {
onModalClose(true);
};

const onReprofile = (fileSchema: Dataschema) => {
// Parse source table/schema from the model's provenance metadata
const provenance = parseProvenance(fileSchema.code || "");
if (provenance?.sourceTable && provenance?.sourceDatabase) {
setReprofileTarget({
table: provenance.sourceTable,
schema: provenance.sourceDatabase,
});
} else {
setReprofileTarget(null);
}
setLocation(`${basePath}/${curSource?.id}/${currentBranch?.id}/smartgen`);
};

const fetching =
version?.fetching ||
deleteMutation.fetching ||
Expand Down Expand Up @@ -1001,8 +967,6 @@ const ModelsWrapper: React.FC = () => {
`${basePath}/${curSource?.id}/${currentBranch?.id}/versions`
)
}
onReprofile={isClickHouse ? onReprofile : undefined}
reprofileTarget={reprofileTarget}
cubeRegistry={cubeRegistry}
onRefreshRegistry={refreshRegistry}
/>
Expand Down