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

Adding all to req operation type enum #1842

Merged
merged 10 commits into from
Oct 6, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ describe("AclApprovals", () => {
env: "ALL",
pageNo: "1",
requestStatus: "CREATED",
operationType: "ALL",
search: "",
};

Expand Down
4 changes: 1 addition & 3 deletions coral/src/app/features/approvals/acls/AclApprovals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import {
import { AclRequestsForApprover } from "src/domain/acl/acl-types";
import { parseErrorMsg } from "src/services/mutation-utils";

const defaultType = "ALL";

function AclApprovals() {
const queryClient = useQueryClient();
const [searchParams, setSearchParams] = useSearchParams();
Expand Down Expand Up @@ -80,7 +78,7 @@ function AclApprovals() {
requestStatus: status,
aclType,
search: search,
operationType: requestType !== defaultType ? requestType : undefined,
operationType: requestType,
}),
keepPreviousData: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe("ConnectorApprovals", () => {
requestStatus: "CREATED",
env: "ALL",
search: "",
operationType: "ALL",
};

beforeAll(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
import { parseErrorMsg } from "src/services/mutation-utils";
import { SearchConnectorFilter } from "src/app/features/components/filters/SearchConnectorFilter";

const defaultType = "ALL";

function ConnectorApprovals() {
const queryClient = useQueryClient();

Expand Down Expand Up @@ -72,7 +70,7 @@ function ConnectorApprovals() {
pageNo: currentPage.toString(),
env: environment,
search: search,
operationType: requestType !== defaultType ? requestType : undefined,
operationType: requestType,
}),
keepPreviousData: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ describe("SchemaApprovals", () => {
requestStatus: "CREATED",
env: "ALL",
search: "",
operationType: "ALL",
};
beforeAll(() => {
mockIntersectionObserver();
Expand Down
4 changes: 1 addition & 3 deletions coral/src/app/features/approvals/schemas/SchemaApprovals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
import { parseErrorMsg } from "src/services/mutation-utils";
import { RequestTypeFilter } from "src/app/features/components/filters/RequestTypeFilter";

const defaultType = "ALL";

function SchemaApprovals() {
const queryClient = useQueryClient();

Expand Down Expand Up @@ -72,7 +70,7 @@ function SchemaApprovals() {
pageNo: currentPage.toString(),
env: environment,
search: search,
operationType: requestType !== defaultType ? requestType : undefined,
operationType: requestType,
}),
keepPreviousData: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ describe("TopicApprovals", () => {
pageNo: "1",
requestStatus: "CREATED",
search: "",
operationType: "ALL",
};
beforeAll(() => {
mockIntersectionObserver();
Expand Down Expand Up @@ -422,6 +423,7 @@ describe("TopicApprovals", () => {
requestStatus: "CREATED",
search: "",
teamId: undefined,
operationType: "ALL",
});
});
});
Expand Down
6 changes: 2 additions & 4 deletions coral/src/app/features/approvals/topics/TopicApprovals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import {
import { HTTPError } from "src/services/api";
import { parseErrorMsg } from "src/services/mutation-utils";

const defaultType = "ALL";

function TopicApprovals() {
const queryClient = useQueryClient();

Expand Down Expand Up @@ -81,9 +79,9 @@ function TopicApprovals() {
pageNo: String(currentPage),
env: environment,
requestStatus: status,
teamId: teamId !== defaultType ? Number(teamId) : undefined,
teamId: teamId !== "ALL" ? Number(teamId) : undefined,
search: search,
operationType: requestType !== defaultType ? requestType : undefined,
operationType: requestType,
}),
keepPreviousData: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ChipStatus } from "@aivenio/aquarium";
// here TS won't complain if a possible
// value is missing from the array.
const requestOperationTypeList: RequestOperationType[] = [
"ALL",
"CLAIM",
"CREATE",
"DELETE",
Expand All @@ -16,6 +17,7 @@ const requestOperationTypeList: RequestOperationType[] = [
const requestOperationTypeChipStatusMap: {
[key in RequestOperationType]: ChipStatus;
} = {
ALL: "neutral",
CLAIM: "neutral",
CREATE: "neutral",
DELETE: "neutral",
Expand All @@ -26,6 +28,7 @@ const requestOperationTypeChipStatusMap: {
const requestOperationTypeNameMap: {
[key in RequestOperationType]: string;
} = {
ALL: "All",
CLAIM: "Claim",
CREATE: "Create",
DELETE: "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ describe("RequestTypeFilter.tsx", () => {

requestOperationTypeList.forEach((type) => {
const option = screen.getByRole("option", {
name: requestOperationTypeNameMap[type],
name:
requestOperationTypeNameMap[type] === "All"
? "All request types"
: requestOperationTypeNameMap[type],
});

expect(option).toBeEnabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ function RequestTypeFilter() {
defaultValue={requestType}
onChange={handleChangeRequestType}
>
<option key={"ALL"} value={"ALL"}>
All request types
</option>
{requestOperationTypeList.map((operationType) => {
return (
<option key={operationType} value={operationType}>
{requestOperationTypeNameMap[operationType]}
{operationType === "ALL"
? "All request types"
: requestOperationTypeNameMap[operationType]}
</option>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type SetFiltersParams =
| { name: "status"; value: RequestStatus }
| { name: "teamId"; value: string }
| { name: "showOnlyMyRequests"; value: boolean }
| { name: "requestType"; value: RequestOperationType | "ALL" }
| { name: "requestType"; value: RequestOperationType }
| { name: "search"; value: string };

interface UseFiltersDefaultValues {
Expand All @@ -21,7 +21,7 @@ interface UseFiltersDefaultValues {
status: RequestStatus;
teamId: string;
showOnlyMyRequests: boolean;
requestType: RequestOperationType | "ALL";
requestType: RequestOperationType;
search: string;
paginated: boolean;
}
Expand Down Expand Up @@ -58,7 +58,6 @@ const FiltersProvider = ({
}) => {
const [searchParams, setSearchParams] = useSearchParams();

//
const initialValues = { ...emptyValues, ...defaultValues };

const environment =
Expand All @@ -70,7 +69,7 @@ const FiltersProvider = ({
const teamId = searchParams.get("teamId") ?? initialValues.teamId;
const showOnlyMyRequests = searchParams.get("showOnlyMyRequests") === "true";
const requestType =
(searchParams.get("requestType") as RequestOperationType | "ALL") ??
(searchParams.get("requestType") as RequestOperationType) ??
initialValues.requestType;
const search = searchParams.get("search") ?? initialValues.search;
const paginated = initialValues.paginated;
Expand Down
26 changes: 13 additions & 13 deletions coral/src/app/features/requests/acls/AclRequests.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe("AclRequests", () => {
env: "ALL",
aclType: "ALL",
requestStatus: "ALL",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand All @@ -176,7 +176,7 @@ describe("AclRequests", () => {
env: "ALL",
aclType: "ALL",
requestStatus: "ALL",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand Down Expand Up @@ -285,7 +285,7 @@ describe("AclRequests", () => {
env: "ALL",
aclType: "ALL",
requestStatus: "ALL",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand All @@ -309,7 +309,7 @@ describe("AclRequests", () => {
env: "ALL",
aclType: "ALL",
requestStatus: "ALL",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand All @@ -330,7 +330,7 @@ describe("AclRequests", () => {
env: "ALL",
aclType: "ALL",
requestStatus: "ALL",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand Down Expand Up @@ -365,7 +365,7 @@ describe("AclRequests", () => {
env: "1",
aclType: "ALL",
requestStatus: "ALL",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand Down Expand Up @@ -393,7 +393,7 @@ describe("AclRequests", () => {
env: "1",
aclType: "ALL",
requestStatus: "ALL",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand Down Expand Up @@ -424,7 +424,7 @@ describe("AclRequests", () => {
env: "ALL",
aclType: "CONSUMER",
requestStatus: "ALL",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand All @@ -448,7 +448,7 @@ describe("AclRequests", () => {
env: "ALL",
aclType: "CONSUMER",
requestStatus: "ALL",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand Down Expand Up @@ -479,7 +479,7 @@ describe("AclRequests", () => {
env: "ALL",
aclType: "ALL",
requestStatus: "APPROVED",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand All @@ -504,7 +504,7 @@ describe("AclRequests", () => {
env: "ALL",
aclType: "ALL",
requestStatus: "APPROVED",
operationType: undefined,
operationType: "ALL",
isMyRequest: false,
});
});
Expand Down Expand Up @@ -536,7 +536,7 @@ describe("AclRequests", () => {
aclType: "ALL",
requestStatus: "ALL",
isMyRequest: true,
operationType: undefined,
operationType: "ALL",
});
});

Expand Down Expand Up @@ -564,7 +564,7 @@ describe("AclRequests", () => {
aclType: "ALL",
requestStatus: "ALL",
isMyRequest: true,
operationType: undefined,
operationType: "ALL",
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion coral/src/app/features/requests/acls/AclRequests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function AclRequests() {
env: environment,
aclType,
requestStatus: status,
operationType: requestType === "ALL" ? undefined : requestType,
operationType: requestType,
isMyRequest: showOnlyMyRequests,
}),
keepPreviousData: true,
Expand Down
Loading
Loading