Skip to content

Commit

Permalink
Merge pull request #6705 from savindi7/fix-b2b-app-branding-update
Browse files Browse the repository at this point in the history
Fix update call in B2B app-wise branding
  • Loading branch information
savindi7 authored Aug 12, 2024
2 parents bc73ba3 + 0513c0b commit c4d12e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-taxis-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/admin.branding.v1": patch
---

Fix update call in B2B app-wise branding.
31 changes: 19 additions & 12 deletions features/admin.branding.v1/components/branding-core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import Alert from "@oxygen-ui/react/Alert";
import { Show } from "@wso2is/access-control";
import { Show, useRequiredScopes } from "@wso2is/access-control";
import useAIBrandingPreference from "@wso2is/admin.branding.ai.v1/hooks/use-ai-branding-preference";
import { EventPublisher, OrganizationType } from "@wso2is/admin.core.v1";
import { AppState } from "@wso2is/admin.core.v1/store";
Expand All @@ -34,7 +34,6 @@ import {
PredefinedLayouts
} from "@wso2is/common.branding.v1/models";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
import { hasRequiredScopes } from "@wso2is/core/helpers";
import { AlertInterface, AlertLevels, IdentifiableComponentInterface } from "@wso2is/core/models";
import { addAlert } from "@wso2is/core/store";
import {
Expand Down Expand Up @@ -186,11 +185,11 @@ const BrandingCore: FunctionComponent<BrandingCoreInterface> = (

const eventPublisher: EventPublisher = EventPublisher.getInstance();

const isReadOnly: boolean = useMemo(() => !hasRequiredScopes(
featureConfig?.branding,
featureConfig?.branding?.scopes?.update,
allowedScopes
), [ featureConfig, allowedScopes ]);
const hasBrandingScopesUpdatePermissions: boolean = useRequiredScopes(
featureConfig?.branding?.scopes?.update
);

const isReadOnly: boolean = useMemo(() => !hasBrandingScopesUpdatePermissions, [ featureConfig, allowedScopes ]);

const isBrandingPageLoading: boolean = useMemo(
() =>
Expand Down Expand Up @@ -242,11 +241,19 @@ const BrandingCore: FunctionComponent<BrandingCoreInterface> = (
return;
}

if (organizationType === OrganizationType.SUBORGANIZATION
&& originalBrandingPreference?.name !== currentOrganization?.id) {
// This means the sub-org has no branding preference configured.
// It gets the branding preference from the parent org.
setIsBrandingConfigured(false);
if (organizationType === OrganizationType.SUBORGANIZATION) {
if (
(brandingMode === BrandingModes.APPLICATION &&
originalBrandingPreference?.name !== selectedApplication) ||
(brandingMode === BrandingModes.ORGANIZATION &&
originalBrandingPreference?.name !== currentOrganization?.id)
) {
// This means the sub-org or app has no branding preference configured.
// It gets the branding preference from the parent org.
setIsBrandingConfigured(false);
} else {
setIsBrandingConfigured(true);
}
} else {
setIsBrandingConfigured(true);
}
Expand Down

0 comments on commit c4d12e0

Please sign in to comment.