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

changed to use ui-shared #27919

Merged
merged 2 commits into from Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/apps/admin-ui/cypress/e2e/clients_test.spec.ts
Expand Up @@ -196,7 +196,7 @@
cy.intercept("/admin/realms/master/client-scopes").as("load");
commonPage.tableToolbarUtils().clickSearchButton();
cy.wait("@load");
cy.wait(1000);

Check warning on line 199 in js/apps/admin-ui/cypress/e2e/clients_test.spec.ts

View workflow job for this annotation

GitHub Actions / Admin UI

Do not wait for arbitrary time periods
commonPage.tableToolbarUtils().checkActionItemIsEnabled("Remove", false);
commonPage.tableToolbarUtils().searchItem(clientScopeName, false);
commonPage
Expand All @@ -206,7 +206,7 @@
cy.intercept("/admin/realms/master/client-scopes").as("load");
commonPage.tableToolbarUtils().clickSearchButton();
cy.wait("@load");
cy.wait(1000);

Check warning on line 209 in js/apps/admin-ui/cypress/e2e/clients_test.spec.ts

View workflow job for this annotation

GitHub Actions / Admin UI

Do not wait for arbitrary time periods
commonPage.tableToolbarUtils().clickActionItem("Remove");
commonPage.masthead().checkNotificationMessage(msgScopeMappingRemoved);
commonPage.tableToolbarUtils().searchItem(clientScopeName, false);
Expand Down Expand Up @@ -536,7 +536,7 @@
{ action: "drag-drop" },
);

cy.wait(1000);

Check warning on line 539 in js/apps/admin-ui/cypress/e2e/clients_test.spec.ts

View workflow job for this annotation

GitHub Actions / Admin UI

Do not wait for arbitrary time periods
//cy.findByTestId("realm-file").contains('"clientId": "identical"')
cy.findByTestId("clientId").click();
cy.findByText("Save").click();
Expand Down Expand Up @@ -854,8 +854,8 @@

advancedTab.revertAuthFlowOverride();
advancedTab.jumpToAuthFlow();
advancedTab.checkBrowserFlowInput("");
advancedTab.checkDirectGrantInput("");
advancedTab.checkBrowserFlowInput("Choose...");
advancedTab.checkDirectGrantInput("Choose...");
advancedTab.selectBrowserFlowInput("browser");
advancedTab.selectDirectGrantInput("docker auth");

Expand Down
Expand Up @@ -13,7 +13,7 @@ export default class AdvancedTab extends PageObject {
#nodeHostInput = "node";
#addNodeConfirmBtn = "#add-node-confirm";

#accessTokenSignatureAlgorithmInput = "#accessTokenSignatureAlgorithm";
#accessTokenSignatureAlgorithmInput = "#access🍺token🍺signed🍺response🍺alg";
#fineGrainSaveBtn = "#fineGrainSave";
#fineGrainRevertBtn = "#fineGrainRevert";
#OIDCCompatabilitySaveBtn = "OIDCCompatabilitySave";
Expand All @@ -36,8 +36,8 @@ export default class AdvancedTab extends PageObject {
#pushedAuthorizationRequestRequiredSwitch =
"attributes.require🍺pushed🍺authorization🍺requests";

#browserFlowInput = "#browserFlow";
#directGrantInput = "#directGrant";
#browserFlowInput = "#browser";
#directGrantInput = "#direct_grant";

#jumpToOIDCCompatabilitySettings =
"jump-link-openid-connect-compatibility-modes";
Expand Down
116 changes: 28 additions & 88 deletions js/apps/admin-ui/src/clients/advanced/AuthenticationOverrides.tsx
@@ -1,20 +1,11 @@
import {
ActionGroup,
Button,
FormGroup,
Select,
SelectOption,
SelectVariant,
} from "@patternfly/react-core";
import AuthenticationFlowRepresentation from "@keycloak/keycloak-admin-client/lib/defs/authenticationFlowRepresentation";
import { ActionGroup, Button } from "@patternfly/react-core";
import { sortBy } from "lodash-es";
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";

import { FormAccess } from "../../components/form/FormAccess";
import { HelpItem } from "ui-shared";

import { SelectControl } from "ui-shared";
import { adminClient } from "../../admin-client";
import { FormAccess } from "../../components/form/FormAccess";
import { useFetch } from "../../utils/useFetch";

type AuthenticationOverridesProps = {
Expand All @@ -31,11 +22,7 @@ export const AuthenticationOverrides = ({
hasConfigureAccess,
}: AuthenticationOverridesProps) => {
const { t } = useTranslation();
const [flows, setFlows] = useState<JSX.Element[]>([]);
const [browserFlowOpen, setBrowserFlowOpen] = useState(false);
const [directGrantOpen, setDirectGrantOpen] = useState(false);

const { control } = useFormContext();
const [flows, setFlows] = useState<AuthenticationFlowRepresentation[]>([]);

useFetch(
() => adminClient.authenticationManagement.getFlows(),
Expand All @@ -44,16 +31,7 @@ export const AuthenticationOverrides = ({
...flows.filter((flow) => flow.providerId !== "client-flow"),
];
filteredFlows = sortBy(filteredFlows, [(f) => f.alias]);
setFlows([
<SelectOption key="empty" value="">
{t("choose")}
</SelectOption>,
...filteredFlows.map((flow) => (
<SelectOption key={flow.id} value={flow.id}>
{flow.alias}
</SelectOption>
)),
]);
setFlows(filteredFlows);
},
[],
);
Expand All @@ -64,69 +42,31 @@ export const AuthenticationOverrides = ({
fineGrainedAccess={hasConfigureAccess}
isHorizontal
>
<FormGroup
<SelectControl
name="authenticationFlowBindingOverrides.browser"
label={t("browserFlow")}
fieldId="browserFlow"
labelIcon={
<HelpItem
helpText={t("browserFlowHelp")}
fieldLabelId="browserFlow"
/>
}
>
<Controller
name="authenticationFlowBindingOverrides.browser"
defaultValue=""
control={control}
render={({ field }) => (
<Select
toggleId="browserFlow"
variant={SelectVariant.single}
onToggle={setBrowserFlowOpen}
isOpen={browserFlowOpen}
onSelect={(_, value) => {
field.onChange(value);
setBrowserFlowOpen(false);
}}
selections={[field.value]}
>
{flows}
</Select>
)}
/>
</FormGroup>
labelIcon={t("browserFlowHelp")}
controller={{
defaultValue: "",
}}
options={[
{ key: "", value: t("choose") },
...flows.map(({ id, alias }) => ({ key: id!, value: alias! })),
]}
/>
{protocol === "openid-connect" && (
<FormGroup
<SelectControl
name="authenticationFlowBindingOverrides.direct_grant"
label={t("directGrant")}
fieldId="directGrant"
labelIcon={
<HelpItem
helpText={t("directGrantHelp")}
fieldLabelId="directGrant"
/>
}
>
<Controller
name="authenticationFlowBindingOverrides.direct_grant"
defaultValue=""
control={control}
render={({ field }) => (
<Select
toggleId="directGrant"
variant={SelectVariant.single}
onToggle={setDirectGrantOpen}
isOpen={directGrantOpen}
onSelect={(_, value) => {
field.onChange(value);
setDirectGrantOpen(false);
}}
selections={[field.value]}
>
{flows}
</Select>
)}
/>
</FormGroup>
labelIcon={t("directGrantHelp")}
controller={{
defaultValue: "",
}}
options={[
{ key: "", value: t("choose") },
...flows.map(({ id, alias }) => ({ key: id!, value: alias! })),
]}
/>
)}
<ActionGroup>
<Button
Expand Down