From ef56b35e0164a36535d5361ec54a56e51a188210 Mon Sep 17 00:00:00 2001 From: okanji Date: Mon, 27 Nov 2023 15:26:45 -0800 Subject: [PATCH 1/7] added async to nats message --- nats/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nats/index.ts b/nats/index.ts index c0aded427..f3f6e3b2b 100644 --- a/nats/index.ts +++ b/nats/index.ts @@ -53,10 +53,10 @@ export async function sendPrivateCloudNatsMessage( const messageBody = createPrivateCloudNatsMessage(requestId, requestType, requestedProject, contactChanged); - return sendNatsMessage(natsSubject, messageBody); + await sendNatsMessage(natsSubject, messageBody); } -export function sendPublicCloudNatsMessage( +export async function sendPublicCloudNatsMessage( requestType: RequestType, requestedProject: PublicCloudRequestedProjectWithContacts, currentProject?: PublicCloudProjectWithContacts | null, @@ -65,5 +65,5 @@ export function sendPublicCloudNatsMessage( const messageBody = createPublicCloudNatsMessage(requestType, requestedProject, currentProject); - return sendNatsMessage(natsSubject, messageBody); + await sendNatsMessage(natsSubject, messageBody); } From 10fe62901914c1ee8b1e220f7c6852ddcc5f8ef3 Mon Sep 17 00:00:00 2001 From: okanji Date: Mon, 27 Nov 2023 15:33:25 -0800 Subject: [PATCH 2/7] removed unused console logs --- app/(dashboard)/private-cloud/products/page.tsx | 1 - app/(dashboard)/private-cloud/requests/page.tsx | 1 - app/(dashboard)/public-cloud/products/page.tsx | 1 - app/(dashboard)/public-cloud/requests/page.tsx | 1 - app/(request)/public-cloud/decision/[licencePlate]/page.tsx | 6 ------ app/api/private-cloud/requests/route.ts | 2 -- app/authExample/page.tsx | 1 - ches/index.ts | 1 - components/form/CommonComponentsTemp.tsx | 1 - emails/templates/EditRequestTemplate.tsx | 2 +- 10 files changed, 1 insertion(+), 16 deletions(-) diff --git a/app/(dashboard)/private-cloud/products/page.tsx b/app/(dashboard)/private-cloud/products/page.tsx index 6ac9a139f..da95ce926 100644 --- a/app/(dashboard)/private-cloud/products/page.tsx +++ b/app/(dashboard)/private-cloud/products/page.tsx @@ -35,7 +35,6 @@ export default async function ProductsTable({ const session = await getServerSession(authOptions); if (!session) { - console.log('No session found'); redirect('/login?callbackUrl=/private-cloud/products'); } diff --git a/app/(dashboard)/private-cloud/requests/page.tsx b/app/(dashboard)/private-cloud/requests/page.tsx index d741cd133..92a59f953 100644 --- a/app/(dashboard)/private-cloud/requests/page.tsx +++ b/app/(dashboard)/private-cloud/requests/page.tsx @@ -37,7 +37,6 @@ export default async function RequestsTable({ const session = await getServerSession(authOptions); if (!session) { - console.log('No session found'); redirect('/login?callbackUrl=/private-cloud/products'); } diff --git a/app/(dashboard)/public-cloud/products/page.tsx b/app/(dashboard)/public-cloud/products/page.tsx index c0773a01c..741115746 100644 --- a/app/(dashboard)/public-cloud/products/page.tsx +++ b/app/(dashboard)/public-cloud/products/page.tsx @@ -35,7 +35,6 @@ export default async function ProductsTable({ const session = await getServerSession(authOptions); if (!session) { - console.log('No session found'); redirect('/login?callbackUrl=/private-cloud/products'); } diff --git a/app/(dashboard)/public-cloud/requests/page.tsx b/app/(dashboard)/public-cloud/requests/page.tsx index 3944de015..72b584ae9 100644 --- a/app/(dashboard)/public-cloud/requests/page.tsx +++ b/app/(dashboard)/public-cloud/requests/page.tsx @@ -34,7 +34,6 @@ export default async function RequestsTable({ const session = await getServerSession(authOptions); if (!session) { - console.log('No session found'); redirect('/login?callbackUrl=/private-cloud/products'); } diff --git a/app/(request)/public-cloud/decision/[licencePlate]/page.tsx b/app/(request)/public-cloud/decision/[licencePlate]/page.tsx index c38e83c39..353b38b08 100644 --- a/app/(request)/public-cloud/decision/[licencePlate]/page.tsx +++ b/app/(request)/public-cloud/decision/[licencePlate]/page.tsx @@ -94,12 +94,6 @@ export default function RequestDecision({ params }: { params: { licencePlate: st } }; - console.log('WATCH'); - console.log(methods.watch()); - - console.log('DATA ACCOUNT CODING'); - console.log(data?.requestedProject?.accountCoding); - return (
diff --git a/app/api/private-cloud/requests/route.ts b/app/api/private-cloud/requests/route.ts index 20da48cf1..bf88c4de8 100644 --- a/app/api/private-cloud/requests/route.ts +++ b/app/api/private-cloud/requests/route.ts @@ -10,8 +10,6 @@ import { privateCloudRequestsPaginated } from '@/queries/paginated/private-cloud export async function GET(req: NextRequest): Promise { const { searchParams } = new URL(req.url); - console.log('SEARCH PARAMS: ', searchParams); - const defaultPageSize = searchParams.get('defaultPageSize'); const currentPage = searchParams.get('currentPage'); const search = searchParams.get('search'); diff --git a/app/authExample/page.tsx b/app/authExample/page.tsx index 99f55cce1..a6f72ed59 100644 --- a/app/authExample/page.tsx +++ b/app/authExample/page.tsx @@ -6,7 +6,6 @@ const ServerProtectedPage = async () => { const session = await getServerSession(authOptions); if (!session) { - console.log('No session found'); redirect('/signin?callbackUrl=/protected/server'); } diff --git a/ches/index.ts b/ches/index.ts index 027d8c3fc..97ea83d60 100644 --- a/ches/index.ts +++ b/ches/index.ts @@ -104,7 +104,6 @@ const sendEmail = async (email: Email): Promise => { } const data = await response.json(); - console.log('Email sent successfully:', data); } catch (error) { console.error('Exception sending email:', error); } diff --git a/components/form/CommonComponentsTemp.tsx b/components/form/CommonComponentsTemp.tsx index c4239217d..f825dfe63 100644 --- a/components/form/CommonComponentsTemp.tsx +++ b/components/form/CommonComponentsTemp.tsx @@ -47,7 +47,6 @@ export default function CommonComponents() { const [noneSelected, setNoneSelected] = useState(false); const onClickHandler = (name: string, value: string) => { - // console.log("onClickHandler", name, value); setCheckedState((prevState) => ({ ...prevState, [name]: prevState[name] === value ? 'NOT_USING' : value, diff --git a/emails/templates/EditRequestTemplate.tsx b/emails/templates/EditRequestTemplate.tsx index 8fe9d5b31..026d5ab41 100644 --- a/emails/templates/EditRequestTemplate.tsx +++ b/emails/templates/EditRequestTemplate.tsx @@ -25,7 +25,7 @@ export const EditRequestTemplate = ({ request }: EmailProp) => { const current = request.project; const requested = request.requestedProject; const changed = compareProjects(current, requested); - // console.log(changed) + return ( From 8331eb36ec5460f6596bd14bb56441efc798a02e Mon Sep 17 00:00:00 2001 From: okanji Date: Mon, 27 Nov 2023 16:27:56 -0800 Subject: [PATCH 3/7] added console log --- nats/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/nats/index.ts b/nats/index.ts index 2bf067a75..be34d8950 100644 --- a/nats/index.ts +++ b/nats/index.ts @@ -11,6 +11,7 @@ const serverURL = `${process.env.NATS_HOST}:${process.env.NATS_PORT}`; async function sendNatsMessage(natsSubject: string, messageBody: any) { try { + console.log('NATS SERVER URL: ', serverURL); console.log('NATS SUBJECT: ', natsSubject); console.log('MESSAGE BODY: ', JSON.stringify(messageBody)); From 2e452dcad4c81922545d04f04fe968f86b1e5ec6 Mon Sep 17 00:00:00 2001 From: okanji Date: Tue, 28 Nov 2023 10:47:53 -0800 Subject: [PATCH 4/7] disable request for user --- app/(request)/private-cloud/request/[id]/page.tsx | 7 +++++++ app/(request)/public-cloud/request/[id]/page.tsx | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/app/(request)/private-cloud/request/[id]/page.tsx b/app/(request)/private-cloud/request/[id]/page.tsx index 95c8597da..c5ec9e8b5 100644 --- a/app/(request)/private-cloud/request/[id]/page.tsx +++ b/app/(request)/private-cloud/request/[id]/page.tsx @@ -60,6 +60,13 @@ export default function RequestDecision({ params }: { params: { id: string } }) } }, [data]); + // If user is not an admin, set isDisabled to true + useEffect(() => { + if (session && !session.user.isAdmin) { + setDisabled(true); + } + }, [session]); + const secondTechLeadOnClick = () => { setSecondTechLead(!secondTechLead); if (secondTechLead) { diff --git a/app/(request)/public-cloud/request/[id]/page.tsx b/app/(request)/public-cloud/request/[id]/page.tsx index 499106b28..0b5526a6a 100644 --- a/app/(request)/public-cloud/request/[id]/page.tsx +++ b/app/(request)/public-cloud/request/[id]/page.tsx @@ -64,6 +64,13 @@ export default function RequestDecision({ params }: { params: { id: string } }) } }; + // If user is not an admin, set isDisabled to true + useEffect(() => { + if (session && !session.user.isAdmin) { + setDisabled(true); + } + }, [session]); + return (
From 15d38024a2b1f927b83ce77b9f18705de816d4d0 Mon Sep 17 00:00:00 2001 From: okanji Date: Tue, 28 Nov 2023 10:50:45 -0800 Subject: [PATCH 5/7] removed console log --- components/tabs/CloudTabs.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/tabs/CloudTabs.tsx b/components/tabs/CloudTabs.tsx index 3d50dd134..f33c462fd 100644 --- a/components/tabs/CloudTabs.tsx +++ b/components/tabs/CloudTabs.tsx @@ -19,8 +19,6 @@ const tabs = [ export default function Tabs({ className }: { className?: string }) { const pathname = usePathname(); - console.log(pathname); - return (
From 4cf86e45acbba05a0704c6d55972e8267695788c Mon Sep 17 00:00:00 2001 From: okanji Date: Tue, 28 Nov 2023 14:34:43 -0800 Subject: [PATCH 6/7] fixed bug in nats message --- nats/privateCloud/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nats/privateCloud/index.ts b/nats/privateCloud/index.ts index 15d192a59..e20b59b30 100644 --- a/nats/privateCloud/index.ts +++ b/nats/privateCloud/index.ts @@ -69,9 +69,9 @@ export default function createPrivateCloudNatsMessage( ].map(({ quotaName, quota }) => ({ name: `${licencePlate}-${quotaName}`, quota: { - cpu: DefaultCpuOptions[quota.cpu], - memory: DefaultMemoryOptions[quota.memory], - storage: DefaultStorageOptions[quota.storage], + cpu: DefaultCpuOptions[quota.cpu].name, + memory: DefaultMemoryOptions[quota.memory].name, + storage: DefaultStorageOptions[quota.storage].name, snapshot: snapshot.name, }, quotas: { From a144be4af2b3765aeb3f83e2641c0b866bce29ab Mon Sep 17 00:00:00 2001 From: okanji Date: Tue, 28 Nov 2023 14:41:33 -0800 Subject: [PATCH 7/7] enabled mautic and emails in decision --- app/api/private-cloud/decision/[licencePlate]/route.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/private-cloud/decision/[licencePlate]/route.ts b/app/api/private-cloud/decision/[licencePlate]/route.ts index 42c1b113c..16ff31a87 100644 --- a/app/api/private-cloud/decision/[licencePlate]/route.ts +++ b/app/api/private-cloud/decision/[licencePlate]/route.ts @@ -100,11 +100,11 @@ export async function POST(req: NextRequest, { params }: { params: Params }) { request.requestedProject?.secondaryTechnicalLead, ].filter((user): user is User => Boolean(user)); - // // Subscribe users to Mautic - // await subscribeUsersToMautic(users, request.requestedProject.cluster, 'Private'); + // Subscribe users to Mautic + await subscribeUsersToMautic(users, request.requestedProject.cluster, 'Private'); - // // Send emails - // sendRequestApprovalEmails(request); + // Send emails + sendRequestApprovalEmails(request); return new NextResponse(`Decision request for ${request.licencePlate} succesfully created.`, { status: 200,