Skip to content

Commit

Permalink
refactor: improve code readability and structure in OnCallDutyPolicyE…
Browse files Browse the repository at this point in the history
…xecutionLog services and Feed components
  • Loading branch information
simlarsen committed Jan 15, 2025
1 parent ba0dd4f commit f0bc71b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
9 changes: 5 additions & 4 deletions Common/Server/Services/OnCallDutyPolicyExecutionLogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ export class Service extends DatabaseService<Model> {
}
}


protected override async onUpdateSuccess(
onUpdate: OnUpdate<Model>,
_updatedItemIds: Array<ObjectID>,
Expand Down Expand Up @@ -195,9 +194,11 @@ export class Service extends DatabaseService<Model> {
incidentId: onCalldutyPolicyExecutionLog.triggeredByIncidentId,
projectId: onCalldutyPolicyExecutionLog.projectId!,
incidentFeedEventType: IncidentFeedEventType.OnCallPolicy,
displayColor: onCalldutyPolicyExecutionLog.status ? this.getDisplayColorByStatus(
onCalldutyPolicyExecutionLog.status
) : Blue500,
displayColor: onCalldutyPolicyExecutionLog.status
? this.getDisplayColorByStatus(
onCalldutyPolicyExecutionLog.status,
)
: Blue500,
moreInformationInMarkdown: `**Status:** ${onCalldutyPolicyExecutionLog.status}
**Message:** ${onCalldutyPolicyExecutionLog.statusMessage}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ The on-call policy **${onCallDutyPolicyExecutionLogTimeline.onCallDutyPolicy.nam
_updatedItemIds: Array<ObjectID>,
): Promise<OnUpdate<Model>> {
if (onUpdate.updateBy.query) {

const updatedItems: Array<Model> = await this.findBy({
query: onUpdate.updateBy.query,
props: {
Expand All @@ -166,14 +165,11 @@ The on-call policy **${onCallDutyPolicyExecutionLogTimeline.onCallDutyPolicy.nam
skip: 0,
});

for(const updatedItem of updatedItems) {
for (const updatedItem of updatedItems) {
await this.addToIncidentFeed({
onCallDutyPolicyExecutionLogTimelineId: updatedItem.id as ObjectID,
});
}



}

return onUpdate;
Expand Down
9 changes: 6 additions & 3 deletions Common/UI/Components/Feed/Feed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FunctionComponent, ReactElement } from "react";
import FeedItem, { ComponentProps as FeedItemProps } from "./FeedItem";
import FeedItem, { FeedItemProps } from "./FeedItem";
import ErrorMessage from "../ErrorMessage/ErrorMessage";

export interface ComponentProps {
Expand All @@ -18,8 +18,11 @@ const Feed: FunctionComponent<ComponentProps> = (
<ErrorMessage message={props.noItemsMessage} />
</div>
)}
{props.items.map((item: FeedItemProps) => {
return <FeedItem {...item} />;
{props.items.map((item: FeedItemProps, index: number) => {
return <FeedItem {...item}

isLastItem={index === props.items.length - 1}
/>;
})}
</ul>
</div>
Expand Down
1 change: 0 additions & 1 deletion Common/UI/Components/Feed/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export interface FeedItemProps {
color: Color;
}


export interface ComponentProps extends FeedItemProps {
isLastItem?: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion Dashboard/src/Components/Incident/IncidentFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ListResult from "Common/UI/Utils/BaseDatabase/ListResult";
import ModelAPI from "Common/UI/Utils/ModelAPI/ModelAPI";
import SortOrder from "Common/Types/BaseDatabase/SortOrder";
import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
import { ComponentProps as FeedItemProps } from "Common/UI/Components/Feed/FeedItem";
import { FeedItemProps } from "Common/UI/Components/Feed/FeedItem";
import { Gray500 } from "Common/Types/BrandColors";
import IconProp from "Common/Types/Icon/IconProp";
import { ButtonStyleType } from "Common/UI/Components/Button/Button";
Expand Down

0 comments on commit f0bc71b

Please sign in to comment.