Skip to content

Commit

Permalink
"feat(second clock) adding second clock to the status on the details …
Browse files Browse the repository at this point in the history
…page" (#259)

* feat(second clock) adding second clock to the status

* feat(second clock) adding second clock to the status

* feat(second clock) adding second clock to the status

* feat(second clock) adding second clock to the status

* feat(second clock) adding second clock to the status

* feat(second clock) adding second clock to the status

* feat(second clock) adding second clock to the status

* feat(second clock) adding second clock to the status

* feat(second clock) adding second clock to the status

* feat(second clock) condition refactored

* feat(second clock) adding second clock to the status

* feat(second clock) adding second clock to the status on the details page

* feat(second clock) adding second clock to the status on the details page

* feat(second clock) adding second clock to the status on the details page

* feat(second clock) State users should not see 2nd clock

* feat(second clock) State users should not see 2nd clock

* fix(Additional Subtext): changing the attachment instruction text

* feat(second clock) State users should not see 2nd clock

* feat(second clock) State users should not see 2nd clock

* feat(second clock) State users should not see 2nd clock

* feat(second clock) State users should not see 2nd clock

* feat(second clock) remove console log

* Use new utility

* Update condition

---------

Co-authored-by: Adewale Sangobiyi <[email protected]>
Co-authored-by: Adewale Sangobiyi <[email protected]>
Co-authored-by: Adewale Sangobiyi <[email protected]>
Co-authored-by: Adewale Sangobiyi <[email protected]>
Co-authored-by: Adewale Sangobiyi <[email protected]>
Co-authored-by: Adewale Sangobiyi <[email protected]>
Co-authored-by: Adewale Sangobiyi <[email protected]>
Co-authored-by: Adewale Sangobiyi <[email protected]>
Co-authored-by: Adewale Sangobiyi <[email protected]>
Co-authored-by: Adewale Sangobiyi <[email protected]>
Co-authored-by: Kevin Haube <[email protected]>
Co-authored-by: Kevin Haube <[email protected]>
  • Loading branch information
13 people authored Dec 22, 2023
1 parent 805d302 commit 787a8d9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
4 changes: 2 additions & 2 deletions docs/_deploy-metrics/lib/getMeanTimeToRecover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const getMeanTimeToRecover = async (branch: string) => {
return result;
};
const getMeanFromTimes = (times: { failedTime: Date; upTime: Date }[]) => {
if(times.length === 0) return 0;
if (times.length === 0) return 0;

return (
times.reduce((prev, current) => {
const diff = differenceInHours(current.upTime, current.failedTime);
Expand Down
17 changes: 14 additions & 3 deletions src/packages/shared-types/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { OsMainSourceItem } from "./opensearch";
import { CognitoUserAttributes } from "./user";
import { getLatestRai } from "shared-utils";
import { SEATOOL_STATUS } from "./statusHelper";
import { PlanType, PlanTypeCheck } from "./planType";

export enum Action {
ISSUE_RAI = "issue-rai",
Expand All @@ -12,6 +13,12 @@ export enum Action {
WITHDRAW_PACKAGE = "withdraw-package",
}

const secondClockStatuses = [
SEATOOL_STATUS.PENDING,
SEATOOL_STATUS.PENDING_APPROVAL,
SEATOOL_STATUS.PENDING_CONCURRENCE,
];

const checkStatus = (seatoolStatus: string, authorized: string | string[]) =>
typeof authorized === "string"
? seatoolStatus === authorized
Expand All @@ -21,16 +28,20 @@ export const ActionAvailabilityCheck = ({
seatoolStatus,
rais,
raiWithdrawEnabled,
planType,
}: OsMainSourceItem) => {
const latestRai = getLatestRai(rais);
return {
/** Is in any of our pending statuses, sans Pending-RAI **/
isInActivePendingStatus: checkStatus(seatoolStatus, [
SEATOOL_STATUS.PENDING,
...secondClockStatuses,
SEATOOL_STATUS.PENDING_OFF_THE_CLOCK,
SEATOOL_STATUS.PENDING_APPROVAL,
SEATOOL_STATUS.PENDING_CONCURRENCE,
]),
/** Is in a second clock status and RAI has been received **/
isInSecondClock:
!PlanTypeCheck(planType).is([PlanType.CHIP_SPA]) &&
checkStatus(seatoolStatus, secondClockStatuses) &&
latestRai?.status === "received",
/** Latest RAI is requested and status is Pending-RAI **/
hasRequestedRai:
latestRai?.status === "requested" &&
Expand Down
2 changes: 1 addition & 1 deletion src/services/api/handlers/packageActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export async function respondToRai(body: RaiResponse, rais: any) {
// Close pool
await pool.close();
}
console.log("heyo");

}

export async function withdrawPackage(body: WithdrawPackage) {
Expand Down
53 changes: 26 additions & 27 deletions src/services/ui/src/pages/detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import {
Alert,
Attachmentslist,
CardWithTopBorder,
ConfirmationModal,
DetailItemsGrid,
DetailsSection,
ErrorAlert,
LoadingSpinner,
RaiList,
ConfirmationModal,
} from "@/components";
import { useGetUser } from "@/api/useGetUser";
import {
Action,
ActionAvailabilityCheck,
ItemResult,
OsMainSourceItem,
PlanType,
PlanTypeCheck,
UserRoles,
SEATOOL_STATUS,
getStatus,
Action,
} from "shared-types";
import { useQuery } from "@/hooks";
import { useGetItem } from "@/api";
Expand All @@ -26,7 +29,7 @@ import { useGetPackageActions } from "@/api/useGetPackageActions";
import { PropsWithChildren, useState } from "react";
import { DETAILS_AND_ACTIONS_CRUMBS } from "@/pages/actions/actions-breadcrumbs";
import { API } from "aws-amplify";
import { DetailItemsGrid } from "@/components";
import { getStatus } from "shared-types/statusHelper";
import { spaDetails, submissionDetails } from "@/pages/detail/setup/spa";

const DetailCardWrapper = ({
Expand All @@ -42,24 +45,28 @@ const DetailCardWrapper = ({
</div>
</CardWithTopBorder>
);
const StatusCard = ({
status,
raiWithdrawEnabled,
}: {
status: string;
raiWithdrawEnabled: boolean;
}) => {
const transformedStatuses = getStatus(SEATOOL_STATUS.WITHDRAWN);
const StatusCard = (data: OsMainSourceItem) => {
const transformedStatuses = getStatus(data.seatoolStatus);
const checker = ActionAvailabilityCheck(data);
const { data: user } = useGetUser();

return (
<DetailCardWrapper title={"Status"}>
<div>
<h2 className="text-xl font-semibold">{status}</h2>
{raiWithdrawEnabled &&
!Object.values(transformedStatuses).includes(status) ? (
<em className="text-xs">
<h2 className="text-xl font-semibold">
{user?.isCms &&
!user.user?.["custom:cms-roles"].includes(UserRoles.HELPDESK)
? transformedStatuses.cmsStatus
: transformedStatuses.stateStatus}
</h2>
{checker.hasEnabledRaiWithdraw && (
<em className="text-xs my-4">
{"Withdraw Formal RAI Response - Enabled"}
</em>
) : null}
)}
{user?.isCms && checker.isInSecondClock && (
<span id="secondclock">2nd Clock</span>
)}
</div>
</DetailCardWrapper>
);
Expand Down Expand Up @@ -152,13 +159,8 @@ const PackageActionsCard = ({ id }: { id: string }) => {
};

export const DetailsContent = ({ data }: { data?: ItemResult }) => {
const { data: user } = useGetUser();
const { state } = useLocation();
if (!data?._source) return <LoadingSpinner />;
const status =
user?.isCms && !user.user?.["custom:cms-roles"].includes(UserRoles.HELPDESK)
? data._source.cmsStatus
: data._source.stateStatus;
return (
<div className="block md:flex">
<aside className="flex-none font-bold hidden md:block pr-8">
Expand Down Expand Up @@ -193,10 +195,7 @@ export const DetailsContent = ({ data }: { data?: ItemResult }) => {
id="package-overview"
className="sm:flex lg:grid lg:grid-cols-2 gap-4 my-6"
>
<StatusCard
status={status}
raiWithdrawEnabled={data._source?.raiWithdrawEnabled || false}
/>
<StatusCard {...data._source} />
<PackageActionsCard id={data._id} />
</section>
<h2 className="text-xl font-semibold mb-2">{"Package Details"}</h2>
Expand Down

0 comments on commit 787a8d9

Please sign in to comment.