Skip to content

Commit

Permalink
Merge pull request #6744 from brionmario/code-cleanup-2024-extensions
Browse files Browse the repository at this point in the history
[🧹 UNIFICATION CLEANUP] Refactor `admin.extensions.v1/components/application`
  • Loading branch information
brionmario authored Aug 13, 2024
2 parents 2da6075 + 14e0437 commit a62b383
Show file tree
Hide file tree
Showing 39 changed files with 490 additions and 6,569 deletions.
8 changes: 8 additions & 0 deletions .changeset/light-kids-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@wso2is/admin.applications.v1": patch
"@wso2is/admin.extensions.v1": patch
"@wso2is/admin.roles.v2": patch
"@wso2is/theme": patch
---

Refactor `admin.extensions.v1/components/application`
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
* under the License.
*/

import { createApplication, getApplicationList } from "@wso2is/admin.applications.v1/api";
import { ApplicationManagementConstants } from "@wso2is/admin.applications.v1/constants";
import { ApplicationListInterface, MainApplicationInterface } from "@wso2is/admin.applications.v1/models";
import { AppState, EventPublisher } from "@wso2is/admin.core.v1";
import { TierLimitReachErrorModal } from "@wso2is/admin.core.v1/components/modals/tier-limit-reach-error-modal";
import { getUserDetails } from "@wso2is/admin.users.v1/api/users";
Expand All @@ -40,15 +37,16 @@ import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { Dispatch } from "redux";
import { Divider, Grid, Icon, List, Modal } from "semantic-ui-react";
import LoginApplicationTemplate from
"../../../application-templates/templates/single-page-application/login-playground-application.json";
import InformationIcon from "../../../assets/images/illustrations/information-icon.svg";
import { getTryItClientId } from "../../application/utils/try-it-utils";
import { createApplication, getApplicationList } from "../../api/application";
import { ApplicationManagementConstants } from "../../constants/application-management";
import LoginApplicationTemplate from "../../data/try-it-application.json";
import { ApplicationListInterface, MainApplicationInterface } from "../../models/application";
import getTryItClientId from "../../utils/get-try-it-client-id";

/**
* Prop types of the `LoginPlaygroundWizard` component.
* Prop types of the `TryItCreateWizard` component.
*/
interface LoginPlaygroundWizardPropsInterface extends TestableComponentInterface {
interface TryItCreateWizardPropsInterface extends TestableComponentInterface {
closeWizard: () => void;
applicationName: string;
onApplicationCreate: () => void;
Expand All @@ -61,8 +59,8 @@ const INTERMITTENT_REDIRECTION_TIMEOUT: number = 2000;
*
* @returns Login Playground application wizard.
*/
export const LoginPlaygroundWizard: FunctionComponent<LoginPlaygroundWizardPropsInterface> = (
props: LoginPlaygroundWizardPropsInterface
const TryItCreateWizard: FunctionComponent<TryItCreateWizardPropsInterface> = (
props: TryItCreateWizardPropsInterface
): ReactElement => {
const {
closeWizard,
Expand Down Expand Up @@ -153,7 +151,21 @@ export const LoginPlaygroundWizard: FunctionComponent<LoginPlaygroundWizardProps
<Grid.Row textAlign="center">
<Grid.Column stretched width={ "16" }>
<GenericIcon
icon={ InformationIcon }
icon={ (
/* eslint-disable max-len */
<svg width="80" height="80" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M256 0C114.51 0 0 114.497 0 256C0 397.49 114.497 512 256 512C397.49 512 512 397.503 512 256C512 114.51 397.503 0 256 0ZM256 477.867C133.663 477.867 34.133 378.338 34.133 256C34.133 133.662 133.663 34.133 256 34.133C378.337 34.133 477.867 133.663 477.867 256C477.867 378.337 378.337 477.867 256 477.867Z"
fill="#2185D0" />
<path
d="M255.997 209.777C246.572 209.777 238.93 217.418 238.93 226.844V370.813C238.93 380.238 246.571 387.88 255.997 387.88C265.423 387.88 273.064 380.239 273.064 370.813V226.843C273.063 217.417 265.422 209.777 255.997 209.777Z"
fill="#2185D0" />
<path
d="M256 124.122C237.179 124.122 221.867 139.434 221.867 158.255C221.867 177.076 237.179 192.388 256 192.388C274.821 192.388 290.133 177.076 290.133 158.255C290.133 139.434 274.821 124.122 256 124.122Z"
fill="#2185D0" />
</svg>
/* eslint-enable max-len */
) }
size="tiny"
className="icon"
transparent
Expand Down Expand Up @@ -443,3 +455,5 @@ export const LoginPlaygroundWizard: FunctionComponent<LoginPlaygroundWizardProps
</>
);
};

export default TryItCreateWizard;
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 All @@ -19,18 +19,17 @@
/*
* Try it application constants.
*/
export class TryItApplicationConstants {
class TryItApplicationConstants {
/**
* Private constructor to avoid object instantiation from outside
* the class.
*/
private constructor() {}

/**
* Application's Display Name.
*/
public static readonly DISPLAY_NAME = "Asgardeo Try It";
/*
* status of the try it tour
*/
public static readonly TRY_IT_TOUR_STATUS_STORAGE_KEY = "isTryItTourViewed";
/*
* enabling or disabling try it tour
*/
public static readonly TRY_IT_TOUR_ENABLED = false;
public static readonly DISPLAY_NAME: string = "Asgardeo Try It";
}

export default TryItApplicationConstants;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "asgardeo-login-playground-template",
"name":"Asgardeo Try It",
"image": "../../../../assets/illustrations/asgardeo-rafiki-illustration.svg",
"image": "try-it",
"application": {
"templateId": "custom-application-oidc",
"name": "Asgardeo Try It",
Expand All @@ -27,11 +27,10 @@
"claimConfiguration":{
"dialect":"LOCAL",
"requestedClaims": [

{
"claim": {
"uri":"http://wso2.org/claims/emailaddress"
},
},
"mandatory": false
},
{
Expand Down
1 change: 1 addition & 0 deletions features/admin.applications.v1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@wso2is/admin.secrets.v1": "^2.20.118",
"@wso2is/admin.impersonation.v1": "^1.1.60",
"@wso2is/admin.server-configurations.v1": "^2.21.60",
"@wso2is/admin.users.v1": "^2.20.118",
"@wso2is/admin.userstores.v1": "^2.20.118",
"@wso2is/admin.wsfed-configuration.v1": "^2.20.118",
"@wso2is/core": "^2.0.60",
Expand Down
38 changes: 38 additions & 0 deletions features/admin.applications.v1/utils/get-try-it-client-id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* 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
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import LoginApplicationTemplate from "../data/try-it-application.json";

/**
* Retrieves the Try It client ID for a given tenant domain.
*
* @param tenantDomain - The tenant domain to replace in the client ID template.
* @returns The client ID with the tenant domain replaced.
*
* @example
* // Assuming the client ID template is "client_<TENANT>_id"
* // and tenantDomain is "example.com"
* // returns "client_example.com_id"
* const clientId = getTryItClientId("example.com");
*/
const getTryItClientId = (tenantDomain:string): string => {
return LoginApplicationTemplate.application.
inboundProtocolConfiguration.oidc.clientId.replace("<TENANT>", tenantDomain);
};

export default getTryItClientId;
Loading

0 comments on commit a62b383

Please sign in to comment.