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

Improve email domain discovery page to incorporate new configuration for enabling email domain discovery for self-registration #7084

Merged
merged 7 commits into from
Dec 4, 2024
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 .changeset/shiny-bulldogs-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/admin.organization-discovery.v1": patch
"@wso2is/i18n": patch
---
pavinduLakshan marked this conversation as resolved.
Show resolved Hide resolved

Improve email domain discovery page to incorporate new configuration for enabling email domain discovery for self-registration.
5 changes: 5 additions & 0 deletions .changeset/short-insects-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/admin.server-configurations.v1": minor
---

Add new method to get governance connector details.
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 { store } from "@wso2is/admin.core.v1/store";
import { HttpMethods } from "@wso2is/core/models";
import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
import { OrganizationDiscoveryConfigInterface } from "../models/organization-discovery";

/**
* Get an axios instance.
*/
const httpClient: HttpClientInstance = AsgardeoSPAClient.getInstance()
.httpRequest.bind(AsgardeoSPAClient.getInstance());

/**
* Update organization discovery configurations
*
* @param properties - Data that needs to be updated.
*/
export const updateOrganizationDiscoveryConfig = (
properties: OrganizationDiscoveryConfigInterface
): Promise<any> => {
const requestConfig: AxiosRequestConfig = {
data: properties,
headers: {
"Content-Type": "application/json"
},
method: HttpMethods.PUT,
url: `${ store.getState().config.endpoints.organizations }/organization-configs/discovery`
};

return httpClient(requestConfig)
.then((response: AxiosResponse) => {
if (response.status !== 200) {
return Promise.reject(new Error("Failed to update organization discovery configs."));
}

return Promise.resolve(response?.data);
}).catch((error: AxiosError) => {
return Promise.reject(error?.response?.data);
});
};

export default updateOrganizationDiscoveryConfig;
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import { HttpMethods } from "@wso2is/core/models";
import { OrganizationDiscoveryConfigConstants } from "../constants/organization-discovery-config-constants";
import {
OrganizationDiscoveryConfigInterface,
OrganizationDiscoveryConfigPropertyInterface
OrganizationDiscoveryConfigPropertyInterface,
OrganizationDiscoveryResponseInterface
} from "../models/organization-discovery";

/**
Expand All @@ -36,7 +37,7 @@ import {
* @returns SWR response object containing the data, error, isValidating, mutate.
*/
const useGetOrganizationDiscoveryConfig = <
Data = OrganizationDiscoveryConfigInterface & { isOrganizationDiscoveryEnabled: boolean },
Data = OrganizationDiscoveryResponseInterface,
Error = RequestErrorInterface
>(shouldFetch: boolean = true): RequestResultInterface<Data, Error> => {
const requestConfig: RequestConfigInterface = {
Expand All @@ -53,13 +54,20 @@ const useGetOrganizationDiscoveryConfig = <
});

let isOrganizationDiscoveryEnabled: boolean = false;
let isEmailDomainBasedSelfRegistrationEnabled: boolean = false;

if ((data as OrganizationDiscoveryConfigInterface)?.properties) {
(data as OrganizationDiscoveryConfigInterface).properties?.forEach(
(property: OrganizationDiscoveryConfigPropertyInterface) => {
if (property.key === "emailDomain.enable") {
if (property.key === OrganizationDiscoveryConfigConstants.EMAIL_DOMAIN_DISCOVERY_PROPERTY_KEY
&& property.value === "true") {
isOrganizationDiscoveryEnabled = true;
}

if (property.key === OrganizationDiscoveryConfigConstants.EMAIL_DOMAIN_DISCOVERY_SELF_REG_PROPERTY_KEY
&& property.value === "true") {
isEmailDomainBasedSelfRegistrationEnabled = true;
}
}
);
}
Expand All @@ -83,6 +91,7 @@ const useGetOrganizationDiscoveryConfig = <

return {
data: {
isEmailDomainBasedSelfRegistrationEnabled,
isOrganizationDiscoveryEnabled,
...data
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* 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.
*/

.discoverable-organizations-list-layout {
pavinduLakshan marked this conversation as resolved.
Show resolved Hide resolved
.top-action-panel {
display: flex;
flex-direction: row-reverse;
flex-wrap: nowrap;
align-content: center;
justify-content: flex-start;
align-items: center;
gap: 10px;

>.ui.grid {
Yasasr1 marked this conversation as resolved.
Show resolved Hide resolved
flex-grow: 1;
}
}
}
Loading
Loading