Skip to content

Commit c172f75

Browse files
fix(dep): address compatibility issues (#6557)
Co-authored-by: Pablo Lara <[email protected]>
1 parent ec492fa commit c172f75

File tree

9 files changed

+4284
-4000
lines changed

9 files changed

+4284
-4000
lines changed

ui/actions/roles/roles.ts

+25-9
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,32 @@ export const addRole = async (formData: FormData) => {
8181

8282
const name = formData.get("name") as string;
8383
const groups = formData.getAll("groups[]") as string[];
84-
// Prepare base payload
84+
8585
const payload: any = {
8686
data: {
8787
type: "roles",
8888
attributes: {
8989
name,
9090
manage_users: formData.get("manage_users") === "true",
91-
manage_account: formData.get("manage_account") === "true",
92-
manage_billing: formData.get("manage_billing") === "true",
9391
manage_providers: formData.get("manage_providers") === "true",
94-
manage_integrations: formData.get("manage_integrations") === "true",
9592
manage_scans: formData.get("manage_scans") === "true",
93+
// TODO: Add back when we have integrations ready
94+
// manage_integrations: formData.get("manage_integrations") === "true",
9695
unlimited_visibility: formData.get("unlimited_visibility") === "true",
9796
},
9897
relationships: {},
9998
},
10099
};
101100

102-
// Add relationships only if there are items
101+
// Conditionally include manage_account and manage_billing for cloud environment
102+
if (process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true") {
103+
payload.data.attributes.manage_account =
104+
formData.get("manage_account") === "true";
105+
payload.data.attributes.manage_billing =
106+
formData.get("manage_billing") === "true";
107+
}
108+
109+
// Add provider groups relationships only if there are items
103110
if (groups.length > 0) {
104111
payload.data.relationships.provider_groups = {
105112
data: groups.map((groupId: string) => ({
@@ -147,19 +154,27 @@ export const updateRole = async (formData: FormData, roleId: string) => {
147154
type: "roles",
148155
id: roleId,
149156
attributes: {
150-
...(name && { name }),
157+
...(name && { name }), // Include name only if provided
151158
manage_users: formData.get("manage_users") === "true",
152-
manage_account: formData.get("manage_account") === "true",
153-
manage_billing: formData.get("manage_billing") === "true",
154159
manage_providers: formData.get("manage_providers") === "true",
155-
manage_integrations: formData.get("manage_integrations") === "true",
156160
manage_scans: formData.get("manage_scans") === "true",
161+
// TODO: Add back when we have integrations ready
162+
// manage_integrations: formData.get("manage_integrations") === "true",
157163
unlimited_visibility: formData.get("unlimited_visibility") === "true",
158164
},
159165
relationships: {},
160166
},
161167
};
162168

169+
// Conditionally include manage_account and manage_billing for cloud environments
170+
if (process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true") {
171+
payload.data.attributes.manage_account =
172+
formData.get("manage_account") === "true";
173+
payload.data.attributes.manage_billing =
174+
formData.get("manage_billing") === "true";
175+
}
176+
177+
// Add provider groups relationships only if there are items
163178
if (groups.length > 0) {
164179
payload.data.relationships.provider_groups = {
165180
data: groups.map((groupId: string) => ({
@@ -182,6 +197,7 @@ export const updateRole = async (formData: FormData, roleId: string) => {
182197
},
183198
body,
184199
});
200+
185201
const data = await response.json();
186202
revalidatePath("/roles");
187203
return data;

ui/app/(prowler)/providers/(set-up-provider)/update-credentials/page.tsx

+17-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Alert, cn } from "@nextui-org/react";
21
import React from "react";
32

3+
import { InfoIcon } from "@/components/icons";
44
import {
55
UpdateViaCredentialsForm,
66
UpdateViaRoleForm,
@@ -17,33 +17,23 @@ export default function UpdateCredentialsPage({ searchParams }: Props) {
1717
{searchParams.type === "aws" && !searchParams.via && (
1818
<>
1919
<div className="flex flex-col gap-4">
20-
<p className="text-sm text-default-500">
21-
If the provider was set up with static credentials, updates must
22-
use static credentials. If it was set up with a role, updates must
23-
use a role.
20+
<p className="text-sm text-default-700">
21+
To update provider credentials,{" "}
22+
<strong>
23+
the same type that was originally configured must be used.
24+
</strong>
2425
</p>
25-
26-
<Alert
27-
color="warning"
28-
variant="faded"
29-
classNames={{
30-
base: cn([
31-
"border-1 border-default-200 dark:border-default-100",
32-
"gap-x-4",
33-
]),
34-
}}
35-
description={
36-
<>
37-
To update provider credentials,{" "}
38-
<strong>
39-
you must use the same type that was originally configured.
40-
</strong>{" "}
41-
</>
42-
}
43-
/>
44-
<p className="text-sm text-default-500">
45-
To switch from static credentials to a role (or vice versa), you
46-
need to delete the provider and set it up again.
26+
<div className="flex items-center rounded-lg border border-system-warning bg-system-warning-medium p-4 text-sm dark:text-default-300">
27+
<InfoIcon className="mr-2 inline h-4 w-4 flex-shrink-0" />
28+
<p>
29+
If the provider was configured with static credentials, updates
30+
must also use static credentials. If it was configured with a
31+
role, updates must use a role.
32+
</p>
33+
</div>
34+
<p className="text-sm text-default-700">
35+
To switch from static credentials to a role (or vice versa), the
36+
provider must be deleted and set up again.
4737
</p>
4838
<SelectViaAWS initialVia={searchParams.via} />
4939
</div>

ui/app/(prowler)/scans/page.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,18 @@ export default async function Scans({
6666
<>
6767
<Spacer y={8} />
6868
<NoProvidersConnected />
69+
<Spacer y={4} />
6970
</>
7071
) : (
7172
<>
7273
<LaunchScanWorkflow providers={providerInfo} />
74+
<Spacer y={4} />
75+
<ScanWarningBar />
7376
<Spacer y={8} />
7477
</>
7578
)}
7679
<div className="grid grid-cols-12 items-start gap-4">
7780
<div className="col-span-12">
78-
<ScanWarningBar />
79-
<Spacer y={4} />
8081
<div className="flex flex-row items-center justify-between">
8182
<DataTableFilterCustom filters={filterScans || []} />
8283
<ButtonRefreshData

ui/components/roles/workflow/forms/add-role-form.tsx

+12-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ export const AddRoleForm = ({
3333
defaultValues: {
3434
name: "",
3535
manage_users: false,
36-
manage_account: false,
37-
manage_billing: false,
3836
manage_providers: false,
39-
manage_integrations: false,
4037
manage_scans: false,
4138
unlimited_visibility: false,
4239
groups: [],
40+
...(process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true" && {
41+
manage_account: false,
42+
manage_billing: false,
43+
}),
4344
},
4445
});
4546

@@ -64,7 +65,7 @@ export const AddRoleForm = ({
6465
"manage_account",
6566
"manage_billing",
6667
"manage_providers",
67-
"manage_integrations",
68+
// "manage_integrations",
6869
"manage_scans",
6970
"unlimited_visibility",
7071
];
@@ -79,18 +80,22 @@ export const AddRoleForm = ({
7980

8081
const onSubmitClient = async (values: FormValues) => {
8182
const formData = new FormData();
83+
8284
formData.append("name", values.name);
8385
formData.append("manage_users", String(values.manage_users));
84-
formData.append("manage_account", String(values.manage_account));
85-
formData.append("manage_billing", String(values.manage_billing));
8686
formData.append("manage_providers", String(values.manage_providers));
87-
formData.append("manage_integrations", String(values.manage_integrations));
8887
formData.append("manage_scans", String(values.manage_scans));
8988
formData.append(
9089
"unlimited_visibility",
9190
String(values.unlimited_visibility),
9291
);
9392

93+
// Conditionally append manage_account and manage_billing
94+
if (process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true") {
95+
formData.append("manage_account", String(values.manage_account));
96+
formData.append("manage_billing", String(values.manage_billing));
97+
}
98+
9499
if (values.groups && values.groups.length > 0) {
95100
values.groups.forEach((group) => {
96101
formData.append("groups[]", group);

ui/components/roles/workflow/forms/edit-role-form.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,21 @@ export const EditRoleForm = ({
9595
}
9696

9797
updatedFields.manage_users = values.manage_users;
98-
updatedFields.manage_account = values.manage_account;
99-
updatedFields.manage_billing = values.manage_billing;
10098
updatedFields.manage_providers = values.manage_providers;
101-
updatedFields.manage_integrations = values.manage_integrations;
99+
// updatedFields.manage_integrations = values.manage_integrations;
102100
updatedFields.manage_scans = values.manage_scans;
103101
updatedFields.unlimited_visibility = values.unlimited_visibility;
104102

103+
if (process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true") {
104+
updatedFields.manage_account = values.manage_account;
105+
updatedFields.manage_billing = values.manage_billing;
106+
}
107+
105108
if (
106109
JSON.stringify(values.groups) !==
107-
JSON.stringify(roleData.data.relationships?.provider_groups?.data)
110+
JSON.stringify(
111+
roleData.data.relationships?.provider_groups?.data.map((g) => g.id),
112+
)
108113
) {
109114
updatedFields.groups = values.groups;
110115
}
+13-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import { Alert, cn } from "@nextui-org/react";
1+
"use client";
2+
3+
import { InfoIcon } from "../icons";
24

35
export const ScanWarningBar = () => {
46
return (
5-
<Alert
6-
color="warning"
7-
title="Waiting for Your Scan to Show Up?"
8-
description="Your scan is being processed and may take a few minutes to appear on the table. It will show up shortly."
9-
variant="faded"
10-
isClosable
11-
classNames={{
12-
base: cn([
13-
"border-1 border-default-200 dark:border-default-100",
14-
"gap-x-4",
15-
]),
16-
}}
17-
/>
7+
<div className="flex items-center rounded-lg border border-system-warning bg-system-warning-medium p-4 text-sm dark:text-default-300">
8+
<InfoIcon className="mr-4 inline h-4 w-4 flex-shrink-0" />
9+
<div className="flex flex-col gap-1">
10+
<strong>Waiting for Your Scan to Show Up?</strong>
11+
<p>
12+
It may take a few minutes for the scan to appear on the table and be
13+
displayed.
14+
</p>
15+
</div>
16+
</div>
1817
);
1918
};

0 commit comments

Comments
 (0)