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
Moved Alertmanager Config & YAML to Admin -> Cluster Settings -> Global Configuration #3159
Moved Alertmanager Config & YAML to Admin -> Cluster Settings -> Global Configuration #3159
Conversation
dtaylor113
commented
Oct 30, 2019
@@ -143,7 +167,7 @@ class GlobalConfigPage_ extends React.Component<GlobalConfigPageProps, GlobalCon | |||
</div> | |||
<div className="co-m-table-grid__body"> | |||
{_.map(sortedItems, (item) => ( | |||
<ItemRow item={item} key={item.uid} /> | |||
<ItemRow item={item} key={_.get(item, 'uid')} /> |
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.
If we need to use _.get
, it means not everything has a UID, which means not all rows have keys. That's bad.
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.
fixed
const description = getResourceDescription(item.model); | ||
|
||
let resourceLink, menuItems, description; | ||
if (item.isK8Item !== false) { |
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.
This isn't the right place to have this logic. It would be better to pass in an item object with link
, actions
, and description
already set. Then the logic here is trivial. The way to build those items should be moved up to a higher level that already knows what kind of config link it's working with.
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.
fixed
b4c33cb
to
8f076c2
Compare
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.
Let's change the names of some of the item properties to be something more generic and only transform the config items once instead of twice.
usableConfigs.length > 0 ? _.sortBy(_.flatten(allItems), 'kind', 'asc') : items; | ||
|
||
let allItems = items.concat(usableConfigs); | ||
allItems = allItems |
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.
const allItems = [...items, ...usableConfgs].map((item) => {
const apiExplorerLink = `/api-resource/cluster/${referenceForModel(item.model)}`; | ||
const resourceLink = resourcePathFromModel(item.model, item.name, item.namespace); | ||
return { | ||
...item, |
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.
Don't pass more than is necessary. You should be able to remove this line. I would add a label
prop to the row items since kind
is not accurate when it's not a k8s resource.
label: item.kind,
id: item.uid,
path: resourceLink,
}; | ||
}) | ||
.concat({ | ||
kind: 'Alertmanager', |
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.
kind: 'Alertmanager', | |
label: 'Alertmanager', |
}) | ||
.concat({ | ||
kind: 'Alertmanager', | ||
uid: 'alertmanager', |
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.
This isn't a UID. Let's just call it id
uid: 'alertmanager', | |
id: 'alertmanager', |
kind: 'Alertmanager', | ||
uid: 'alertmanager', | ||
description: 'Configure grouping and routing of alerts', | ||
resourceLink: '/monitoring/alertmanagerconfig', |
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.
I'd call this path
instead of resourceLink
. It's not always a resource.
resourceLink: '/monitoring/alertmanagerconfig', | |
path: '/monitoring/alertmanagerconfig', |
|
||
let allItems = items.concat(usableConfigs); | ||
allItems = allItems | ||
.map((item) => { |
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're already mapping in componentDidMount
. We shouldn't transform it twice. move this logic there.
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.
Hi, moved all to componentDidMount
, thanks
8f076c2
to
916b11a
Compare
/retest |
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.
/approve
/lgtm
Thanks @dtaylor113, this looks cleaner
|
||
const globalConfigs = this.getGlobalConfigs(); | ||
const usableConfigs = globalConfigs | ||
.filter((item) => this.checkFlags(item)) |
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.
There's an edge case where the flags can change after the component mounts. We might have to keep the flags in the item and filter in render. We can address in a follow-on.
It looks like the tests need to be updated for this change. /lgtm cancel |
@dtaylor113 i believe the tests need to be updated for these changes |
916b11a
to
9e7ecb3
Compare
@spadgett, think this is ready to merge -thanks |
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.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dtaylor113, spadgett The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |