-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5964 from anjuchamantha/dcr-configs-ui
Adding new DCR Application Settings Page
- Loading branch information
Showing
19 changed files
with
17,536 additions
and
12,338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@wso2is/admin.applications.v1": minor | ||
"@wso2is/admin.extensions.v1": minor | ||
"@wso2is/admin.core.v1": minor | ||
"@wso2is/i18n": minor | ||
--- | ||
|
||
Adding a new page with tenant-wise DCR configurations |
60 changes: 60 additions & 0 deletions
60
features/admin.applications.v1/api/applications-settings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) 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 { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react"; | ||
import { HttpMethods } from "@wso2is/core/models"; | ||
import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios"; | ||
import { store } from "../../admin.core.v1/store"; | ||
import { ApplicationsSettingsFormValuesInterface, DCRConfigUpdateType } from "../models/applications-settings"; | ||
|
||
/** | ||
* Get an axios instance. | ||
*/ | ||
const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance() | ||
.httpRequest.bind(AsgardeoSPAClient.getInstance()); | ||
|
||
/** | ||
* Updates the DCR Configurations. | ||
* | ||
* @returns A promise containing the response. | ||
*/ | ||
export const updateDCRConfigurations = ( | ||
updateData: Array<DCRConfigUpdateType> | ||
): Promise<ApplicationsSettingsFormValuesInterface | void> => { | ||
|
||
const requestConfig: AxiosRequestConfig = { | ||
data: updateData, | ||
headers: { | ||
"Accept": "application/json", | ||
"Content-Type": "application/json" | ||
}, | ||
method: HttpMethods.PATCH, | ||
url: store.getState().config.endpoints.dcrConfiguration | ||
}; | ||
|
||
return httpClient(requestConfig) | ||
.then((response: AxiosResponse) => { | ||
if (response.status !== 200) { | ||
return Promise.reject(new Error("Failed to update DCR Configuration.")); | ||
} | ||
|
||
return Promise.resolve(response.data as ApplicationsSettingsFormValuesInterface); | ||
}).catch((error: AxiosError) => { | ||
return Promise.reject(error); | ||
}); | ||
}; |
55 changes: 55 additions & 0 deletions
55
features/admin.applications.v1/api/use-get-dcr-configurations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright (c) 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 { HttpMethods } from "@wso2is/core/models"; | ||
import { AxiosRequestConfig } from "axios"; | ||
import useRequest, { | ||
RequestErrorInterface, | ||
RequestResultInterface | ||
} from "../../admin.core.v1/hooks/use-request"; | ||
import { store } from "../../admin.core.v1/store"; | ||
import { ApplicationsSettingsFormValuesInterface } from "../models/applications-settings"; | ||
|
||
/** | ||
* Hook to get the dcr configurations from the API. | ||
* | ||
* @returns Response as a promise. | ||
*/ | ||
export const useGetDCRConfigurations = <Data = ApplicationsSettingsFormValuesInterface, Error = RequestErrorInterface>( | ||
shouldFetch: boolean = true | ||
): RequestResultInterface<Data, Error> => { | ||
|
||
const requestConfig: AxiosRequestConfig = { | ||
headers: { | ||
"Accept": "application/json", | ||
"Content-Type": "application/json" | ||
}, | ||
method: HttpMethods.GET, | ||
url: `${ store.getState().config.endpoints.dcrConfiguration}` | ||
}; | ||
|
||
const { data, error, isValidating, mutate } = useRequest<Data, Error>(shouldFetch ? requestConfig : null); | ||
|
||
return { | ||
data, | ||
error: error, | ||
isLoading: !error && !data, | ||
isValidating, | ||
mutate | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
features/admin.applications.v1/models/applications-settings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* Copyright (c) 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 { IdentifiableComponentInterface } from "@wso2is/core/models"; | ||
|
||
/** | ||
* Form values interface. | ||
*/ | ||
export interface ApplicationsSettingsFormValuesInterface { | ||
/** | ||
* Is the mandateSSA enabled. | ||
*/ | ||
mandateSSA?: boolean; | ||
/** | ||
* Is the requireAuthentication enabled. | ||
*/ | ||
authenticationRequired?: boolean; | ||
/** | ||
* JWKS Endpoint Url. | ||
*/ | ||
ssaJwks?: string; | ||
/** | ||
* Is fapi complience enforced for the dcr apps. | ||
*/ | ||
enableFapiEnforcement?: boolean | ||
} | ||
|
||
/** | ||
* DCR Config update type. | ||
*/ | ||
export interface DCRConfigUpdateType { | ||
/** | ||
* Operation type. | ||
*/ | ||
operation: string; | ||
/** | ||
* Path type. | ||
*/ | ||
path: string; | ||
/** | ||
* Value type. | ||
*/ | ||
value: string | boolean; | ||
} | ||
|
||
/** | ||
* Proptypes for the applications settings form component. | ||
*/ | ||
export interface ApplicationsSettingsPropsInterface extends IdentifiableComponentInterface { | ||
/** | ||
* Is the SSA(Software Statement Assertion) mandated. | ||
*/ | ||
mandateSSA?: boolean; | ||
/** | ||
* Is the requireAuthentication enabled. | ||
*/ | ||
authenticationRequired?: boolean; | ||
/** | ||
* JWKS Endpoint Url to validate SSA(Software Statement Assertion). | ||
*/ | ||
ssaJwks?: string; | ||
/** | ||
* DCR Endpoint Url. | ||
*/ | ||
dcrEndpoint?: string; | ||
/** | ||
* Is fapi compliance enforced for the DCR apps. | ||
*/ | ||
enableFapiEnforcement?: boolean | ||
} | ||
|
||
/** | ||
* Proptypes for the applications settings form error messages. | ||
*/ | ||
export interface ApplicationsSettingsFormErrorValidationsInterface { | ||
/** | ||
* Error message for the JWKS URL. | ||
*/ | ||
ssaJwks?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.