-
Notifications
You must be signed in to change notification settings - Fork 259
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
Open
Yasasr1
wants to merge
5
commits into
wso2:master
Choose a base branch
from
Yasasr1:b2b-self-signup-config
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
41b06c5
Add org discovery for self-signup.
Yasasr1 b961b97
Add config to disable org discovery self-reg feature.
Yasasr1 6151889
🦋 Add changeset.
Yasasr1 9d66740
Utilize useRequiredScopes hook.
Yasasr1 ba5ced4
Address review comments.
Yasasr1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 @@ | ||
--- | ||
"@wso2is/admin.organization-discovery.v1": patch | ||
"@wso2is/i18n": patch | ||
--- | ||
|
||
Improve email domain discovery page to incorporate new configuration for enabling email domain discovery for self-registration. |
60 changes: 60 additions & 0 deletions
60
features/admin.organization-discovery.v1/api/update-organization-discovery-config.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 { 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; |
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
33 changes: 33 additions & 0 deletions
33
...es/admin.organization-discovery.v1/components/discoverable-organizations-list-layout.scss
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,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 { | ||
.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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. recheck usage of > |
||
flex-grow: 1; | ||
} | ||
} | ||
} |
244 changes: 244 additions & 0 deletions
244
...res/admin.organization-discovery.v1/components/discoverable-organizations-list-layout.tsx
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,244 @@ | ||
/** | ||
* 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 { Show } from "@wso2is/access-control"; | ||
import { EventPublisher, FeatureConfigInterface } from "@wso2is/admin.core.v1"; | ||
import { AdvancedSearchWithBasicFilters } from "@wso2is/admin.core.v1/components"; | ||
import { AppConstants } from "@wso2is/admin.core.v1/constants/app-constants"; | ||
import { history } from "@wso2is/admin.core.v1/helpers/history"; | ||
import { IdentifiableComponentInterface } from "@wso2is/core/models"; | ||
import { I18n } from "@wso2is/i18n"; | ||
import { ListLayout, PrimaryButton } from "@wso2is/react-components"; | ||
import find from "lodash-es/find"; | ||
import React, { | ||
FunctionComponent, | ||
MouseEvent, | ||
ReactElement, | ||
ReactNode, | ||
SyntheticEvent, | ||
useCallback, | ||
useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { DropdownItemProps, DropdownProps, Icon, PaginationProps } from "semantic-ui-react"; | ||
import DiscoverableOrganizationsList from "./discoverable-organizations-list"; | ||
import { OrganizationListWithDiscoveryInterface } from "../models/organization-discovery"; | ||
import "./discoverable-organizations-list-layout.scss"; | ||
|
||
/** | ||
* Props interface of {@link DiscoverableOrganizationsListLayout} | ||
*/ | ||
export interface DiscoverableOrganizationsListLayoutPropsInterface extends IdentifiableComponentInterface { | ||
discoverableOrganizations: OrganizationListWithDiscoveryInterface | ||
listItemLimit: number; | ||
isDiscoverableOrganizationsFetchRequestLoading: boolean; | ||
featureConfig: FeatureConfigInterface; | ||
searchQuery: string; | ||
onListItemLimitChange: (limit: number) => void; | ||
onListOffsetChange: (offset: number) => void; | ||
onSearchQueryChange: (query: string) => void; | ||
} | ||
|
||
/** | ||
* Layout for the discoverable organizations list. | ||
* | ||
* @param props - Props injected to the component. | ||
* @returns Discoverable organization list layout component. | ||
*/ | ||
const DiscoverableOrganizationsListLayout: FunctionComponent<DiscoverableOrganizationsListLayoutPropsInterface> = ({ | ||
discoverableOrganizations, | ||
listItemLimit, | ||
isDiscoverableOrganizationsFetchRequestLoading, | ||
featureConfig, | ||
searchQuery, | ||
onListItemLimitChange, | ||
onListOffsetChange, | ||
onSearchQueryChange, | ||
["data-componentid"]: componentId = "discoverable-organizations-list-layout" | ||
}: DiscoverableOrganizationsListLayoutPropsInterface): ReactElement => { | ||
|
||
const ORGANIZATIONS_LIST_SORTING_OPTIONS: DropdownItemProps[] = [ | ||
{ | ||
key: 0, | ||
text: I18n.instance.t("organizationDiscovery:advancedSearch." + | ||
"form.dropdown.filterAttributeOptions.organizationName") as ReactNode, | ||
value: "organizationName" | ||
} | ||
]; | ||
|
||
const eventPublisher: EventPublisher = EventPublisher.getInstance(); | ||
const { t } = useTranslation(); | ||
const [ triggerClearQuery, setTriggerClearQuery ] = useState<boolean>(false); | ||
const [ listSortingStrategy, setListSortingStrategy ] = useState<DropdownItemProps>( | ||
ORGANIZATIONS_LIST_SORTING_OPTIONS[ 0 ] | ||
); | ||
|
||
/** | ||
* Handles the `onFilter` callback action from the | ||
* organization search component. | ||
* | ||
* @param query - Search query. | ||
*/ | ||
const handleOrganizationFilter: (query: string) => void = useCallback( | ||
(query: string): void => { | ||
onSearchQueryChange(query); | ||
}, | ||
[ onSearchQueryChange ] | ||
); | ||
|
||
/** | ||
* Handles the `onSearchQueryClear` callback action. | ||
*/ | ||
const handleSearchQueryClear: () => void = useCallback((): void => { | ||
setTriggerClearQuery(!triggerClearQuery); | ||
onSearchQueryChange(""); | ||
}, [ onSearchQueryChange, triggerClearQuery ]); | ||
|
||
/** | ||
* Handles per page dropdown page. | ||
* | ||
* @param event - Mouse event. | ||
* @param data - Dropdown data. | ||
*/ | ||
const handleItemsPerPageDropdownChange = (event: MouseEvent<HTMLAnchorElement>, data: DropdownProps): void => { | ||
onListItemLimitChange(data.value as number); | ||
}; | ||
|
||
/** | ||
* Handles the pagination change. | ||
* | ||
* @param event - Mouse event. | ||
* @param data - Pagination component data. | ||
*/ | ||
const handlePaginationChange = (event: MouseEvent<HTMLAnchorElement>, data: PaginationProps) => { | ||
const offsetValue: number = ((data.activePage as number) - 1) * listItemLimit; | ||
|
||
onListOffsetChange(offsetValue); | ||
}; | ||
|
||
/** | ||
* Sets the list sorting strategy. | ||
* | ||
* @param event - The event. | ||
* @param data - Dropdown data. | ||
*/ | ||
const handleListSortingStrategyOnChange = (event: SyntheticEvent<HTMLElement>, data: DropdownProps): void => { | ||
setListSortingStrategy( | ||
find(ORGANIZATIONS_LIST_SORTING_OPTIONS, (option: DropdownItemProps) => { | ||
return data.value === option.value; | ||
}) | ||
); | ||
}; | ||
|
||
/** | ||
* Checks if the `Next` page nav button should be shown. | ||
* | ||
* @param orgList - List of discoverable organizations. | ||
* @returns `true` if `Next` page nav button should be shown. | ||
*/ | ||
const shouldShowNextPageNavigation = (orgList: OrganizationListWithDiscoveryInterface): boolean => { | ||
return orgList?.startIndex + orgList?.count !== orgList?.totalResults + 1; | ||
}; | ||
|
||
return ( | ||
<ListLayout | ||
advancedSearch={ ( | ||
<AdvancedSearchWithBasicFilters | ||
onFilter={ handleOrganizationFilter } | ||
filterAttributeOptions={ [ | ||
{ | ||
key: 0, | ||
text: t("organizationDiscovery:advancedSearch." + | ||
"form.dropdown.filterAttributeOptions.organizationName"), | ||
value: "organizationName" | ||
} | ||
] } | ||
filterAttributePlaceholder={ t( | ||
"organizationDiscovery:advancedSearch.form" + | ||
".inputs.filterAttribute.placeholder" | ||
) } | ||
filterConditionsPlaceholder={ t( | ||
"organizationDiscovery:advancedSearch.form" + | ||
".inputs.filterCondition.placeholder" | ||
) } | ||
filterValuePlaceholder={ t( | ||
"organizationDiscovery:advancedSearch.form" + | ||
".inputs.filterValue.placeholder" | ||
) } | ||
placeholder={ t( | ||
"organizationDiscovery:advancedSearch.placeholder" | ||
) } | ||
defaultSearchAttribute="organizationName" | ||
defaultSearchOperator="co" | ||
triggerClearQuery={ triggerClearQuery } | ||
data-componentid={ `${ componentId }-list-advanced-search` } | ||
/> | ||
) } | ||
currentListSize={ discoverableOrganizations?.organizations?.length } | ||
listItemLimit={ listItemLimit } | ||
onItemsPerPageDropdownChange={ handleItemsPerPageDropdownChange } | ||
onPageChange={ handlePaginationChange } | ||
onSortStrategyChange={ handleListSortingStrategyOnChange } | ||
showTopActionPanel={ | ||
isDiscoverableOrganizationsFetchRequestLoading || | ||
!(!searchQuery && discoverableOrganizations?.organizations?.length <= 0) | ||
} | ||
sortOptions={ ORGANIZATIONS_LIST_SORTING_OPTIONS } | ||
sortStrategy={ listSortingStrategy } | ||
topActionPanelExtension={ | ||
( | ||
<Show when={ featureConfig?.organizationDiscovery?.scopes?.create }> | ||
<PrimaryButton | ||
disabled={ isDiscoverableOrganizationsFetchRequestLoading } | ||
loading={ isDiscoverableOrganizationsFetchRequestLoading } | ||
onClick={ () => { | ||
eventPublisher.publish("organization-click-assign-email-domain-button"); | ||
history.push( | ||
AppConstants.getPaths().get("ASSIGN_ORGANIZATION_DISCOVERY_DOMAINS") | ||
); | ||
} } | ||
data-componentid={ `${ componentId }-assign-button` } | ||
> | ||
<Icon name="add" /> | ||
{ t("organizationDiscovery:emailDomains.actions.assign") } | ||
</PrimaryButton> | ||
</Show> | ||
) } | ||
totalPages={ 10 } | ||
totalListSize={ discoverableOrganizations?.organizations?.length } | ||
isLoading={ isDiscoverableOrganizationsFetchRequestLoading } | ||
paginationOptions={ { | ||
disableNextButton: !shouldShowNextPageNavigation(discoverableOrganizations) | ||
} } | ||
data-componentid={ `${ componentId }-list-layout` } | ||
className="discoverable-organizations-list-layout" | ||
showPagination | ||
> | ||
<DiscoverableOrganizationsList | ||
list={ discoverableOrganizations } | ||
onEmptyListPlaceholderActionClick={ () => { | ||
history.push(AppConstants.getPaths().get("ASSIGN_ORGANIZATION_DISCOVERY_DOMAINS")); | ||
} } | ||
onSearchQueryClear={ handleSearchQueryClear } | ||
searchQuery={ searchQuery } | ||
data-componentid="organization-list-with-discovery" | ||
/> | ||
</ListLayout> | ||
); | ||
}; | ||
|
||
export default DiscoverableOrganizationsListLayout; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add license header