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

[🧹 UNIFICATION CLEANUP] Refactor extensions/components directory #6882

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions .changeset/plenty-garlics-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@wso2is/admin.server-configurations.v1": minor
"@wso2is/admin.sms-providers.v1": minor
"@wso2is/admin.connections.v1": minor
"@wso2is/admin.extensions.v1": minor
"@wso2is/admin.validation.v1": minor
"@wso2is/admin.core.v1": minor
---

Completely refactor the admin.extensions.v1/components directly and move the logic to related features.
30 changes: 0 additions & 30 deletions features/admin.connections.v1/api/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { IdentityAppsApiException } from "@wso2is/core/exceptions";
import { HttpMethods } from "@wso2is/core/models";
import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
import { ConnectionUIConstants } from "../constants/connection-ui-constants";
import { NotificationSenderSMSInterface } from "../models/authenticators";
import {
ApplicationBasicInterface,
ConnectedAppsInterface,
Expand Down Expand Up @@ -1071,35 +1070,6 @@ export const updateImplicitAssociationConfig = (
});
};

/**
* Hook to get all sms notification senders with name SMSPublisher.
*
* @returns A promise containing the response.
*/
export const useSMSNotificationSenders = <Data = NotificationSenderSMSInterface[], Error = RequestErrorInterface>():
RequestResultInterface<Data, Error> => {
const { resourceEndpoints } = useResourceEndpoints();

const requestConfig: RequestConfigInterface = {
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
method: HttpMethods.GET,
url: resourceEndpoints.notificationSendersEndPoint + "/sms"
};

const { data, error, isValidating, mutate } = useRequest<Data, Error>(requestConfig);

return {
data,
error: error,
isLoading: !error && !data,
isValidating,
mutate: mutate
};
};

/**
* Get connection groups list.
*
Expand Down
54 changes: 37 additions & 17 deletions features/admin.connections.v1/components/edit/connection-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ import React, {
useEffect,
useState
} from "react";
import { useTranslation } from "react-i18next";
import { useSelector } from "react-redux";
import { TabProps } from "semantic-ui-react";
import QuickStartTab from "./quick-start-tab";
import {
AdvanceSettings,
AttributeSettings,
Expand Down Expand Up @@ -153,6 +155,8 @@ export const EditConnection: FunctionComponent<EditConnectionPropsInterface> = (
[ "data-testid" ]: testId
} = props;

const { t } = useTranslation();

const featureConfig : FeatureConfigInterface = useSelector((state: AppState) => state.config.ui.features);

const [ tabPaneExtensions, setTabPaneExtensions ] = useState<ResourceTabPaneInterface[]>(undefined);
Expand Down Expand Up @@ -375,24 +379,40 @@ export const EditConnection: FunctionComponent<EditConnectionPropsInterface> = (
let extensions: ResourceTabPaneInterface[] = [];

if (typeof connectionSettingsMetaData?.edit?.tabs?.quickStart === "string") {
extensions = identityProviderConfig
.editIdentityProvider.getTabExtensions({
content: lazy(
() => import(`../../resources/guides/${
connectionSettingsMetaData?.edit?.tabs?.quickStart
}/quick-start.tsx`)
),
identityProvider: identityProvider,
template: template
});
extensions = [
{
componentId: "quick-start",
menuItem: t("console:develop.componentExtensions.component.application.quickStart.title"),
render: () => (
<QuickStartTab
content={ lazy(() =>
import(
`../../resources/guides/${
connectionSettingsMetaData?.edit?.tabs?.quickStart
}/quick-start.tsx`
)
) }
identityProvider={ identityProvider }
template={ template }
/>
)
}
];
} else {
extensions = identityProviderConfig
.editIdentityProvider.getTabExtensions({
content: lazy(() => import("./connection-quick-start")),
identityProvider: identityProvider,
quickStartContent: connectionSettingsMetaData?.edit?.tabs?.quickStart,
template: template
});
extensions = [
{
componentId: "quick-start",
menuItem: t("console:develop.componentExtensions.component.application.quickStart.title"),
render: () => (
<QuickStartTab
content={ lazy(() => import("./connection-quick-start")) }
identityProvider={ identityProvider }
quickStartContent={ connectionSettingsMetaData?.edit?.tabs?.quickStart }
template={ template }
/>
)
}
];
}

if (Array.isArray(extensions) && extensions.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
* under the License.
*/

import {
AuthenticatorExtensionsConfigInterface,
identityProviderConfig
} from "@wso2is/admin.extensions.v1";
import { AuthenticatorExtensionsConfigInterface } from "@wso2is/admin.extensions.v1";
import { authenticatorConfig } from "@wso2is/admin.extensions.v1/configs/authenticator";
import { AuthenticatorFormFactory } from "@wso2is/admin.identity-providers.v1/components/forms";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
Expand All @@ -32,6 +29,7 @@ import { useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
import { Dispatch } from "redux";
import { Grid, SemanticShorthandItem, TabPaneProps } from "semantic-ui-react";
import QuickStartTab from "./quick-start-tab";
import { updateMultiFactorAuthenticatorDetails } from "../../api/authenticators";
import { LocalAuthenticatorConstants } from "../../constants/local-authenticator-constants";
import { AuthenticatorMeta } from "../../meta/authenticator-meta";
Expand Down Expand Up @@ -116,10 +114,13 @@ export const EditMultiFactorAuthenticator: FunctionComponent<EditMultiFactorAuth
return;
}

const extensions: ResourceTabPaneInterface[] = identityProviderConfig
.editIdentityProvider.getTabExtensions({
content: authenticatorConfig.content.quickStart
});
const extensions: ResourceTabPaneInterface[] = [
{
componentId: "quick-start",
menuItem: t("console:develop.componentExtensions.component.application.quickStart.title"),
render: () => <QuickStartTab content={ authenticatorConfig.content.quickStart } />
}
];

setTabPaneExtensions(extensions);
}, [ authenticator, tabPaneExtensions ]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
* Copyright (c) 2020-2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand All @@ -21,28 +21,36 @@ import { ResourceTab } from "@wso2is/react-components";
import React, { ElementType, FunctionComponent, ReactElement } from "react";
import { Grid } from "semantic-ui-react";

/**
* Props interface for the QuickStartTab component.
*/
interface QuickStartTabPropsInterface extends TestableComponentInterface {
/**
* Content to be rendered.
*/
content: ElementType;
/**
* Dynamic attributes for the component.
*/
[key: string]: any;
}

/**
* A function returning a ReactElement to render tab panes.
* QuickStartTab component.
*
* @param props - Props injected to the component.
* @returns The QuickStartTab component.
*/
const QuickStartTab: FunctionComponent<QuickStartTabPropsInterface> = (
props: QuickStartTabPropsInterface
): ReactElement => {

const {
content: Content,
[ "data-testid" ]: testId,
...rest
} = props;

const QuickStartTab: FunctionComponent<QuickStartTabPropsInterface> = ({
content: Content,
["data-testid"]: testId,
...rest
}: QuickStartTabPropsInterface): ReactElement => {
return (
<ResourceTab.Pane controlledSegmentation>
<Grid>
<Grid.Row>
<Grid.Column width={ 16 } >
<Grid.Column width={ 16 }>
<Content data-testid={ testId } { ...rest } />
</Grid.Column>
</Grid.Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@
/**
* Class containing Sign In With Ethereum IDP constants.
*/
export class SIWEConstants {
class SIWEConstants {
/**
* Private constructor to avoid object instantiation from outside the class.
*/
private constructor() {}

public static readonly SIWE_REGISTRATION_INVALID_STATUS_CODE_ERROR_CODE: string = "ASG-CON-SIWE-00001";
public static readonly SIWE_REGISTRATION_ERROR_CODE: string = "ASG-CON-SIWE-00002";

/**
* Private constructor to avoid object instantiation from outside
* the class.
*
] */
private constructor() { }

public static readonly SIWE_CLIENT_REGISTRATION_DOCS_URL: string = "https://docs.login.xyz/servers/" +
"oidc-provider/hosted-oidc-provider#openid-connect-client-registration";

Expand All @@ -52,5 +49,7 @@ export class SIWEConstants {
CALLBACK_URL: "callbackUrl",
CLIENT_ID: "ClientId",
CLIENT_SECRET: "ClientSecret"
}
};
}

export default SIWEConstants;
14 changes: 0 additions & 14 deletions features/admin.connections.v1/models/authenticators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,3 @@ export type CommonAuthenticatorFormPropertyInterface = CommonPluggableComponentP
export interface CommonAuthenticatorFormFieldInterface extends CommonAuthenticatorFormPropertyInterface {
meta: CommonPluggableComponentMetaPropertyInterface;
}

/**
* Interface for SMS Notification Sender Details.
**/
export interface NotificationSenderSMSInterface {
name: string;
provider: string;
providerURL: string;
contentType: string;
properties?: {
key: string;
value: string;
}[];
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
* Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down
2 changes: 2 additions & 0 deletions features/admin.core.v1/configs/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { getRemoteFetchConfigResourceEndpoints } from "@wso2is/admin.remote-repo
import { getRolesResourceEndpoints } from "@wso2is/admin.roles.v2/configs/endpoints";
import { getSecretsManagementEndpoints } from "@wso2is/admin.secrets.v1/configs/endpoints";
import { getServerConfigurationsResourceEndpoints } from "@wso2is/admin.server-configurations.v1";
import { getSMSProvidersResourceEndpoints } from "@wso2is/admin.sms-providers.v1/configs/endpoints";
import { getExtensionTemplatesEndpoints } from "@wso2is/admin.template-core.v1/configs/endpoints";
import { getTenantResourceEndpoints } from "@wso2is/admin.tenants.v1/configs/endpoints";
import { getUsersResourceEndpoints } from "@wso2is/admin.users.v1/configs/endpoints";
Expand Down Expand Up @@ -266,6 +267,7 @@ export class Config {
...getExtensionTemplatesEndpoints(this.resolveServerHost()),
...getApplicationTemplatesResourcesEndpoints(this.resolveServerHost()),
...getActionsResourceEndpoints(this.resolveServerHost()),
...getSMSProvidersResourceEndpoints(this.resolveServerHost()),
CORSOrigins: `${ this.getDeploymentConfig()?.serverHost }/api/server/v1/cors/origins`,
// TODO: Remove this endpoint and use ID token to get the details
me: `${ this.getDeploymentConfig()?.serverHost }/scim2/Me`,
Expand Down
4 changes: 3 additions & 1 deletion features/admin.core.v1/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { OrganizationResourceEndpointsInterface } from "@wso2is/admin.organizati
import { RolesResourceEndpointsInterface } from "@wso2is/admin.roles.v2/models/endpoints";
import { SecretsManagementEndpoints } from "@wso2is/admin.secrets.v1/models/endpoints";
import { ServerConfigurationsResourceEndpointsInterface } from "@wso2is/admin.server-configurations.v1";
import { SMSProvidersResourceEndpointsInterface } from "@wso2is/admin.sms-providers.v1/models/endpoints";
import { ExtensionTemplatesEndpointsInterface } from "@wso2is/admin.template-core.v1/models/endpoints";
import { TenantResourceEndpointsInterface } from "@wso2is/admin.tenants.v1/models/endpoints";
import { UsersResourceEndpointsInterface } from "@wso2is/admin.users.v1/models/endpoints";
Expand Down Expand Up @@ -541,7 +542,8 @@ export interface ServiceResourceEndpointsInterface extends ClaimResourceEndpoint
ConsoleSettingsResourceEndpointsInterface,
ExtensionTemplatesEndpointsInterface,
ApplicationsTemplatesEndpointsInterface,
ActionsResourceEndpointsInterface {
ActionsResourceEndpointsInterface,
SMSProvidersResourceEndpointsInterface {

CORSOrigins: string;
// TODO: Remove this endpoint and use ID token to get the details
Expand Down
2 changes: 2 additions & 0 deletions features/admin.core.v1/store/reducers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ export const commonConfigReducerInitialState: CommonConfigReducerStateInterface<
selfSignUp: "",
serverConfigurations: "",
serverSupportedSchemas: "",
smsPublisher: "",
smsSender: "",
tenantAssociationApi: "",
tenantManagementApi: "",
tenantSubscriptionApi: "",
Expand Down
Loading
Loading