Skip to content

Commit

Permalink
Merge pull request #4708 from ThaminduDilshan/thamindu-fix-idp-call
Browse files Browse the repository at this point in the history
Fix 404 response for IDP filtering with tags
  • Loading branch information
ThaminduDilshan authored Nov 20, 2023
2 parents b2bebfd + 40aecf6 commit ab99781
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-hornets-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/console": patch
---

Prevent API call with filter attribute tags for the IDP list endpoint
7 changes: 5 additions & 2 deletions apps/console/src/features/connections/api/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export const createConnection = (
* @param offset - Offset for get to start.
* @param filter - Search filter.
* @param requiredAttributes - Extra attribute to be included in the list response. ex:`isFederationHub`
* @param shouldFetch - Should fetch from the network. If false, will return results from cache.
* @param expectEmpty - If true, will allow returning empty results.
*
* @returns Requested connections.
*/
Expand All @@ -101,7 +103,8 @@ export const useGetConnections = <Data = ConnectionListResponseInterface, Error
offset?: number,
filter?: string,
requiredAttributes?: string,
shouldFetch: boolean = true
shouldFetch: boolean = true,
expectEmpty: boolean = false
): RequestResultInterface<Data, Error> => {

const { resourceEndpoints } = useResourceEndpoints();
Expand All @@ -126,7 +129,7 @@ export const useGetConnections = <Data = ConnectionListResponseInterface, Error
return {
data,
error: error,
isLoading: !error && !data,
isLoading: !expectEmpty && !error && !data,
isValidating,
mutate
};
Expand Down
11 changes: 10 additions & 1 deletion apps/console/src/features/connections/pages/connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const ConnectionsPage: FC<ConnectionsPropsInterface> = (props: ConnectionsPropsI
const [ localAuthenticatorList, setLocalAuthenticatorList ] = useState<AuthenticatorInterface[]>([]);
const [ filteredAuthenticatorList, setFilteredAuthenticatorList ] = useState<AuthenticatorInterface[]>([]);
const [ filter, setFilter ] = useState<string>(null);
const [ filterAuthenticatorsOnly, setFilterAuthenticatorsOnly ] = useState<boolean>(false);
const [ appendConnections, setAppendConnections ] = useState<boolean>(false);
const isPaginating: boolean = false;

Expand All @@ -122,7 +123,14 @@ const ConnectionsPage: FC<ConnectionsPropsInterface> = (props: ConnectionsPropsI
isLoading: isConnectionsFetchRequestLoading,
error: connectionsFetchRequestError,
mutate: mutateConnectionsFetchRequest
} = useGetConnections(listItemLimit, listOffset, filter, "federatedAuthenticators");
} = useGetConnections(
listItemLimit,
listOffset,
filter,
"federatedAuthenticators",
!filterAuthenticatorsOnly,
filterAuthenticatorsOnly
);

const {
data: authenticatorTags,
Expand Down Expand Up @@ -381,6 +389,7 @@ const ConnectionsPage: FC<ConnectionsPropsInterface> = (props: ConnectionsPropsI

setSelectedFilterTags(filterTags);
setFilter(ConnectionsManagementUtils.buildAuthenticatorsFilterQuery(query, filterTags));
setFilterAuthenticatorsOnly(filterTags && filterTags.length > 0);

if (isEmpty(query) && isEmpty(filterTags)) {
setShowFilteredList(false);
Expand Down

0 comments on commit ab99781

Please sign in to comment.