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

Updating SSO types + minor fixes #5183

Merged
merged 8 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const AddModal = ({
</Heading>
</Box>
</ModalHeader>
<ModalBody pb={4} overflow="scroll">
<ModalBody pb={4} overflow="auto">
galvana marked this conversation as resolved.
Show resolved Hide resolved
{children}
</ModalBody>
</ModalContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,31 @@ const SSOProvider = ({
}: {
openIDProvider: OpenIDProvider;
}) => {
const { onOpen, isOpen, onClose } = useDisclosure();
const { isOpen: deleteIsOpen, onClose: onDeleteClose } = useDisclosure();
const {
onOpen: onEditOpen,
isOpen: isEditOpen,
onClose: onEditClose,
} = useDisclosure();
const {
onOpen: onDeleteOpen,
isOpen: deleteIsOpen,
onClose: onDeleteClose,
} = useDisclosure();
galvana marked this conversation as resolved.
Show resolved Hide resolved
const toast = useToast();

const [deleteOpenIDProviderMutation] = useDeleteOpenIDProviderMutation();

const handleDelete = async () => {
const result = await deleteOpenIDProviderMutation(openIDProvider.id);
const result = await deleteOpenIDProviderMutation(
openIDProvider.identifier,
);
if (isErrorResult(result)) {
toast(errorToastParams(getErrorMessage(result.error)));
onDeleteClose();
return;
}

toast(successToastParams(`OpenID Provider deleted successfully`));
toast(successToastParams(`SSO provider deleted successfully`));
galvana marked this conversation as resolved.
Show resolved Hide resolved

onDeleteClose();
};
Expand Down Expand Up @@ -69,7 +79,7 @@ const SSOProvider = ({
size="sm"
marginRight="12px"
variant="outline"
onClick={onDeleteClose}
onClick={onDeleteOpen}
galvana marked this conversation as resolved.
Show resolved Hide resolved
data-testid="remove-sso-provider-btn"
>
Remove
Expand All @@ -78,15 +88,15 @@ const SSOProvider = ({
size="sm"
marginRight="12px"
variant="outline"
onClick={onOpen}
onClick={onEditOpen}
data-testid="edit-sso-provider-btn"
>
Edit
</Button>
</Box>
<EditSSOProviderModal
isOpen={isOpen}
onClose={onClose}
isOpen={isEditOpen}
onClose={onEditClose}
openIDProvider={openIDProvider}
/>
<ConfirmationModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,31 @@ import {
useCreateOpenIDProviderMutation,
useUpdateOpenIDProviderMutation,
} from "~/features/openid-authentication/openprovider.slice";
import { OpenIDProvider } from "~/types/api";
import {
OpenIDProvider,
OpenIDProviderCreate,
ProviderEnum,
} from "~/types/api";

interface SSOProviderFormProps {
openIDProvider?: OpenIDProvider;
onSuccess?: (openIDProvider: OpenIDProvider) => void;
onClose: () => void;
}

export interface SSOProviderFormValues extends OpenIDProvider {}
export type SSOProviderFormValues = Omit<
OpenIDProviderCreate,
"provider" | "client_id" | "client_secret"
> & {
id?: string;
provider?: ProviderEnum;
client_id?: string;
client_secret?: string;
};

export const defaultInitialValues: SSOProviderFormValues = {
id: "",
identifier: "",
name: "",
provider: "",
client_id: "",
client_secret: "",
};
Expand Down Expand Up @@ -67,21 +77,21 @@ const SSOProviderForm = ({
) => {
const handleResult = (
result:
| { data: object }
| { data: OpenIDProvider }
| { error: FetchBaseQueryError | SerializedError },
) => {
if (isErrorResult(result)) {
const errorMsg = getErrorMessage(
result.error,
"An unexpected error occurred while editing the OpenID Provider. Please try again.",
"An unexpected error occurred while editing the SSO provider. Please try again.",
);
toast(errorToastParams(errorMsg));
} else {
toast(successToastParams("OpenID Provider configuration saved."));
toast(successToastParams("SSO provider configuration saved."));
onClose();
formikHelpers.resetForm({});
if (onSuccess) {
onSuccess(values);
onSuccess(result.data);
}
}
};
Expand Down Expand Up @@ -164,6 +174,7 @@ const SSOProviderForm = ({
tooltip="Unique identifier for your provider"
variant="stacked"
isRequired
disabled={!!initialValues.id}
galvana marked this conversation as resolved.
Show resolved Hide resolved
/>
<CustomTextInput
id="name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const SSOProvidersSection = () => {

const renderItems: () => JSX.Element[] | undefined = () =>
openidProviders?.map((item: OpenIDProvider) => (
<SSOProvider key={item.id} openIDProvider={item} />
<SSOProvider key={item.identifier} openIDProvider={item} />
));

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const openIDProviderApi = baseApi.injectEndpoints({
}),
updateOpenIDProvider: build.mutation<
OpenIDProvider,
Partial<OpenIDProvider> & Pick<OpenIDProvider, "id">
Partial<OpenIDProvider> & Pick<OpenIDProvider, "identifier">
>({
query: (params) => ({
url: `plus/openid-provider/${params.id}`,
url: `plus/openid-provider/${params.identifier}`,
method: "PATCH",
body: params,
}),
Expand Down
2 changes: 1 addition & 1 deletion clients/admin-ui/src/features/user-management/UserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const UserForm = ({ onSubmit, initialValues, canEditNames }: Props) => {
const { data: openidProviders } = useGetAllOpenIDProvidersQuery();

const passwordFieldIsRequired =
!flags.openIDAuthentication || !openidProviders?.length;
!flags.ssoAuthentication || !openidProviders?.length;

if (!passwordFieldIsRequired) {
validationSchema = ValidationSchema.shape({
Expand Down
4 changes: 2 additions & 2 deletions clients/admin-ui/src/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"test": true,
"production": false
},
"openIDAuthentication": {
"description": "OpenID authentication",
"ssoAuthentication": {
"description": "SSO Authentication Providers (OpenID)",
"development": true,
"test": true,
"production": false
Expand Down
11 changes: 0 additions & 11 deletions clients/admin-ui/src/mocks/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,11 @@ export const mockConsentableItems: ConsentableItem[] = [
external_id: "34419",
type: "Channel",
name: "Default SMS channel (SMS)",
notice_id: null,
children: [
{
external_id: "40007",
type: "Message type",
name: "Default SMS message type",
notice_id: null,
children: [],
unmapped: true,
},
Expand All @@ -290,13 +288,11 @@ export const mockConsentableItems: ConsentableItem[] = [
external_id: "34415",
type: "Channel",
name: "Default InApp channel (InApp)",
notice_id: null,
children: [
{
external_id: "40003",
type: "Message type",
name: "Default InApp message type",
notice_id: null,
children: [],
unmapped: true,
},
Expand All @@ -307,13 +303,11 @@ export const mockConsentableItems: ConsentableItem[] = [
external_id: "33843",
type: "Channel",
name: "Push Marketing Channel (Push)",
notice_id: null,
children: [
{
external_id: "39240",
type: "Message type",
name: "Push Marketing Message",
notice_id: null,
children: [],
unmapped: true,
},
Expand All @@ -324,13 +318,11 @@ export const mockConsentableItems: ConsentableItem[] = [
external_id: "33842",
type: "Channel",
name: "Transactional Channel (Email)",
notice_id: null,
children: [
{
external_id: "39239",
type: "Message type",
name: "Transactional Message",
notice_id: null,
children: [],
unmapped: true,
},
Expand All @@ -341,21 +333,18 @@ export const mockConsentableItems: ConsentableItem[] = [
external_id: "33841",
type: "Channel",
name: "Marketing Channel (Email)",
notice_id: null,
children: [
{
external_id: "40000",
type: "Message type",
name: "Untitled message type",
notice_id: null,
children: [],
unmapped: true,
},
{
external_id: "39238",
type: "Message type",
name: "Marketing Message",
notice_id: null,
children: [],
unmapped: true,
},
Expand Down
4 changes: 2 additions & 2 deletions clients/admin-ui/src/pages/settings/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const OrganizationPage: NextPage = () => {
);
const {
plus: hasPlus,
flags: { openIDAuthentication },
flags: { ssoAuthentication },
} = useFeatures();

return (
Expand All @@ -36,7 +36,7 @@ const OrganizationPage: NextPage = () => {
<Box background="gray.50" padding={2}>
<OrganizationForm organization={organization} />
</Box>
{openIDAuthentication && hasPlus && (
{ssoAuthentication && hasPlus && (
<Restrict scopes={[ScopeRegistryEnum.OPENID_PROVIDER_CREATE]}>
<OpenIDAuthenticationSection />
</Restrict>
Expand Down
6 changes: 5 additions & 1 deletion clients/admin-ui/src/types/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export type { IdentityTypes } from "./models/IdentityTypes";
export type { IdentityVerificationConfigResponse } from "./models/IdentityVerificationConfigResponse";
export { IncludeExcludeEnum } from "./models/IncludeExcludeEnum";
export type { Language } from "./models/Language";
export { Layer1ButtonOption } from "./models/Layer1ButtonOption";
export { LegalBasisForProcessingEnum } from "./models/LegalBasisForProcessingEnum";
export { LegalBasisForProfilingEnum } from "./models/LegalBasisForProfilingEnum";
export type { LimitedPrivacyNoticeResponseSchema } from "./models/LimitedPrivacyNoticeResponseSchema";
Expand Down Expand Up @@ -253,6 +254,9 @@ export type { NoticeTranslationCreate } from "./models/NoticeTranslationCreate";
export type { NoticeTranslationResponse } from "./models/NoticeTranslationResponse";
export type { NotificationApplicationConfig } from "./models/NotificationApplicationConfig";
export type { OktaConfig } from "./models/OktaConfig";
export type { OpenIDProvider } from "./models/OpenIDProvider";
export type { OpenIDProviderCreate } from "./models/OpenIDProviderCreate";
export type { OpenIDProviderSimple } from "./models/OpenIDProviderSimple";
export type { Organization } from "./models/Organization";
export type { OrganizationMetadata } from "./models/OrganizationMetadata";
export type { Page_BasicSystemResponse_ } from "./models/Page_BasicSystemResponse_";
Expand Down Expand Up @@ -306,7 +310,6 @@ export type { PreApprovalWebhookResponse } from "./models/PreApprovalWebhookResp
export type { PreApprovalWebhookUpdate } from "./models/PreApprovalWebhookUpdate";
export type { PreferencesSaved } from "./models/PreferencesSaved";
export type { PreferencesSavedExtended } from "./models/PreferencesSavedExtended";
export type { OpenIDProvider } from "./models/OpenIDProvider";
export type { PreferenceWithNoticeInformation } from "./models/PreferenceWithNoticeInformation";
export type { PrivacyCenterConfig } from "./models/PrivacyCenterConfig";
export type { PrivacyDeclaration } from "./models/PrivacyDeclaration";
Expand Down Expand Up @@ -337,6 +340,7 @@ export type { PrivacyRequestVerboseResponse } from "./models/PrivacyRequestVerbo
export type { PrivacyRule } from "./models/PrivacyRule";
export type { Property } from "./models/Property";
export { PropertyType } from "./models/PropertyType";
export { ProviderEnum } from "./models/ProviderEnum";
export type { PublicPropertyResponse } from "./models/PublicPropertyResponse";
export type { PurposesResponse } from "./models/PurposesResponse";
export type { QueryParam } from "./models/QueryParam";
Expand Down
14 changes: 9 additions & 5 deletions clients/admin-ui/src/types/api/models/ConsentableItem.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

/**
* 3rd-party consentable item and privacy notice relationships
* Schema to represent 3rd-party consentable items and privacy notice relationships.
*/
export interface ConsentableItem {
export type ConsentableItem = {
external_id: string;
type: string;
name: string;
notice_id?: string | null;
children?: ConsentableItem[];
notice_id?: string;
children?: Array<ConsentableItem>;
unmapped?: boolean;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/* tslint:disable */
/* eslint-disable */

import { Layer1ButtonOption } from "~/features/privacy-experience/form/constants";
import type { ComponentType } from "./ComponentType";
import type { ExperienceTranslationCreate } from "./ExperienceTranslationCreate";
import type { Layer1ButtonOption } from "./Layer1ButtonOption";
import type { MinimalProperty } from "./MinimalProperty";
import type { PrivacyNoticeRegion } from "./PrivacyNoticeRegion";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/* tslint:disable */
/* eslint-disable */

import { Layer1ButtonOption } from "~/features/privacy-experience/form/constants";
import type { ComponentType } from "./ComponentType";
import type { ExperienceTranslationResponse } from "./ExperienceTranslationResponse";
import type { Layer1ButtonOption } from "./Layer1ButtonOption";
import type { MinimalProperty } from "./MinimalProperty";
import type { PrivacyNoticeRegion } from "./PrivacyNoticeRegion";
import type { PrivacyNoticeResponse } from "./PrivacyNoticeResponse";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/* tslint:disable */
/* eslint-disable */

import { Layer1ButtonOption } from "~/features/privacy-experience/form/constants";
import type { ComponentType } from "./ComponentType";
import type { ExperienceTranslationResponse } from "./ExperienceTranslationResponse";
import type { Layer1ButtonOption } from "./Layer1ButtonOption";
import type { MinimalProperty } from "./MinimalProperty";
import type { PrivacyNoticeRegion } from "./PrivacyNoticeRegion";
import type { SupportedLanguage } from "./SupportedLanguage";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/* tslint:disable */
/* eslint-disable */

import { Layer1ButtonOption } from "~/features/privacy-experience/form/constants";
import type { ExperienceTranslation } from "./ExperienceTranslation";
import type { Layer1ButtonOption } from "./Layer1ButtonOption";
import type { MinimalProperty } from "./MinimalProperty";
import type { PrivacyNoticeRegion } from "./PrivacyNoticeRegion";

Expand Down
11 changes: 11 additions & 0 deletions clients/admin-ui/src/types/api/models/Layer1ButtonOption.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

/**
* Layer 1 button options - not formalized in the db
*/
export enum Layer1ButtonOption {
ACKNOWLEDGE = "acknowledge",
OPT_IN_OPT_OUT = "opt_in_opt_out",
}
Loading
Loading