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

Fix api resource collection endpoint path #7094

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/friendly-dodos-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/admin.console-settings.v1": patch
"@wso2is/admin.core.v1": patch
---

Fix api resource collection endpoint path
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import useRequest, {
RequestErrorInterface,
RequestResultInterface
} from "@wso2is/admin.core.v1/hooks/use-request";
import { store } from "@wso2is/admin.core.v1/store";
import { HttpMethods } from "@wso2is/core/models";
import { getConsoleSettingsResourceEndpoints } from "../configs/endpoints";
import { APIResourceCollectionResponseInterface } from "../models/console-roles";

/**
Expand Down Expand Up @@ -50,7 +50,7 @@ const useGetAPIResourceCollections = <
attributes,
filter
},
url: store.getState().config.endpoints.apiResourceCollections
url: getConsoleSettingsResourceEndpoints().apiResourceCollections
};

const { data, error, isValidating, mutate } = useRequest<Data, Error>(shouldFetch? requestConfig : null, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
* under the License.
*/

import Autocomplete, {
AutocompleteRenderGetTagProps,
AutocompleteRenderInputParams
} from "@oxygen-ui/react/Autocomplete";
import TextField from "@oxygen-ui/react/TextField";
import { updateRoleDetails } from "@wso2is/admin.roles.v2/api/roles";
import { RenderChip } from "@wso2is/admin.roles.v2/components/edit-role/edit-role-common/render-chip";
import { Schemas } from "@wso2is/admin.roles.v2/constants/role-constants";
import { CreateRolePermissionInterface, PatchRoleDataInterface } from "@wso2is/admin.roles.v2/models/roles";
import {
Expand Down Expand Up @@ -98,7 +92,6 @@ const ConsoleRolePermissions: FunctionComponent<ConsoleRolePermissionsProps> = (
role,
onRoleUpdate,
tabIndex,
isSubOrganization,
[ "data-componentid" ]: componentId
} = props;

Expand All @@ -107,13 +100,13 @@ const ConsoleRolePermissions: FunctionComponent<ConsoleRolePermissionsProps> = (
const { t } = useTranslation();

const { data: tenantAPIResourceCollections } = useGetAPIResourceCollections(
!isSubOrganization,
true,
"type eq tenant",
"apiResources"
);

const { data: organizationAPIResourceCollections } = useGetAPIResourceCollections(
!isSubOrganization,
true,
"type eq organization",
"apiResources"
);
Expand Down Expand Up @@ -301,43 +294,6 @@ const ConsoleRolePermissions: FunctionComponent<ConsoleRolePermissionsProps> = (
});
};

/**
* Render the read only permission list for sub organizations.
* Due to a limitation in the API, we have to use a separate permission list component for sub organizations.
*
* @returns Read only permission list for sub organizations.
*/
const readOnlyPermissionListSubOrganization = (): ReactElement => (
<Autocomplete
readOnly
multiple
options={ role?.permissions ?? [] }
defaultValue={ role?.permissions ?? [] }
getOptionLabel={ (scope: RolePermissionInterface) => scope.display }
renderInput={ (params: AutocompleteRenderInputParams) => (
<TextField
{ ...params }
data-componentid={ `${componentId}-textfield` }
/>
) }
renderTags={ (
value: RolePermissionInterface[],
getTagProps: AutocompleteRenderGetTagProps
) => value.map((option: RolePermissionInterface, index: number) => (
<RenderChip
{ ...getTagProps({ index }) }
key={ index }
primaryText={ option.display }
secondaryText={ option.value }
option={ option }
activeOption={ null }
setActiveOption={ () => null }
variant="filled"
/>
)) }
/>
);

return (
<EmphasizedSegment padded="very" className="console-role-permissions">
<div className="section-heading">
Expand All @@ -352,17 +308,12 @@ const ConsoleRolePermissions: FunctionComponent<ConsoleRolePermissionsProps> = (
}
</Heading>
</div>
{ isSubOrganization
? readOnlyPermissionListSubOrganization()
: (
<CreateConsoleRoleWizardPermissionsForm
defaultExpandedIfPermissionsAreSelected
isReadOnly={ isReadOnly }
initialValues={ permissionFormInitialValues }
onPermissionsChange={ setPermissions }
/>
)
}
<CreateConsoleRoleWizardPermissionsForm
defaultExpandedIfPermissionsAreSelected
isReadOnly={ isReadOnly }
initialValues={ permissionFormInitialValues }
onPermissionsChange={ setPermissions }
/>
{
!isReadOnly && (
<PrimaryButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ const CreateConsoleRoleWizardPermissionsForm: FunctionComponent<CreateConsoleRol
)
}
inputProps={ {
"aria-label": `Select ${collection.displayName} permission`
"aria-label":
`Select ${collection.displayName} permission`
} }
/>
</TableCell>
Expand All @@ -428,7 +429,10 @@ const CreateConsoleRoleWizardPermissionsForm: FunctionComponent<CreateConsoleRol
Object.keys(selectedPermissions.tenant).includes(
collection.id
)
? get(selectedPermissions.tenant, collection.id)?.write
? get(
selectedPermissions.tenant,
collection.id
)?.write
? "write"
: "read"
: null
Expand Down
10 changes: 5 additions & 5 deletions features/admin.console-settings.v1/configs/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import { ConsoleSettingsResourceEndpointsInterface } from "../models/endpoints";
* @param serverHost - Server Host.
* @returns Endpoint URLs.
*/
export const getConsoleSettingsResourceEndpoints = (
serverHost: string
): ConsoleSettingsResourceEndpointsInterface => {
export const getConsoleSettingsResourceEndpoints = (): ConsoleSettingsResourceEndpointsInterface => {
return {
apiResourceCollection: `${serverHost}/api/server/v1/meta/api-resource-collections/:id`,
apiResourceCollections: `${serverHost}/api/server/v1/meta/api-resource-collections`
apiResourceCollection:
`${window["AppUtils"].getServerOriginWithTenant(false)}/api/server/v1/meta/api-resource-collections/:id`,
apiResourceCollections:
`${window["AppUtils"].getServerOriginWithTenant(false)}/api/server/v1/meta/api-resource-collections`
};
};
2 changes: 0 additions & 2 deletions features/admin.core.v1/configs/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { getBrandingResourceEndpoints } from "@wso2is/admin.branding.v1/configs/
import { getCertificatesResourceEndpoints } from "@wso2is/admin.certificates.v1";
import { getClaimResourceEndpoints } from "@wso2is/admin.claims.v1/configs/endpoints";
import { getConnectionResourceEndpoints } from "@wso2is/admin.connections.v1";
import { getConsoleSettingsResourceEndpoints } from "@wso2is/admin.console-settings.v1/configs/endpoints";
import { getEmailTemplatesResourceEndpoints } from "@wso2is/admin.email-templates.v1";
import { getExtendedFeatureResourceEndpoints } from "@wso2is/admin.extensions.v1/configs/endpoints";
import { getFeatureGateResourceEndpoints } from "@wso2is/admin.feature-gate.v1/configs/endpoints";
Expand Down Expand Up @@ -265,7 +264,6 @@ export class Config {
...getTenantResourceEndpoints(this.getDeploymentConfig().serverOrigin),
...getFeatureGateResourceEndpoints(this.resolveServerHostforFG(false)),
...getInsightsResourceEndpoints(this.getDeploymentConfig()?.serverHost),
...getConsoleSettingsResourceEndpoints(this.getDeploymentConfig()?.serverHost),
...getExtensionTemplatesEndpoints(this.resolveServerHost()),
...getApplicationTemplatesResourcesEndpoints(this.resolveServerHost()),
...getActionsResourceEndpoints(this.resolveServerHost()),
Expand Down
2 changes: 0 additions & 2 deletions features/admin.core.v1/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { BrandingPreferenceResourceEndpointsInterface } from "@wso2is/admin.bran
import { CertificatesResourceEndpointsInterface } from "@wso2is/admin.certificates.v1";
import { ClaimResourceEndpointsInterface } from "@wso2is/admin.claims.v1/models/endpoints";
import { ConnectionResourceEndpointsInterface } from "@wso2is/admin.connections.v1";
import { ConsoleSettingsResourceEndpointsInterface } from "@wso2is/admin.console-settings.v1/models/endpoints";
import { GroupsResourceEndpointsInterface } from "@wso2is/admin.groups.v1";
import { ScopesResourceEndpointsInterface } from "@wso2is/admin.oidc-scopes.v1";
import { OrganizationResourceEndpointsInterface } from "@wso2is/admin.organizations.v1/models";
Expand Down Expand Up @@ -543,7 +542,6 @@ export interface ServiceResourceEndpointsInterface extends ClaimResourceEndpoint
TenantResourceEndpointsInterface,
ValidationServiceEndpointsInterface,
BrandingPreferenceResourceEndpointsInterface,
ConsoleSettingsResourceEndpointsInterface,
ExtensionTemplatesEndpointsInterface,
ApplicationsTemplatesEndpointsInterface,
SMSTemplateResourceEndpointsInterface,
Expand Down
2 changes: 0 additions & 2 deletions features/admin.core.v1/store/reducers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ export const commonConfigReducerInitialState: CommonConfigReducerStateInterface<
accountRecovery: "",
actions: "",
adminAdvisoryBanner: "",
apiResourceCollection: "",
apiResourceCollections: "",
applicationTemplate: "",
applicationTemplateMetadata: "",
applications: "",
Expand Down
Loading