Skip to content

Commit 08ae536

Browse files
committed
🐛 Remove kind=asset from the Credentials pages
Part 2 of 2: https://issues.redhat.com/browse/MTA-6122 Part 2 of 2: konveyor#2599 Follows: konveyor#2610 Signed-off-by: Scott J Dickerson <[email protected]>
1 parent c7af155 commit 08ae536

File tree

11 files changed

+70
-238
lines changed

11 files changed

+70
-238
lines changed

client/src/app/api/models.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ export const IdentityKinds = [
218218
"proxy",
219219
"basic-auth",
220220
"bearer",
221-
"asset",
222221
] as const;
223222

224223
export type IdentityKind = (typeof IdentityKinds)[number];

client/src/app/pages/identities/components/DefaultLabel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Icon, Tooltip } from "@patternfly/react-core";
44
import StarIcon from "@patternfly/react-icons/dist/esm/icons/star-icon";
55

66
import { Identity } from "@app/api/models";
7+
78
import { KIND_VALUES } from "../utils";
89

910
export interface DefaultLabelProps {

client/src/app/pages/identities/components/identity-form/__tests__/identity-form.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from "react";
2+
import "@testing-library/jest-dom";
3+
import { server } from "@mocks/server";
4+
import { rest } from "msw";
5+
26
import {
7+
fireEvent,
38
render,
4-
waitFor,
59
screen,
6-
fireEvent,
10+
waitFor,
711
} from "@app/test-config/test-utils";
812

9-
import "@testing-library/jest-dom";
10-
import { server } from "@mocks/server";
11-
import { rest } from "msw";
12-
1313
import { IdentityForm } from "..";
1414

1515
describe("Component: identity-form", () => {

client/src/app/pages/identities/components/identity-form/identity-form.tsx

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
import React from "react";
2+
import { yupResolver } from "@hookform/resolvers/yup";
3+
import { AxiosError } from "axios";
4+
import { FormProvider, useForm } from "react-hook-form";
25
import { useTranslation } from "react-i18next";
36
import * as yup from "yup";
4-
import { AxiosError } from "axios";
57
import {
68
ActionGroup,
79
Button,
810
ButtonVariant,
911
Form,
1012
} from "@patternfly/react-core";
11-
import { FormProvider, useForm } from "react-hook-form";
12-
import { yupResolver } from "@hookform/resolvers/yup";
1313

14-
import { OptionWithValue, SimpleSelect } from "@app/components/SimpleSelect";
1514
import { Identity, IdentityKind, IdentityKinds, New } from "@app/api/models";
16-
import { duplicateNameCheck, getAxiosErrorMessage } from "@app/utils/utils";
17-
import { toOptionLike } from "@app/utils/model-utils";
18-
import {
19-
useCreateIdentityMutation,
20-
useFetchIdentities,
21-
useUpdateIdentityMutation,
22-
} from "@app/queries/identities";
2315
import {
2416
HookFormPFGroupController,
2517
HookFormPFTextInput,
2618
} from "@app/components/HookFormPFFields";
2719
import { NotificationsContext } from "@app/components/NotificationsContext";
20+
import { OptionWithValue, SimpleSelect } from "@app/components/SimpleSelect";
21+
import {
22+
useCreateIdentityMutation,
23+
useFetchIdentities,
24+
useUpdateIdentityMutation,
25+
} from "@app/queries/identities";
26+
import { toOptionLike } from "@app/utils/model-utils";
27+
import { duplicateNameCheck, getAxiosErrorMessage } from "@app/utils/utils";
2828

2929
import { KIND_OPTIONS } from "../../utils";
30-
import { KindSourceForm } from "./kind-source-form";
31-
import { KindAssetForm } from "./kind-asset-form";
30+
31+
import { KindBearerTokenForm } from "./kind-bearer-token-form";
3232
import { KindMavenSettingsFileForm } from "./kind-maven-settings-file-form";
3333
import { KindSimpleUsernamePasswordForm } from "./kind-simple-username-password-form";
34-
import { KindBearerTokenForm } from "./kind-bearer-token-form";
34+
import { KindSourceForm } from "./kind-source-form";
3535

3636
import "./identity-form.css";
3737

@@ -70,7 +70,7 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
7070
const getUserCredentialsInitialValue = (
7171
identity?: Identity
7272
): UserCredentials | undefined => {
73-
if ("source" === identity?.kind || "asset" === identity?.kind) {
73+
if ("source" === identity?.kind) {
7474
if (identity?.user && identity?.password) {
7575
return "userpass";
7676
} else {
@@ -159,20 +159,6 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
159159
});
160160
}
161161

162-
if (kind === "asset" && formValues.userCredentials === "source") {
163-
Object.assign(payload, {
164-
key: formValues.key,
165-
password: formValues.password.trim(),
166-
});
167-
}
168-
169-
if (kind === "asset" && formValues.userCredentials === "userpass") {
170-
Object.assign(payload, {
171-
user: formValues.user.trim(),
172-
password: formValues.password.trim(),
173-
});
174-
}
175-
176162
if (kind === "basic-auth") {
177163
Object.assign(payload, {
178164
user: formValues.user.trim(),
@@ -237,7 +223,7 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
237223
default: yup.bool().defined(),
238224

239225
userCredentials: yup.mixed<UserCredentials>().when("kind", {
240-
is: (kind: IdentityKind) => kind === "source" || kind === "asset",
226+
is: (kind: IdentityKind) => kind === "source",
241227
then: (schema) => schema.required().oneOf(["userpass", "source"]),
242228
}),
243229

@@ -259,16 +245,6 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
259245
.string()
260246
.defined()
261247
.trim()
262-
.when(["kind", "userCredentials"], {
263-
is: (kind: IdentityKind, userCredentials: UserCredentials) =>
264-
(kind === "source" || kind === "asset") &&
265-
userCredentials === "userpass",
266-
then: (schema) =>
267-
schema
268-
.required(t("validation.required"))
269-
.min(3, t("validation.minLength", { length: 3 }))
270-
.max(120, t("validation.maxLength", { length: 120 })),
271-
})
272248
.when("kind", {
273249
is: (kind: IdentityKind) => kind === "proxy",
274250
then: (schema) =>
@@ -285,6 +261,15 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
285261
.min(3, t("validation.minLength", { length: 3 }))
286262
.max(120, t("validation.maxLength", { length: 120 }))
287263
.email("Username must be a valid email"),
264+
})
265+
.when(["kind", "userCredentials"], {
266+
is: (kind: IdentityKind, userCredentials: UserCredentials) =>
267+
kind === "source" && userCredentials === "userpass",
268+
then: (schema) =>
269+
schema
270+
.required(t("validation.required"))
271+
.min(3, t("validation.minLength", { length: 3 }))
272+
.max(120, t("validation.maxLength", { length: 120 })),
288273
}),
289274
password: yup
290275
.string()
@@ -308,8 +293,7 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
308293
})
309294
.when(["kind", "userCredentials"], {
310295
is: (kind: IdentityKind, userCredentials: UserCredentials) =>
311-
(kind === "source" || kind === "asset") &&
312-
userCredentials === "userpass",
296+
kind === "source" && userCredentials === "userpass",
313297
then: (schema) =>
314298
schema
315299
.required(t("validation.required"))
@@ -322,8 +306,7 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
322306
.defined()
323307
.when(["kind", "userCredentials"], {
324308
is: (kind: IdentityKind, userCredentials: UserCredentials) =>
325-
(kind === "source" || kind === "asset") &&
326-
userCredentials === "source",
309+
kind === "source" && userCredentials === "source",
327310
// If we want to verify key contents before saving, add the yup test in the then function
328311
then: (schema) => schema.required(t("validation.required")),
329312
})
@@ -417,8 +400,6 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
417400
/>
418401
)}
419402

420-
{values?.kind === "asset" && <KindAssetForm identity={identity} />}
421-
422403
{values?.kind === "maven" && (
423404
<KindMavenSettingsFileForm
424405
identity={identity}

client/src/app/pages/identities/components/identity-form/kind-asset-form.tsx

Lines changed: 0 additions & 150 deletions
This file was deleted.

client/src/app/pages/identities/components/identity-form/kind-bearer-token-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React, { useState } from "react";
22
import { useFormContext } from "react-hook-form";
33

44
import { Identity } from "@app/api/models";
5-
import KeyDisplayToggle from "@app/components/KeyDisplayToggle";
65
import { HookFormPFTextInput } from "@app/components/HookFormPFFields";
6+
import KeyDisplayToggle from "@app/components/KeyDisplayToggle";
77

88
export const KindBearerTokenForm: React.FC<{ identity?: Identity }> = ({
99
identity,

client/src/app/pages/identities/components/identity-form/kind-maven-settings-file-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from "react";
2+
import { useFormContext } from "react-hook-form";
23
import { Trans, useTranslation } from "react-i18next";
34
import { Alert, FileUpload, Switch } from "@patternfly/react-core";
4-
import { useFormContext } from "react-hook-form";
55

66
import { Identity, IdentityKind } from "@app/api/models";
77
import { HookFormPFGroupController } from "@app/components/HookFormPFFields";

client/src/app/pages/identities/components/identity-form/kind-simple-username-password-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React, { useState } from "react";
22
import { useFormContext } from "react-hook-form";
33

44
import { Identity } from "@app/api/models";
5-
import KeyDisplayToggle from "@app/components/KeyDisplayToggle";
65
import { HookFormPFTextInput } from "@app/components/HookFormPFFields";
6+
import KeyDisplayToggle from "@app/components/KeyDisplayToggle";
77

88
export const KindSimpleUsernamePasswordForm: React.FC<{
99
identity?: Identity;

client/src/app/pages/identities/components/identity-form/kind-source-form.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import React, { useState } from "react";
2+
import { useFormContext, useWatch } from "react-hook-form";
23
import { Trans, useTranslation } from "react-i18next";
34
import { Alert, FileUpload, Switch } from "@patternfly/react-core";
4-
import { useFormContext, useWatch } from "react-hook-form";
55

6-
import { OptionWithValue, SimpleSelect } from "@app/components/SimpleSelect";
76
import { Identity, IdentityKind } from "@app/api/models";
8-
import { toOptionLike } from "@app/utils/model-utils";
9-
import KeyDisplayToggle from "@app/components/KeyDisplayToggle";
107
import {
118
HookFormPFGroupController,
129
HookFormPFTextInput,
1310
} from "@app/components/HookFormPFFields";
11+
import KeyDisplayToggle from "@app/components/KeyDisplayToggle";
12+
import { OptionWithValue, SimpleSelect } from "@app/components/SimpleSelect";
13+
import { toOptionLike } from "@app/utils/model-utils";
14+
1415
import { UserCredentials } from "./identity-form";
1516
import { KindSimpleUsernamePasswordForm } from "./kind-simple-username-password-form";
1617

0 commit comments

Comments
 (0)