wso2 / product-is

Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
744 stars 723 forks source link

Faulty logic in the Branding UI component's JSON editor doesn't allow removing custom texts #20638

Open vfraga opened 3 months ago

vfraga commented 3 months ago

Describe the issue: The Branding component in the Console [1] allows users to add their branding styling and label text preferences. They're also able to add custom text by editing the JSON under the path Branding > Styles & Text > Text > JSON.

I believe the snippet [2] was introduced to keep users from removing the default JSON entries, however the way it was implemented also makes it impossible to remove custom texts already persisted, since the API used to retrieve the data [3] returns both default and custom texts.

Therefore, it'd be best to use the data in the resources/branding/i18n/screens/${screen}/${locale}.json file, as it only stores the default entries [4].

How to reproduce:

  1. Start an Identity Server 7.0.0 instance.
  2. Go to: Console > Branding > Styles & Text > Text > JSON
  3. Add a new entry to the end of the JSON object:
    {
    "copyright": "© {{currentYear}} WSO2 LLC.",
    "site.title": "WSO2 Identity Server",
    "privacy.policy": "Privacy Policy",
    "terms.of.service": "Terms of Service",
    "custom.footer": "Footer"
    }
  4. Click the Save & Publish button.
  5. Try removing the added entry. Sometimes the UI glitches by itself and the entry will show up with an empty value, and others you'll need to refresh the page to see that it didn't remove it.

Expected behavior: The Branding UI component should allow users to remove the added custom text.

Environment information:


[1] https://is.docs.wso2.com/en/7.0.0/guides/branding/configure-ui-branding/ [2] https://github.com/wso2/identity-apps/blob/%40wso2is/console%402.12.46/apps/console/src/features/branding/providers/branding-preference-provider.tsx#L413-L426 [3] https://github.com/wso2/identity-apps/blob/%40wso2is/console%402.12.46/apps/console/src/features/branding/api/use-get-custom-text-preference-resolve.ts#L72-L75 [4] https://github.com/wso2/identity-apps/blob/%40wso2is/console%402.12.46/apps/console/src/features/branding/api/use-get-custom-text-preference-fallbacks.ts#L51-L53

amanda-ariyaratne commented 2 months ago

Since we are not supporting custom texts, the solution should be towards not allowing custom texts to be added in the first place.

vfraga commented 2 months ago

Hi @amanda-ariyaratne ,

Why do we provide an API for adding/updating custom texts [1] if we're not supporting it?

[1] https://is.docs.wso2.com/en/7.0.0/apis/branding-preference-rest-api/#tag/Custom-Text/operation/addCustomText