Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -1781,10 +1781,15 @@ private void configureDatasetResolvers(final RuntimeWiring.Builder builder) {
.type(
"Incident",
typeWiring ->
typeWiring.dataFetcher(
"assignees",
new OwnerTypeBatchResolver(
ownerTypes, (env) -> ((Incident) env.getSource()).getAssignees())))
typeWiring
.dataFetcher(
"entity",
new EntityTypeResolver(
entityTypes, (env) -> ((Incident) env.getSource()).getEntity()))
.dataFetcher(
"assignees",
new OwnerTypeBatchResolver(
ownerTypes, (env) -> ((Incident) env.getSource()).getAssignees())))
.type(
"SchemaField",
typeWiring ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static Incident map(@Nullable QueryContext context, final EntityResponse
result.setSource(mapIncidentSource(context, info.getSource()));
}
if (info.hasStatus()) {
result.setIncidentStatus(mapStatus(context, info.getStatus()));
result.setStatus(mapStatus(context, info.getStatus()));
}
result.setCreated(AuditStampMapper.map(context, info.getCreated()));
Expand Down
6 changes: 6 additions & 0 deletions datahub-graphql-core/src/main/resources/incident.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ type Incident implements Entity {
"""
The status of an incident
"""
incidentStatus: IncidentStatus!

"""
The status of an incident
@deprecated, use incidentStatus instead
"""
status: IncidentStatus!

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ public void testGetSuccess() throws Exception {
assertEquals(incident.getDescription(), expectedInfo.getDescription());
assertEquals(incident.getCustomType(), expectedInfo.getCustomType());
assertEquals(
incident.getStatus().getState().toString(), expectedInfo.getStatus().getState().toString());
assertEquals(incident.getStatus().getMessage(), expectedInfo.getStatus().getMessage());
incident.getIncidentStatus().getState().toString(),
expectedInfo.getStatus().getState().toString());
assertEquals(incident.getIncidentStatus().getMessage(), expectedInfo.getStatus().getMessage());
assertEquals(
incident.getStatus().getLastUpdated().getTime(),
incident.getIncidentStatus().getLastUpdated().getTime(),
expectedInfo.getStatus().getLastUpdated().getTime());
assertEquals(
incident.getStatus().getLastUpdated().getActor(),
incident.getIncidentStatus().getLastUpdated().getActor(),
expectedInfo.getStatus().getLastUpdated().getActor().toString());
assertEquals(
incident.getSource().getType().toString(), expectedInfo.getSource().getType().toString());
Expand Down Expand Up @@ -308,20 +309,22 @@ public void testGetSuccessAllFilters() throws Exception {
assertEquals(incident.getDescription(), expectedInfo.getDescription());
assertEquals(incident.getCustomType(), expectedInfo.getCustomType());
assertEquals(
incident.getStatus().getState().toString(), expectedInfo.getStatus().getState().toString());
incident.getIncidentStatus().getState().toString(),
expectedInfo.getStatus().getState().toString());
assertEquals(
incident.getStatus().getStage().toString(), expectedInfo.getStatus().getStage().toString());
incident.getIncidentStatus().getStage().toString(),
expectedInfo.getStatus().getStage().toString());
assertEquals(incident.getPriority(), IncidentPriority.CRITICAL);
assertEquals(incident.getAssignees().size(), 1);
assertEquals(
((CorpUser) incident.getAssignees().get(0)).getUrn(),
expectedInfo.getAssignees().get(0).getActor().toString());
assertEquals(incident.getStatus().getMessage(), expectedInfo.getStatus().getMessage());
assertEquals(incident.getIncidentStatus().getMessage(), expectedInfo.getStatus().getMessage());
assertEquals(
incident.getStatus().getLastUpdated().getTime(),
incident.getIncidentStatus().getLastUpdated().getTime(),
expectedInfo.getStatus().getLastUpdated().getTime());
assertEquals(
incident.getStatus().getLastUpdated().getActor(),
incident.getIncidentStatus().getLastUpdated().getActor(),
expectedInfo.getStatus().getLastUpdated().getActor().toString());
assertEquals(
incident.getSource().getType().toString(), expectedInfo.getSource().getType().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,18 @@ public void testMap() throws Exception {
incident.getSource().getType().toString(),
com.linkedin.datahub.graphql.generated.IncidentSourceType.ASSERTION_FAILURE.toString());
assertEquals(incident.getSource().getSource().getUrn(), assertionUrn.toString());
assertEquals(
incident.getIncidentStatus().getState().toString(),
com.linkedin.datahub.graphql.generated.IncidentState.ACTIVE.toString());
assertEquals(
incident.getStatus().getState().toString(),
com.linkedin.datahub.graphql.generated.IncidentState.ACTIVE.toString());
assertEquals(
incident.getStatus().getStage().toString(),
incident.getIncidentStatus().getStage().toString(),
com.linkedin.datahub.graphql.generated.IncidentStage.INVESTIGATION.toString());
assertEquals(incident.getStatus().getMessage(), "This incident is open.");
assertEquals(incident.getStatus().getLastUpdated().getTime().longValue(), 1000L);
assertEquals(incident.getStatus().getLastUpdated().getActor(), userUrn.toString());
assertEquals(incident.getIncidentStatus().getMessage(), "This incident is open.");
assertEquals(incident.getIncidentStatus().getLastUpdated().getTime().longValue(), 1000L);
assertEquals(incident.getIncidentStatus().getLastUpdated().getActor(), userUrn.toString());
assertEquals(incident.getCreated().getTime().longValue(), 1000L);
assertEquals(incident.getCreated().getActor(), userUrn.toString());
assertEquals(incident.getAssignees().size(), 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ public void testBatchLoad() throws Exception {
assertEquals(incident.getDescription(), TEST_INCIDENT_INFO.getDescription());
assertEquals(incident.getCustomType(), TEST_INCIDENT_INFO.getCustomType());
assertEquals(
incident.getStatus().getState().toString(),
incident.getIncidentStatus().getState().toString(),
TEST_INCIDENT_INFO.getStatus().getState().toString());
assertEquals(incident.getStatus().getMessage(), TEST_INCIDENT_INFO.getStatus().getMessage());
assertEquals(
incident.getStatus().getLastUpdated().getTime(),
incident.getIncidentStatus().getMessage(), TEST_INCIDENT_INFO.getStatus().getMessage());
assertEquals(
incident.getIncidentStatus().getLastUpdated().getTime(),
TEST_INCIDENT_INFO.getStatus().getLastUpdated().getTime());
assertEquals(
incident.getStatus().getLastUpdated().getActor(),
incident.getIncidentStatus().getLastUpdated().getActor(),
TEST_INCIDENT_INFO.getStatus().getLastUpdated().getActor().toString());
assertEquals(
incident.getSource().getType().toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,12 @@ export const IncidentTab = () => {

const hasData = (data?.entity as any)?.incidents;
const combinedData = (entityType === EntityType.Dataset && combineEntityDataWithSiblings(data)) || data;
const allIncidents =
const allIncidents: Incident[] =
(combinedData && (combinedData as any).entity?.incidents?.incidents?.map((incident) => incident as Incident)) ||
[];
const filteredIncidents = allIncidents.filter(
(incident) => !selectedIncidentState || incident.status?.state === selectedIncidentState,
(incident) => !selectedIncidentState || incident.incidentStatus?.state === selectedIncidentState,
);
const incidentList = filteredIncidents?.map((incident) => ({
urn: incident?.urn,
created: incident.created,
customType: incident.customType,
description: incident.description,
status: incident.status,
type: incident?.incidentType,
title: incident?.title,
}));

return (
<>
Expand Down Expand Up @@ -130,7 +121,7 @@ export const IncidentTab = () => {
/>
),
}}
dataSource={incidentList}
dataSource={filteredIncidents}
renderItem={(item: any) => <IncidentListItem refetch={refetch} incident={item} />}
/>
</IncidentList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import { useEntityRegistry } from '@app/useEntityRegistry';

import { useUpdateIncidentStatusMutation } from '@graphql/mutations.generated';
import { useGetUserQuery } from '@graphql/user.generated';
import { EntityType, IncidentState, IncidentType } from '@types';
import { EntityType, Incident, IncidentState, IncidentType } from '@types';

type Props = {
incident: any;
incident: Incident;
refetch?: () => Promise<any>;
};

Expand Down Expand Up @@ -154,17 +154,17 @@ export default function IncidentListItem({ incident, refetch }: Props) {

// Fetching the most recent actor's data.
const { data: createdActor } = useGetUserQuery({
variables: { urn: incident.created.actor, groupsCount: 0 },
variables: { urn: incident.created.actor || '', groupsCount: 0 },
fetchPolicy: 'cache-first',
});
const { data: lastUpdatedActor } = useGetUserQuery({
variables: { urn: incident.status.lastUpdated.actor, groupsCount: 0 },
variables: { urn: incident.incidentStatus?.lastUpdated.actor || '', groupsCount: 0 },
fetchPolicy: 'cache-first',
});

// Converting the created time into UTC
const createdDate = incident.created.time && new Date(incident.created.time);
const lastModifiedDate = incident.status.lastUpdated.time && new Date(incident.status.lastUpdated.time);
const createdDate = new Date(incident.created.time).getTime();
const lastModifiedDate = new Date(incident.incidentStatus?.lastUpdated.time || incident.created.time).getTime();

// Updating the incident status on button click
const updateIncidentStatus = (state: IncidentState, resolvedMessage: string) => {
Expand Down Expand Up @@ -223,19 +223,19 @@ export default function IncidentListItem({ incident, refetch }: Props) {
<TitleContainer>
<IncidentTitle>{incident.title}</IncidentTitle>
<IncidentTypeTag>
{incident.type === IncidentType.Custom
{incident.incidentType === IncidentType.Custom
? incident.customType
: getNameFromType(incident.type)}
: getNameFromType(incident.incidentType)}
</IncidentTypeTag>
</TitleContainer>
<DescriptionContainer>
<IncidentDescriptionLabel>Description</IncidentDescriptionLabel>
<MarkdownViewer source={incident?.description} />
{incident.status.state === IncidentState.Resolved ? (
<MarkdownViewer source={incident?.description || ''} />
{incident.incidentStatus?.state === IncidentState.Resolved ? (
<>
<IncidentDescriptionLabel>Resolution Note</IncidentDescriptionLabel>
<IncidentDescriptionText>
{incident?.status?.message || 'No additional details'}
{incident?.incidentStatus?.message || 'No additional details'}
</IncidentDescriptionText>
</>
) : null}
Expand All @@ -259,22 +259,24 @@ export default function IncidentListItem({ incident, refetch }: Props) {
</DescriptionContainer>
</div>
</IncidentHeaderContainer>
{incident.status.state === IncidentState.Resolved ? (
{incident.incidentStatus?.state === IncidentState.Resolved ? (
<IncidentResolvedTextContainer>
<Popover
overlayStyle={{ maxWidth: 240 }}
placement="left"
title={<Typography.Text strong>Note</Typography.Text>}
content={
incident?.status?.message === null ? (
incident?.incidentStatus?.message === null ? (
<Typography.Text type="secondary">No additional details</Typography.Text>
) : (
<Typography.Text type="secondary">{incident?.status?.message}</Typography.Text>
<Typography.Text type="secondary">
{incident?.incidentStatus?.message}
</Typography.Text>
)
}
>
<IncidentResolvedText>
{incident?.status?.lastUpdated && (
{incident?.incidentStatus?.lastUpdated && (
<Tooltip showArrow={false} title={toLocalDateTimeString(lastModifiedDate)}>
Resolved {toRelativeTimeString(lastModifiedDate)} by{' '}
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const getIncidentsStatusSummary = (incidents: Array<Incident>) => {
};
incidents.forEach((assertion) => {
if (incidents.length) {
const resultType = assertion.status.state;
const resultType = assertion.incidentStatus?.state;
if (IncidentState.Active === resultType) {
summary.activeIncident++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import handleGraphQLError from '@src/app/shared/handleGraphQLError';
import { useRaiseIncidentMutation, useUpdateIncidentMutation } from '@src/graphql/mutations.generated';
import { EntityType, IncidentSourceType, IncidentState } from '@src/types.generated';

import { IncidentResultFieldsFragment } from '@graphql/incident.generated';

export const getCacheIncident = ({
values,
responseData,
Expand All @@ -21,8 +23,9 @@ export const getCacheIncident = ({
responseData?: any;
user?: any;
incidentUrn?: string;
}) => {
const newIncident = {
}): IncidentResultFieldsFragment['incidents'][number] => {
const firstLinkedAsset = values.linkedAssets?.[0] || {};
const newIncident: IncidentResultFieldsFragment['incidents'][number] = {
__typename: 'Incident',
urn: incidentUrn ?? responseData?.data?.raiseIncident,
type: EntityType.Incident,
Expand All @@ -43,6 +46,17 @@ export const getCacheIncident = ({
actor: user?.urn,
},
},
incidentStatus: {
__typename: 'IncidentStatus',
state: values?.state,
stage: values?.stage,
message: values?.message || null,
lastUpdated: {
__typename: 'AuditStamp',
time: Date.now(),
actor: user?.urn,
},
},
source: {
__typename: 'IncidentSource',
type: IncidentSourceType.Manual,
Expand All @@ -64,6 +78,10 @@ export const getCacheIncident = ({
actor: user?.urn,
},
assignees: values.assignees,
entity: {
__typename: firstLinkedAsset.type,
...firstLinkedAsset,
},
};
return newIncident;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ describe('Utility Functions', () => {
const incidents: any = [
{
title: 'Incident 1',
status: { stage: 'WorkInProgress' },
incidentStatus: { stage: 'WorkInProgress' },
incidentType: 'DATASET_COLUMN',
priority: 'High',
type: 'INCIDENT',
},
{
title: 'Incident 2',
status: { stage: 'Closed' },
incidentStatus: { stage: 'Closed' },
incidentType: 'DATASET_COLUMN_1',
priority: 'Low',
type: 'INCIDENT',
Expand Down
Loading
Loading