Skip to content

Commit

Permalink
fix: doc prop issues (#1513)
Browse files Browse the repository at this point in the history
* fix: showing doc prop btn when col desc

* fix: styling

* fix: no cll text

* feat: added saved sucessfully message

---------

Co-authored-by: anandgupta42 <93243293+anandgupta42@users.noreply.github.com>
  • Loading branch information
AdiGajbhiye and anandgupta42 authored Dec 10, 2024
1 parent ddda6f6 commit f9042e7
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const DocumentationPropagationButton = ({
const [allColumns, setAllColumns] = useState<DocsItem[]>([]);
const [currColumns, setCurrColumns] = useState<DocsItem[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [isSaved, setIsSaved] = useState(false);
const [tableMetadata, setTableMetadata] = useState<TableMetadata[]>([]);
const [testsMetadata, setTestsMetadata] = useState<Record<string, unknown>>(
{},
Expand All @@ -72,6 +73,7 @@ export const DocumentationPropagationButton = ({
setAllColumns([]);
setCurrColumns(startColumn);
setTableMetadata([]);
setIsSaved(false);
}, [currentDocsData?.uniqueId, name]);

const loadMoreDownstreamModels = async () => {
Expand Down Expand Up @@ -165,6 +167,7 @@ export const DocumentationPropagationButton = ({
}

await executeRequestInSync("saveDocumentationBulk", { models: req });
setIsSaved(true);
};

const setAllColumnsValue = (value: boolean) => {
Expand All @@ -183,6 +186,10 @@ export const DocumentationPropagationButton = ({
return null;
}

if (!currColumnDescription) {
return null;
}

return (
<Drawer
buttonProps={{ color: "primary", title: "Propagate documentation" }}
Expand All @@ -193,81 +200,91 @@ export const DocumentationPropagationButton = ({
>
<Stack direction="column" className="gap-0 mb-2">
<div className={styles.itemRow}>
<div className="fw-semibold">Model:</div>
<div>Model:</div>
<div>{currentDocsData?.name}</div>
</div>
<div className={styles.itemRow}>
<div className="fw-semibold">Column:</div>
<div>Column:</div>
<div>{name}</div>
</div>
{currColumnDescription && (
<div className={styles.itemRow}>
<div className="fw-semibold">Description:</div>
<div className={styles.colDesc}>
<div>Description:</div>
<div>{currColumnDescription}</div>
</div>
)}
</Stack>
<Stack className="mb-2">
<Button color="primary" onClick={() => setAllColumnsValue(true)}>
Select All
</Button>
<Button color="primary" onClick={() => setAllColumnsValue(false)}>
Unselect All
</Button>
</Stack>
<Stack direction="column" className="gap-md">
{allColumns.map((item) => {
const key = item.model + "/" + item.column;
return (
<Stack key={key} className={styles.itemCard}>
<Input
type="checkbox"
checked={selectedColumns[key]}
onChange={() =>
setSelectedColumns((prev) => ({
...prev,
[key]: !prev[key],
}))
}
/>
<Stack direction="column" className="gap-0 w-100">
<div className={styles.itemRow}>
<div>Model:</div>
<div>{item.model.split(".").pop()}</div>
</div>
<div className={styles.itemRow}>
<div>Column:</div>
<div>{item.column}</div>
</div>
<div className={styles.itemRow}>
<div>Description:</div>
<div>{item.description}</div>
</div>
</Stack>
</Stack>
);
})}
{currColumns.length > 0 && (
<Button
color="primary"
outline
onClick={loadMoreDownstreamModels}
disabled={isLoading}
>
Load 3 more downstream levels
</Button>
)}
<Button
color="primary"
disabled={
Object.values(selectedColumns).filter((v) => Boolean(v)).length ===
0
}
onClick={() => propagateDocumentation()}
>
Propagate documentation to selected models
</Button>
</Stack>
{!isLoading && allColumns.length === 0 ? (
<div className="mt-4">
No downstream column level lineage detected to propagate the
documentation
</div>
) : (
<>
<Stack className="mb-2">
<Button color="primary" onClick={() => setAllColumnsValue(true)}>
Select All
</Button>
<Button color="primary" onClick={() => setAllColumnsValue(false)}>
Unselect All
</Button>
</Stack>
<Stack direction="column" className="gap-md">
{allColumns.map((item) => {
const key = item.model + "/" + item.column;
return (
<Stack key={key} className={styles.itemCard}>
<Input
type="checkbox"
checked={selectedColumns[key]}
onChange={() =>
setSelectedColumns((prev) => ({
...prev,
[key]: !prev[key],
}))
}
/>
<Stack direction="column" className="gap-0 w-100">
<div className={styles.itemRow}>
<div>Model:</div>
<div>{item.model.split(".").pop()}</div>
</div>
<div className={styles.itemRow}>
<div>Column:</div>
<div>{item.column}</div>
</div>
<div className={styles.itemRow}>
<div>Description:</div>
<div>{item.description}</div>
</div>
</Stack>
</Stack>
);
})}
{currColumns.length > 0 && (
<Button
color="primary"
outline
onClick={loadMoreDownstreamModels}
disabled={isLoading}
>
Load 3 more downstream levels
</Button>
)}
<Button
color="primary"
disabled={
Object.values(selectedColumns).filter((v) => Boolean(v))
.length === 0
}
onClick={() => propagateDocumentation()}
>
Propagate documentation to selected models
</Button>
{isSaved && <div>Saved documentation successfully</div>}
</Stack>
</>
)}
</Drawer>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@
grid-template-columns: 1fr 3fr;

:nth-child(1) {
font-weight: 500;
font-weight: 600;
}

:nth-child(2) {
line-break: anywhere;
color: var(--text-grey2-color);
}
}

.colDesc {
:nth-child(1) {
font-weight: 600;
}

:nth-child(2) {
Expand Down

0 comments on commit f9042e7

Please sign in to comment.