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(4276): add cancel operations for private/public clouds #4641

Merged
merged 8 commits into from
Jan 15, 2025
Merged

Conversation

golebu2020
Copy link
Collaborator

@golebu2020 golebu2020 commented Jan 11, 2025

The ability to cancel requests is available for all operations (CREATE, EDIT, DELETE) in both Private and Public Clouds, and is not limited to just CREATE requests. At any point during the provisioning cycle or after the provisioning cycle, particularly for the Public Cloud, active requests of any type can be cancelled.

billingId String @db.ObjectId
billing Billing @relation("billing", fields: [billingId], references: [id])
billingId String? @db.ObjectId
billing Billing? @relation("billing", fields: [billingId], references: [id])
Copy link
Collaborator

Choose a reason for hiding this comment

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

should billingId and billing itself be optional for already created product?

Copy link
Collaborator Author

@golebu2020 golebu2020 Jan 13, 2025

Choose a reason for hiding this comment

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

The error occurs because the billingId field in decisionData can be null, but Prisma's upsert method expects it to be a string, StringFieldUpdateOperationsInput, or undefined. To fix this, I ensured billingId is either a valid string or undefined before passing it to the upsert operation. This error propagates to almost every code block that handles public cloud billing. I had to make billing and billingId optional. This changes didn't break the code even after pulling live data from dev environment.

@@ -12,10 +12,12 @@ import {
IconMoneybag,
IconReceipt2,
} from '@tabler/icons-react';
import { useSession } from 'next-auth/react';
import { useEffect, useState } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesn't look like it is used

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed!

@@ -62,18 +62,18 @@ export const GET = apiHandler(async ({ pathParams, queryParams, session }) => {
return BadRequestResponse('invalid account coding');
}

product = req.decisionData;
product = req.decisionData as Product;
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we really need this cast here?

Copy link
Collaborator Author

@golebu2020 golebu2020 Jan 13, 2025

Choose a reason for hiding this comment

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

This has been removed

}

const canDownloadMou =
session.permissions.downloadBillingMou ||
product.members.some(
product?.members.some(
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need this check here? Product is checked on line 50

Copy link
Collaborator Author

@golebu2020 golebu2020 Jan 13, 2025

Choose a reason for hiding this comment

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

This has been removed

(member) =>
member.userId === session.user.id &&
arraysIntersect(member.roles, [PublicCloudProductMemberRole.BILLING_VIEWER]),
);

if (!canDownloadMou) {
if (!canDownloadMou || !product) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, product is checked on line 50

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This has been removed

(doc.type === RequestType.DELETE || doc.type === RequestType.EDIT || doc.type === RequestType.CREATE);

const canEdit = (canReview && doc.type !== RequestType.DELETE) || canCancel;

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don 't think that a user can edit own request

Copy link
Collaborator Author

@golebu2020 golebu2020 Jan 13, 2025

Choose a reason for hiding this comment

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

I don't understand this comment. A user can edit own request, I made sure that the exact same requester is able to edit their request. The canEdit has to be true for the decisionStatus prop to be editable in the public cloud request.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Kolezhanchik please review the recent changes

Copy link
Collaborator

Choose a reason for hiding this comment

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

still user can't edit own request, only admin can

@golebu2020 golebu2020 merged commit ceeb2a7 into main Jan 15, 2025
9 of 10 checks passed
@golebu2020 golebu2020 deleted the feat/4276 branch January 15, 2025 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants