Skip to content

Commit

Permalink
Merge branch 'main' into improve-docs-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
programmiri authored Aug 7, 2023
2 parents 0578c5f + 9e99619 commit b34b402
Show file tree
Hide file tree
Showing 127 changed files with 515 additions and 402 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.idea
.idea/*
!.idea/vcs.xml
!.idea/icon.png
target
logs

Expand Down
Binary file added .idea/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
2 changes: 1 addition & 1 deletion cluster-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<!-- the list is sorted-->
<apache.commons.lang.version>3.12.0</apache.commons.lang.version>
<apache.commons.lang.version>3.13.0</apache.commons.lang.version>
<guava.version>31.1-jre</guava.version>
<kafka.client.version>3.4.1</kafka.client.version>
<mockserver.version>5.15.0</mockserver.version>
Expand Down
21 changes: 18 additions & 3 deletions coral/docs/directory-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,36 @@ In this directory, we group similar code together based on one feature. The stru
- Every feature folder includes one component on the top level to export. This file is named the same as the features directory.
-❗This root component should be the only one used in imports outside of this feature.


#### Second level: `app/pages`

Contains every page of the application. The structure in this folder should mirror the structure of routing. If there is a link to a "dashboard" page in the web app, there should be a `dashboard/index.tsx` page inside `pages`. The files don't need to have a `Page` pre- or postfix since the directory already gives that information.


### First level: `domain` folder

Contains different domains we need to describe the UI application. They are specific to it. They are the concepts you would elaborate on when describing the Klaw UI app.
`domain` is where business logic lives and a layer between e.g. the data from the backend API and `app`. `domain` is
`domain` is where business logic lives and a layer between e.g. the data from the backend API and `app`. `domain` is
the only place that speaks with the backend and knows what data from the backend looks like.

- We name the folders in `domain` based on the model / concept they are implementing.
- Each `domain` has a main file called `{entity}-api.ts` which holds handler functions for API operations, which are used in the `app` folder
- Every folder includes a `index.ts` file to export modules / interfaces and act as a public API.

#### Naming convention for `domain` handlers

**`POST` - Creating a request: `request{entity}{action noun}`**
Only use `request` as a verb when the API handlers creates a request entity which needs to be approved, with the structure `request{entity}{action}`.

Example: `requestTopicCreation`, `requestConnectorDeletion`, `requestTopicPromotion`

**`POST` - Acting on a created request: `{action verb}{entity}Request`**
Only use `Request` as a noun when the API handlers fires an action against a created request entity, with the structure `{action}{entity}Request`.

Example: `deleteTopicRequest`, `approveTopicRequest`

**`POST` / `GET` - Immediate action: `{action verb}{entity}{optional category}`**
Do not use `request` for immediate actions (no request entity created), but the structure `{action}{entity}{optional category}`.

Example: `updateTopicDocumentation`, `getConnectorOverview`

### First level: `services`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { Context as AquariumContext } from "@aivenio/aquarium";
import { cleanup, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { ConnectorSettings } from "src/app/features/connectors/details/settings/ConnectorSettings";
import { ConnectorOverview, deleteConnector } from "src/domain/connector";
import {
ConnectorOverview,
requestConnectorDeletion,
} from "src/domain/connector";
import { customRender } from "src/services/test-utils/render-with-wrappers";
import { KlawApiModel } from "types/utils";

Expand All @@ -18,8 +21,8 @@ jest.mock("src/app/features/connectors/details/ConnectorDetails", () => ({
}));

jest.mock("src/domain/connector/connector-api.ts");
const mockDeleteConnector = deleteConnector as jest.MockedFunction<
typeof deleteConnector
const mockDeleteConnector = requestConnectorDeletion as jest.MockedFunction<
typeof requestConnectorDeletion
>;

const testConnectorName = "my-nice-connector";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { useConnectorDetails } from "src/app/features/connectors/details/ConnectorDetails";
import { ConnectorDeleteConfirmationModal } from "src/app/features/connectors/details/settings/components/ConnectorDeleteConfirmationModal";
import { deleteConnector } from "src/domain/connector";
import { requestConnectorDeletion } from "src/domain/connector";
import { HTTPError } from "src/services/api";
import { parseErrorMsg } from "src/services/mutation-utils";

Expand All @@ -39,7 +39,7 @@ function ConnectorSettings() {

const { mutate, isLoading } = useMutation(
(remark?: string) =>
deleteConnector({
requestConnectorDeletion({
connectorName,
envId: environmentId,
remark,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { cleanup, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { Route, Routes } from "react-router-dom";
import ConnectorEditRequest from "src/app/features/connectors/request/ConnectorEditRequest";
import { editConnector, getConnectorDetailsPerEnv } from "src/domain/connector";
import {
requestConnectorEdit,
getConnectorDetailsPerEnv,
} from "src/domain/connector";
import { customRender } from "src/services/test-utils/render-with-wrappers";
import * as ReactQuery from "@tanstack/react-query";

Expand Down Expand Up @@ -52,8 +55,8 @@ const mockGetConnectorDetailsPerEnv =
typeof getConnectorDetailsPerEnv
>;

const mockEditConnector = editConnector as jest.MockedFunction<
typeof editConnector
const mockEditConnector = requestConnectorEdit as jest.MockedFunction<
typeof requestConnectorEdit
>;

const mockedUsedNavigate = jest.fn();
Expand Down Expand Up @@ -242,8 +245,8 @@ describe("<ConnectorEditRequest />", () => {
await user.type(input, "hello");
await user.click(button);

expect(editConnector).toHaveBeenCalledTimes(1);
expect(editConnector).toHaveBeenCalledWith({
expect(requestConnectorEdit).toHaveBeenCalledTimes(1);
expect(requestConnectorEdit).toHaveBeenCalledWith({
connectorConfig:
testConnectorDetailsPerEnvResponse.connectorContents
.connectorConfig,
Expand Down Expand Up @@ -281,7 +284,7 @@ describe("<ConnectorEditRequest />", () => {
).toBeVisible()
);

expect(editConnector).not.toHaveBeenCalled();
expect(requestConnectorEdit).not.toHaveBeenCalled();
expect(mockedUseToast).not.toHaveBeenCalled();
expect(
screen.getByRole("button", { name: "Submit update request" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import { Routes } from "src/app/router_utils";
import {
ConnectorDetailsForEnv,
editConnector,
requestConnectorEdit,
getConnectorDetailsPerEnv,
} from "src/domain/connector";
import { HTTPError } from "src/services/api";
Expand Down Expand Up @@ -142,7 +142,7 @@ function ConnectorEditRequest() {
isLoading: editIsLoading,
isError: editIsError,
error: editError,
} = useMutation(editConnector, {
} = useMutation(requestConnectorEdit, {
onSuccess: () => {
navigate(-1);
toast({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import userEvent from "@testing-library/user-event";
import ConnectorRequest from "src/app/features/connectors/request/ConnectorRequest";
import { createEnvironment } from "src/domain/environment/environment-test-helper";
import { customRender } from "src/services/test-utils/render-with-wrappers";
import { createConnectorRequest } from "src/domain/connector";
import { requestConnectorCreation } from "src/domain/connector";
import { getAllEnvironmentsForConnector } from "src/domain/environment";

jest.mock("src/domain/environment/environment-api.ts");
Expand All @@ -16,7 +16,9 @@ const mockGetConnectorEnvironmentRequest =
>;

const mockCreateConnectorRequest =
createConnectorRequest as jest.MockedFunction<typeof createConnectorRequest>;
requestConnectorCreation as jest.MockedFunction<
typeof requestConnectorCreation
>;

const mockedUsedNavigate = jest.fn();
jest.mock("react-router-dom", () => ({
Expand Down Expand Up @@ -398,9 +400,9 @@ describe("<ConnectorRequest />", () => {
screen.getByRole("button", { name: "Submit request" })
);
await waitFor(() =>
expect(createConnectorRequest).toHaveBeenCalledTimes(1)
expect(requestConnectorCreation).toHaveBeenCalledTimes(1)
);
expect(createConnectorRequest).toHaveBeenCalledWith({
expect(requestConnectorCreation).toHaveBeenCalledWith({
connectorConfig:
'{ "connector.class": "test", "tasks.max": 10, "topics": "test" }',
connectorName: "this-is-connector-name",
Expand Down Expand Up @@ -431,8 +433,8 @@ describe("<ConnectorRequest />", () => {
screen.getByRole("button", { name: "Submit request" })
);

expect(createConnectorRequest).toHaveBeenCalledTimes(1);
expect(createConnectorRequest).toHaveBeenCalledWith({
expect(requestConnectorCreation).toHaveBeenCalledTimes(1);
expect(requestConnectorCreation).toHaveBeenCalledWith({
connectorConfig:
'{ "connector.class": "test", "tasks.max": 10, "topics": "test" }',
connectorName: "this-is-connector-name",
Expand All @@ -456,7 +458,7 @@ describe("<ConnectorRequest />", () => {
).toBeVisible()
);

expect(createConnectorRequest).not.toHaveBeenCalled();
expect(requestConnectorCreation).not.toHaveBeenCalled();
expect(mockedUseToast).not.toHaveBeenCalled();
expect(
screen.getByRole("button", { name: "Submit request" })
Expand All @@ -468,7 +470,7 @@ describe("<ConnectorRequest />", () => {
screen.getByRole("button", { name: "Submit request" })
);

expect(createConnectorRequest).toHaveBeenCalledTimes(1);
expect(requestConnectorCreation).toHaveBeenCalledTimes(1);
await waitFor(() =>
expect(mockedUseToast).toHaveBeenCalledWith({
message: "Connector request successfully created",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
ConnectorRequestFormSchema,
connectorRequestFormSchema,
} from "src/app/features/connectors/request/schemas/connector-request-form";
import { createConnectorRequest } from "src/domain/connector";
import { requestConnectorCreation } from "src/domain/connector";
import {
Environment,
getAllEnvironmentsForConnector,
Expand All @@ -51,7 +51,7 @@ function ConnectorRequest() {
queryFn: () => getAllEnvironmentsForConnector(),
});

const connectorRequestMutation = useMutation(createConnectorRequest, {
const connectorRequestMutation = useMutation(requestConnectorCreation, {
onSuccess: () => {
navigate("/requests/connectors?status=CREATED");
toast({
Expand Down
12 changes: 7 additions & 5 deletions coral/src/app/features/topics/details/TopicDetails.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import userEvent from "@testing-library/user-event";
import { TopicDetails } from "src/app/features/topics/details/TopicDetails";
import { TopicOverview, TopicSchemaOverview } from "src/domain/topic";
import {
claimTopic,
requestTopicClaim,
getSchemaOfTopic,
getTopicOverview,
} from "src/domain/topic/topic-api";
Expand Down Expand Up @@ -40,7 +40,9 @@ const mockGetTopicOverview = getTopicOverview as jest.MockedFunction<
const mockGetSchemaOfTopic = getSchemaOfTopic as jest.MockedFunction<
typeof getSchemaOfTopic
>;
const mockClaimTopic = claimTopic as jest.MockedFunction<typeof claimTopic>;
const mockRequestTopicClaim = requestTopicClaim as jest.MockedFunction<
typeof requestTopicClaim
>;

const testTopicName = "my-nice-topic";
const testTopicOverview: TopicOverview = {
Expand Down Expand Up @@ -510,7 +512,7 @@ describe("TopicDetails", () => {

await userEvent.click(submitButton);

expect(mockClaimTopic).toHaveBeenCalledWith({
expect(mockRequestTopicClaim).toHaveBeenCalledWith({
topicName: testTopicOverview.topicInfo.topicName,
env: testTopicOverview.topicInfo.envId,
});
Expand Down Expand Up @@ -539,7 +541,7 @@ describe("TopicDetails", () => {
await userEvent.type(textArea, "hello");
await userEvent.click(submitButton);

expect(mockClaimTopic).toHaveBeenCalledWith({
expect(mockRequestTopicClaim).toHaveBeenCalledWith({
topicName: testTopicOverview.topicInfo.topicName,
env: testTopicOverview.topicInfo.envId,
remark: "hello",
Expand Down Expand Up @@ -582,7 +584,7 @@ describe("TopicDetails", () => {
const mockErrorMessage = "There was an error";
await waitForElementToBeRemoved(screen.getByPlaceholderText("Loading"));

mockClaimTopic.mockRejectedValue(mockErrorMessage);
mockRequestTopicClaim.mockRejectedValue(mockErrorMessage);

const button = await waitFor(() =>
screen.getByRole("button", { name: "Claim topic" })
Expand Down
4 changes: 2 additions & 2 deletions coral/src/app/features/topics/details/TopicDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from "src/app/router_utils";
import { TopicOverview, TopicSchemaOverview } from "src/domain/topic";
import {
claimTopic,
requestTopicClaim,
getSchemaOfTopic,
getTopicOverview,
} from "src/domain/topic/topic-api";
Expand Down Expand Up @@ -98,7 +98,7 @@ function TopicDetails(props: TopicOverviewProps) {
isError: createClaimTopicRequestIsError,
} = useMutation(
(remark?: string) =>
claimTopic({
requestTopicClaim({
topicName: topicData?.topicInfo.topicName || "",
env: topicData?.topicInfo.envId || "",
remark,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import userEvent from "@testing-library/user-event";
import { TopicDetailsSchema } from "src/app/features/topics/details/schema/TopicDetailsSchema";
import { customRender } from "src/services/test-utils/render-with-wrappers";
import { TopicSchemaOverview } from "src/domain/topic";
import { promoteSchemaRequest } from "src/domain/schema-request";
import { requestSchemaPromotion } from "src/domain/schema-request";

jest.mock("src/domain/schema-request/schema-request-api.ts");
const mockPromoteSchemaRequest = promoteSchemaRequest as jest.MockedFunction<
typeof promoteSchemaRequest
const mockPromoteSchemaRequest = requestSchemaPromotion as jest.MockedFunction<
typeof requestSchemaPromotion
>;

const mockedUseTopicDetails = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { SchemaPromotionModal } from "src/app/features/topics/details/schema/com
import { SchemaStats } from "src/app/features/topics/details/schema/components/SchemaStats";
import {
PromoteSchemaPayload,
promoteSchemaRequest,
requestSchemaPromotion,
} from "src/domain/schema-request";
import { HTTPError } from "src/services/api";
import { parseErrorMsg } from "src/services/mutation-utils";
Expand Down Expand Up @@ -74,7 +74,7 @@ function TopicDetailsSchema() {
throw new Error("No promotion details available");
}

return promoteSchemaRequest({
return requestSchemaPromotion({
targetEnvironment: schemaPromotionDetails.targetEnvId,
sourceEnvironment: schemaPromotionDetails.sourceEnv,
topicName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Context as AquariumContext } from "@aivenio/aquarium";
import { cleanup, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { TopicSettings } from "src/app/features/topics/details/settings/TopicSettings";
import { TopicOverview, deleteTopic } from "src/domain/topic";
import { TopicOverview, requestTopicDeletion } from "src/domain/topic";
import { customRender } from "src/services/test-utils/render-with-wrappers";
import { KlawApiModel } from "types/utils";

Expand All @@ -18,7 +18,9 @@ jest.mock("src/app/features/topics/details/TopicDetails", () => ({
}));

jest.mock("src/domain/topic/topic-api.ts");
const mockDeleteTopic = deleteTopic as jest.MockedFunction<typeof deleteTopic>;
const mockDeleteTopic = requestTopicDeletion as jest.MockedFunction<
typeof requestTopicDeletion
>;

const testTopicName = "my-nice-topic";
const testEnvironmentId = 8;
Expand Down
Loading

0 comments on commit b34b402

Please sign in to comment.