-
Notifications
You must be signed in to change notification settings - Fork 961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat -- table owner categories #2260
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f20020b
owner category interface
B-T-D 76904d5
trailing newline
B-T-D dba3e26
linter
B-T-D 3d5142c
Add other_key_values field to User interface
B-T-D fb1762f
ts configs for owners section categories
B-T-D 22c622e
React component changes to render table owners grouped by category
B-T-D 0f9dff9
css margin zero for last child
B-T-D 0eca378
add title-3 to owner category
B-T-D dd09eed
text for no owner in category
B-T-D 8aa7fd7
linter
B-T-D File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -9,9 +9,11 @@ import AvatarLabel, { AvatarLabelProps } from 'components/AvatarLabel'; | |
import LoadingSpinner from 'components/LoadingSpinner'; | ||
import { ResourceType, UpdateMethod, UpdateOwnerPayload } from 'interfaces'; | ||
import { logClick, logAction } from 'utils/analytics'; | ||
import { getUserIdLabel } from 'config/config-utils'; | ||
import { getUserIdLabel, getOwnersSectionConfig } from 'config/config-utils'; | ||
|
||
import { EditableSectionChildProps } from 'components/EditableSection'; | ||
import InfoButton from 'components/InfoButton'; | ||
import { OwnerCategory } from 'interfaces/OwnerCategory'; | ||
|
||
import * as Constants from './constants'; | ||
|
||
|
@@ -33,6 +35,7 @@ export interface ComponentProps { | |
interface OwnerAvatarLabelProps extends AvatarLabelProps { | ||
link?: string; | ||
isExternal?: boolean; | ||
additionalOwnerInfo?: any; | ||
} | ||
|
||
export interface StateFromProps { | ||
|
@@ -238,21 +241,31 @@ export class OwnerEditor extends React.Component< | |
); | ||
}; | ||
|
||
render() { | ||
const { isEditing, readOnly, resourceType } = this.props; | ||
const { errorText, itemProps } = this.state; | ||
const hasItems = Object.keys(itemProps).length > 0; | ||
renderOwnersSection = (section: OwnerCategory | null) => { | ||
const { resourceType } = this.props; | ||
const { itemProps } = this.state; | ||
|
||
if (errorText) { | ||
return ( | ||
<div className="owner-editor-component"> | ||
<span className="status-message">{errorText}</span> | ||
</div> | ||
// check if rendering an owner category that lacks any entries | ||
let isEmptySection = false; | ||
|
||
if (section) { | ||
isEmptySection = Object.keys(itemProps).every( | ||
(key) => | ||
itemProps[key].additionalOwnerInfo.owner_category.toLowerCase() !== | ||
section.label.toLowerCase() | ||
); | ||
} | ||
|
||
const ownerList = hasItems ? ( | ||
return ( | ||
<ul className="component-list"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a css class to the |
||
{section ? ( | ||
<div> | ||
<span className="title-3">{section.label}</span> | ||
<InfoButton infoText={section.definition} /> | ||
</div> | ||
) : null} | ||
{isEmptySection ? <span className="body-3">None known</span> : null} | ||
|
||
{Object.keys(itemProps).map((key) => { | ||
const owner = itemProps[key]; | ||
const avatarLabel = React.createElement(AvatarLabel, owner); | ||
|
@@ -274,7 +287,12 @@ export class OwnerEditor extends React.Component< | |
{avatarLabel} | ||
</a> | ||
); | ||
} else { | ||
} else if ( | ||
(section && // if section, only render owner that matches category | ||
section.label.toLowerCase() === | ||
owner.additionalOwnerInfo.owner_category.toLowerCase()) || | ||
!section | ||
) { | ||
listItem = ( | ||
<Link | ||
to={owner.link} | ||
|
@@ -290,7 +308,37 @@ export class OwnerEditor extends React.Component< | |
return <li key={`list-item:${key}`}>{listItem}</li>; | ||
})} | ||
</ul> | ||
) : null; | ||
); | ||
}; | ||
|
||
renderOwnersList = () => { | ||
const sections = getOwnersSectionConfig().categories; | ||
|
||
if (sections.length > 0) { | ||
return ( | ||
<div> | ||
{sections.map((section) => this.renderOwnersSection(section))} | ||
</div> | ||
); | ||
} | ||
|
||
return this.renderOwnersSection(null); | ||
}; | ||
|
||
render() { | ||
const { isEditing, readOnly } = this.props; | ||
const { errorText, itemProps } = this.state; | ||
const hasItems = Object.keys(itemProps).length > 0; | ||
|
||
if (errorText) { | ||
return ( | ||
<div className="owner-editor-component"> | ||
<span className="status-message">{errorText}</span> | ||
</div> | ||
); | ||
} | ||
|
||
const ownerList = hasItems ? this.renderOwnersList() : null; | ||
|
||
return ( | ||
<div className="owner-editor-component"> | ||
|
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 |
---|---|---|
|
@@ -112,3 +112,12 @@ | |
} | ||
} | ||
} | ||
|
||
ul.component-list { | ||
margin-bottom: $spacer-1; | ||
|
||
&:last-child { | ||
margin-bottom: 0; | ||
} | ||
|
||
} |
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
7 changes: 7 additions & 0 deletions
7
frontend/amundsen_application/static/js/interfaces/OwnerCategory.ts
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,7 @@ | ||
// Copyright Contributors to the Amundsen project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export interface OwnerCategory { | ||
label: string; | ||
definition?: string; | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might want to consider doing some indication if there are no owners in a certain category. right now those titles look like floating text but isn't fully clear that it is an empty list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated -- i used the styling that FrequentUsers uses for "No frequent users exist": https://github.com/amundsen-io/amundsen/blob/main/frontend/amundsen_application/static/js/pages/TableDetailPage/FrequentUsers/index.tsx#L64