Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/embedded_spec.go

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

2 changes: 2 additions & 0 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3299,6 +3299,8 @@ paths:
post:
summary: Create IDP Configuration
operationId: CreateConfiguration
consumes:
- application/json
parameters:
- name: type
description: IDP Configuration Type
Expand Down
1 change: 1 addition & 0 deletions web-app/src/api/consoleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5091,6 +5091,7 @@ export class Api<
method: "POST",
body: body,
secure: true,
type: ContentType.Json,
format: "json",
...params,
}),
Expand Down
33 changes: 17 additions & 16 deletions web-app/src/screens/Console/IDP/AddIDPConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ import {
Switch,
} from "mds";
import { useNavigate } from "react-router-dom";
import { ErrorResponseHandler } from "../../../common/types";
import { useAppDispatch } from "../../../store";
import { modalStyleUtils } from "../Common/FormComponents/common/styleLibrary";
import {
setErrorSnackMessage,
setHelpName,
setServerNeedsRestart,
} from "../../../systemSlice";
import useApi from "../Common/Hooks/useApi";
import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper";
import HelpMenu from "../HelpMenu";
import { api } from "api";
import { ApiError, HttpResponse, SetIDPResponse } from "api/consoleApi";
import { errorToHandler } from "api/errors";

type AddIDPConfigurationProps = {
classes?: any;
Expand All @@ -46,7 +47,6 @@ type AddIDPConfigurationProps = {
title: string;
backLink: string;
formFields: object;
endpoint: string;
};

const AddIDPConfiguration = ({
Expand All @@ -56,7 +56,6 @@ const AddIDPConfiguration = ({
backLink,
title,
formFields,
endpoint,
}: AddIDPConfigurationProps) => {
const extraFormFields = {
name: {
Expand All @@ -76,16 +75,7 @@ const AddIDPConfiguration = ({
const dispatch = useAppDispatch();

const [fields, setFields] = useState<any>({});

const onSuccess = (res: any) => {
navigate(backLink);
dispatch(setServerNeedsRestart(res.restart === true));
};

const onError = (err: ErrorResponseHandler) =>
dispatch(setErrorSnackMessage(err));

const [loading, invokeApi] = useApi(onSuccess, onError);
const [loadingCreate, setLoadingCreate] = useState<boolean>(false);

const validSave = () => {
for (const [key, value] of Object.entries(extraFormFields)) {
Expand All @@ -108,6 +98,7 @@ const AddIDPConfiguration = ({
};

const addRecord = (event: React.FormEvent) => {
setLoadingCreate(true);
event.preventDefault();
const name = fields["name"];
let input = "";
Expand All @@ -116,7 +107,17 @@ const AddIDPConfiguration = ({
input += `${key}=${fields[key]} `;
}
}
invokeApi("POST", endpoint, { name, input });

api.idp
.createConfiguration("openid", { name, input })
.then((res: HttpResponse<SetIDPResponse, ApiError>) => {
navigate(backLink);
dispatch(setServerNeedsRestart(res.data.restart === true));
})
.catch(async (res: HttpResponse<SetIDPResponse, ApiError>) => {
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
})
.finally(() => setLoadingCreate(false));
};

const renderFormField = (key: string, value: any) => {
Expand Down Expand Up @@ -197,7 +198,7 @@ const AddIDPConfiguration = ({
type="submit"
variant="callAction"
color="primary"
disabled={loading || !validSave()}
disabled={loadingCreate || !validSave()}
label={"Save"}
/>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const AddIDPOpenIDConfiguration = () => {
header={"OpenID Configurations"}
backLink={IAM_PAGES.IDP_OPENID_CONFIGURATIONS}
title={"Create OpenID Configuration"}
endpoint={"/api/v1/idp/openid/"}
formFields={openIDFormFields}
/>
);
Expand Down