Skip to content
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(Single recommendation page): add Impacted column #340

Merged
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
1 change: 1 addition & 0 deletions compiled-lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"impact": "Impact",
"impactDescription": "The impact of the problem would be {level} if it occurred.",
"impactLevel": "{level} impact",
"impacted": "Impacted",
"important": "Important",
"insightsHeader": "Advisor",
"justificationNote": "Justification note",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,71 +7,80 @@
"last_checked_at": "2020-02-22T08:32:37.690Z",
"meta": {
"cluster_version": "3.0.3"
}
},
"impacted": "2022-06-13T22:00:00.000Z"
},
{
"cluster": "bcbd9c24-bf3f-4141-9a6c-019f5404164e",
"cluster_name": "",
"last_checked_at": "2020-02-22T08:32:37.690Z",
"meta": {
"cluster_version": "4.17.9"
}
},
"impacted": "2022-06-26T22:00:00.000Z"
},
{
"cluster": "685de527-ad9e-426c-a83f-07d797dd28e8",
"cluster_name": "foobar cluster",
"last_checked_at": "2022-05-22T08:32:37.690Z",
"meta": {
"cluster_version": ""
}
},
"impacted": "2022-06-22T22:00:00.000Z"
},
{
"cluster": "4bc920df-7935-4882-a946-e1e735439620",
"cluster_name": "",
"last_checked_at": "2020-02-22T08:32:37.690Z",
"meta": {
"cluster_version": "3.3.5"
}
},
"impacted": "2022-06-11T22:00:00.000Z"
},
{
"cluster": "41c30565-b4c9-49f2-a4ce-3277ad22b258",
"cluster_name": "",
"last_checked_at": "2020-02-22T08:32:37.690Z",
"meta": {
"cluster_version": "4.17.9"
}
},
"impacted": "2022-06-11T22:00:00.000Z"
},
{
"cluster": "6810f59e-c37c-420a-ae52-c23ccaccffc9",
"cluster_name": "custom cluster name 1",
"last_checked_at": "2021-04-02T08:32:37.690Z",
"meta": {
"cluster_version": "4.11.16"
}
},
"impacted": "2022-06-09T22:00:00.000Z"
},
{
"cluster": "5d5892d3-1f74-4ccf-22af-548dfc9767bb",
"cluster_name": "",
"last_checked_at": "2021-04-08T20:35:32.798Z",
"meta": {
"cluster_version": "4.8.2"
}
},
"impacted": "2022-06-28T22:00:00.000Z"
},
{
"cluster": "444cf4e5-a983-4894-9852-cb8b441b7006",
"cluster_name": "",
"last_checked_at": "2021-04-08T20:35:32.798Z",
"meta": {
"cluster_version": ""
}
},
"impacted": "2022-06-28T22:00:00.000Z"
},
{
"cluster": "00d404e4-9e83-46ee-9ddd-83c06fa65d67",
"cluster_name": "",
"last_checked_at": "2021-04-08T20:35:32.798Z",
"meta": {
"cluster_version": "4.9.5"
}
},
"impacted": "2022-06-01T22:00:00.000Z"
},
{
"cluster": "e73ee8b2-f60f-4bb0-abc7-be3093debfe7",
Expand All @@ -87,103 +96,116 @@
"last_checked_at": "2020-11-07T08:32:37.690Z",
"meta": {
"cluster_version": "4.18.12"
}
},
"impacted": ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the server will not respond with empty string but with the field missing

Copy link
Collaborator Author

@gkarat gkarat Jul 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are true, they marked it as optional, then this key can be possibly omitted. I'll rewrite the code so that it also considers missing "impacted"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ikerreyes, updated, PTAL

},
{
"cluster": "56f646b2-cf9f-46b2-9553-0e399465b966",
"cluster_name": "Cluster C",
"last_checked_at": "2021-04-08T20:35:32.798Z",
"meta": {
"cluster_version": "4.18.12"
}
},
"impacted": "2022-06-02T22:00:00.000Z"
},
{
"cluster": "e508506a-6cac-4925-9582-fdc0338e1020",
"cluster_name": "Cluster C",
"last_checked_at": "2021-04-08T20:35:32.798Z",
"meta": {
"cluster_version": "4.6.13"
}
},
"impacted": "2022-06-16T22:00:00.000Z"
},
{
"cluster": "bb7c5181-5464-4979-90de-135e38c8794a",
"cluster_name": "",
"last_checked_at": "2021-04-08T20:35:32.798Z",
"meta": {
"cluster_version": "4.5.0"
}
},
"impacted": "2022-06-28T22:00:00.000Z"
},
{
"cluster": "6367317a-5ffe-472c-a9dc-70d8a67485b4",
"cluster_name": "",
"last_checked_at": "2021-04-08T20:35:32.798Z",
"meta": {
"cluster_version": "4.12.8"
}
},
"impacted": "2022-06-21T22:00:00.000Z"
},
{
"cluster": "a7fc5b1a-d3f3-4103-91d3-f1cf560a1910",
"cluster_name": "",
"last_checked_at": "2021-04-08T20:35:32.798Z",
"meta": {
"cluster_version": "4.1.7"
}
},
"impacted": "2022-06-16T22:00:00.000Z"
},
{
"cluster": "40dbef1f-0382-4342-8e4e-c2bf299928c5",
"cluster_name": "",
"last_checked_at": "2021-07-16T12:00:00Z",
"meta": {
"cluster_version": "4.9.3"
}
},
"impacted": "2022-06-30T22:00:00.000Z"
},
{
"cluster": "96c55abf-db62-4e99-b01a-9331a757097f",
"cluster_name": "",
"last_checked_at": "2021-01-11T16:00:00Z",
"meta": {
"cluster_version": ""
}
},
"impacted": "2022-06-05T22:00:00.000Z"
},
{
"cluster": "dd2ef343-9131-46f5-8962-290fdfdf2199",
"cluster_name": "",
"last_checked_at": "2021-10-17T15:00:00Z",
"meta": {
"cluster_version": "4.1.18"
}
},
"impacted": "2022-06-11T22:00:00.000Z"
},
{
"cluster": "90f9a6ea-f79a-4d8d-a889-f0fb151aca5e",
"cluster_name": "",
"last_checked_at": "2021-04-08T20:35:32.798Z",
"meta": {
"cluster_version": "3.13.17"
}
},
"impacted": "2022-06-09T22:00:00.000Z"
},
{
"cluster": "ff41a4ee-aa2c-43a2-ac65-d5956252416d",
"cluster_name": "",
"last_checked_at": "2020-02-22T08:32:37.690Z",
"meta": {
"cluster_version": "4.14.14"
}
},
"impacted": "2022-06-17T22:00:00.000Z"
},
{
"cluster": "020cc0a1-6f1a-45fa-9780-3f4e74590902",
"cluster_name": "",
"last_checked_at": "2020-02-22T08:32:37.690Z",
"meta": {
"cluster_version": "3.7.15"
}
},
"impacted": "2022-06-30T22:00:00.000Z"
},
{
"cluster": "75400997-78fe-404e-a900-1c630bc3501d",
"cluster_name": "",
"last_checked_at": "2020-02-22T08:32:37.690Z",
"meta": {
"cluster_version": "4.9.14"
}
},
"impacted": "2022-06-16T22:00:00.000Z"
}
],
"disabled": [
Expand Down Expand Up @@ -214,4 +236,4 @@
]
},
"status": "ok"
}
}
19 changes: 12 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/AppConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,23 @@ export const RECS_LIST_COLUMNS_KEYS = [
export const AFFECTED_CLUSTERS_NAME_CELL = 1;
export const AFFECTED_CLUSTERS_VERSION_CELL = 2;
export const AFFECTED_CLUSTERS_LAST_SEEN_CELL = 3;
export const AFFECTED_CLUSTERS_IMPACTED_CELL = 4;
export const AFFECTED_CLUSTERS_COLUMNS = [
{
title: intl.formatMessage(messages.name),
transforms: [sortable, cellWidth(70)],
transforms: [sortable, cellWidth(60)],
},
{
title: intl.formatMessage(messages.version),
transforms: [sortable, cellWidth(15)],
transforms: [sortable],
},
{
title: intl.formatMessage(messages.lastSeen),
transforms: [sortable, cellWidth(15)],
transforms: [sortable],
},
{
title: intl.formatMessage(messages.impacted),
transforms: [sortable],
},
];
// TODO: remove since unused
Expand Down
27 changes: 27 additions & 0 deletions src/Components/AffectedClustersTable/AffectedClustersTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '../MessageState/EmptyStates';
import {
AFFECTED_CLUSTERS_COLUMNS,
AFFECTED_CLUSTERS_IMPACTED_CELL,
AFFECTED_CLUSTERS_LAST_SEEN_CELL,
AFFECTED_CLUSTERS_NAME_CELL,
AFFECTED_CLUSTERS_VERSION_CELL,
Expand Down Expand Up @@ -148,6 +149,7 @@ const AffectedClustersTable = ({ query, rule, afterDisableFn }) => {
r.cluster_name || r.cluster,
r.meta.cluster_version,
r.last_checked_at,
r.impacted,
],
};
});
Expand Down Expand Up @@ -182,6 +184,10 @@ const AffectedClustersTable = ({ query, rule, afterDisableFn }) => {
fst = new Date(a.cells[AFFECTED_CLUSTERS_LAST_SEEN_CELL] || 0);
snd = new Date(b.cells[AFFECTED_CLUSTERS_LAST_SEEN_CELL] || 0);
return fst > snd ? d : snd > fst ? -d : 0;
case AFFECTED_CLUSTERS_IMPACTED_CELL:
fst = new Date(a.cells[AFFECTED_CLUSTERS_IMPACTED_CELL] || 0);
snd = new Date(b.cells[AFFECTED_CLUSTERS_IMPACTED_CELL] || 0);
return fst > snd ? d : snd > fst ? -d : 0;
}
});
};
Expand Down Expand Up @@ -222,6 +228,27 @@ const AffectedClustersTable = ({ query, rule, afterDisableFn }) => {
</Tooltip>
)}
</span>,
<span key={r.id}>
{r.cells[AFFECTED_CLUSTERS_IMPACTED_CELL] ? (
<DateFormat
extraTitle={`${intl.formatMessage(messages.impacted)}: `}
date={r.cells[AFFECTED_CLUSTERS_IMPACTED_CELL]}
variant="relative"
/>
) : (
<Tooltip
key={r.id}
content={
<span>
{intl.formatMessage(messages.impacted) + ': '}
{intl.formatMessage(messages.nA)}
</span>
}
>
<span>{intl.formatMessage(messages.nA)}</span>
</Tooltip>
)}
</span>,
],
}));
};
Expand Down
Loading