-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): show table constraint on table details page (#12163)
* feat(ui): show table constraint on table details page * chore: sync locale --------- Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com>
- Loading branch information
1 parent
d91a01a
commit df7f5a7
Showing
15 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
openmetadata-ui/src/main/resources/ui/src/assets/svg/section-line-large.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
openmetadata-ui/src/main/resources/ui/src/assets/svg/section-line-medium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
openmetadata-ui/src/main/resources/ui/src/assets/svg/straight-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
.../main/resources/ui/src/pages/TableDetailsPageV1/TableConstraints/ForeignKeyConstraint.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2023 Collate. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import Icon from '@ant-design/icons/lib/components/Icon'; | ||
import { Tooltip } from 'antd'; | ||
import { ReactComponent as IconForeignKey } from 'assets/svg/foriegnKey.svg'; | ||
import SectionLine from 'assets/svg/section-line-medium.svg'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
const ForeignKeyConstraint = () => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<div className="constraint-foreign-key"> | ||
<img | ||
className="foreign-key-section-line" | ||
src={SectionLine} | ||
width="100%" | ||
/> | ||
<Tooltip | ||
placement="bottom" | ||
title={t('label.foreign-key')} | ||
trigger="hover"> | ||
<Icon | ||
alt="foreign-key" | ||
className="foreign-key-icon" | ||
component={IconForeignKey} | ||
/> | ||
</Tooltip> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ForeignKeyConstraint; |
31 changes: 31 additions & 0 deletions
31
.../main/resources/ui/src/pages/TableDetailsPageV1/TableConstraints/PrimaryKeyConstraint.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2023 Collate. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import Icon from '@ant-design/icons/lib/components/Icon'; | ||
import { ReactComponent as IconKey } from 'assets/svg/icon-key.svg'; | ||
import StraightLine from 'assets/svg/straight-line.svg'; | ||
import React from 'react'; | ||
|
||
const PrimaryKeyConstraint = () => { | ||
return ( | ||
<div className="constraint-primary-key"> | ||
<img src={StraightLine} /> | ||
<Icon | ||
alt="primary-key" | ||
className="primary-key-icon" | ||
component={IconKey} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PrimaryKeyConstraint; |
77 changes: 77 additions & 0 deletions
77
.../src/main/resources/ui/src/pages/TableDetailsPageV1/TableConstraints/TableConstraints.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright 2023 Collate. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { Space, Typography } from 'antd'; | ||
import { ConstraintType, Table } from 'generated/entity/data/table'; | ||
import { isUndefined, map } from 'lodash'; | ||
import React, { FC, Fragment } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import ForeignKeyConstraint from './ForeignKeyConstraint'; | ||
import PrimaryKeyConstraint from './PrimaryKeyConstraint'; | ||
import './table-constraints.less'; | ||
|
||
interface TableConstraintsProps { | ||
constraints: Table['tableConstraints']; | ||
} | ||
|
||
const TableConstraints: FC<TableConstraintsProps> = ({ constraints }) => { | ||
const { t } = useTranslation(); | ||
|
||
if (isUndefined(constraints)) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Space className="p-b-sm" direction="vertical"> | ||
<Typography.Text className="right-panel-label"> | ||
{t('label.table-constraint')} | ||
</Typography.Text> | ||
{constraints.map(({ constraintType, columns, referredColumns }) => { | ||
if (constraintType === ConstraintType.PrimaryKey) { | ||
const columnsLength = (columns?.length ?? 0) - 1; | ||
|
||
return ( | ||
<Space className="constraint-columns"> | ||
{columns?.map((column, index) => ( | ||
<Fragment key={column}> | ||
<Typography.Text>{column}</Typography.Text> | ||
{index < columnsLength ? <PrimaryKeyConstraint /> : null} | ||
</Fragment> | ||
))} | ||
</Space> | ||
); | ||
} | ||
if (constraintType === ConstraintType.ForeignKey) { | ||
return ( | ||
<Space className="constraint-columns"> | ||
<ForeignKeyConstraint /> | ||
<Space direction="vertical" size={16}> | ||
<Typography.Text>{columns?.join(', ')}</Typography.Text> | ||
<div data-testid="referred-column-name"> | ||
{map(referredColumns, (referredColumn) => ( | ||
<Typography.Text className="truncate referred-column-name"> | ||
{referredColumn} | ||
</Typography.Text> | ||
))} | ||
</div> | ||
</Space> | ||
</Space> | ||
); | ||
} | ||
|
||
return null; | ||
})} | ||
</Space> | ||
); | ||
}; | ||
|
||
export default TableConstraints; |
54 changes: 54 additions & 0 deletions
54
...rc/main/resources/ui/src/pages/TableDetailsPageV1/TableConstraints/table-constraints.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2023 Collate. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
@import url('../../../styles/variables.less'); | ||
|
||
.constraint-columns { | ||
border-radius: 5px; | ||
background: @grey-1; | ||
padding: 16px; | ||
max-width: 300px; | ||
} | ||
.referred-column-name { | ||
display: block; | ||
max-width: 250px; | ||
} | ||
|
||
.constraint-primary-key { | ||
position: relative; | ||
.primary-key-icon { | ||
position: absolute; | ||
transform: translate(36px, -8px); | ||
background: white; | ||
height: 20px; | ||
width: 20px; | ||
border-radius: 50%; | ||
border: @global-border; | ||
padding: 2px; | ||
} | ||
} | ||
|
||
.constraint-foreign-key { | ||
position: relative; | ||
.foreign-key-section-line { | ||
margin-top: 20px; | ||
} | ||
.foreign-key-icon { | ||
background: white; | ||
height: 20px; | ||
width: 20px; | ||
border-radius: 50%; | ||
border: @global-border; | ||
padding: 2px; | ||
transform: translate(-7px, -31px); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters