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

Show suborg name in the user dropdown for suborg user's myaccount login #6466

Merged
merged 10 commits into from
Aug 28, 2024
6 changes: 6 additions & 0 deletions .changeset/real-ants-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/myaccount": patch
"@wso2is/core": patch
---

Show suborg name in the user dropdown for suborg user's myaccount login
21 changes: 15 additions & 6 deletions apps/myaccount/src/components/shared/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ export const Header: FunctionComponent<HeaderPropsInterface> = (
const tenantName: string = useSelector(
(state: AppState) => state.authenticationInformation.tenantDomain
);

// B2B organization name if the user has logged in through B2B organization.
const orgName: string = useSelector(
(state: AppState) => state?.authenticationInformation?.orgName
);

const linkedAccounts: LinkedAccountInterface[] = useSelector(
(state: AppState) => state.profile.linkedAccounts
);
Expand Down Expand Up @@ -271,16 +277,19 @@ export const Header: FunctionComponent<HeaderPropsInterface> = (
/**
* Resolves the organization label in the header.
*/
const resolveOrganizationLabel = (): ReactElement => {
const organization: string =
tenantName == "carbon.super"
? commonConfig.header.organization.replace("{{productName}}", productName)
: tenantName;
const resolveOrganizationLabel = (): ReactElement => {
let organizationName: string = tenantName;

if (tenantName === AppConstants.getSuperTenant()) {
organizationName = commonConfig.header.organization.replace("{{productName}}", productName);
} else if (!!orgName && orgName !== tenantName) {
organizationName = orgName;
}

return (
<Alert classes={ { root: "organization-label-alert" } } severity="info" icon={ false }>
{ t("myAccount:components.header.organizationLabel") }{ " " }
<strong>{ organization }</strong>
<strong>{ organizationName }</strong>
</Alert>
);
};
Expand Down
3 changes: 2 additions & 1 deletion apps/myaccount/src/meta/themes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* under the License.
*/

import { DynamicBrandingPreferenceThemeInterface, PredefinedThemes } from "@wso2is/common.branding.v1/models";
import { DynamicBrandingPreferenceThemeInterface } from "@wso2is/common.branding.v1/models";
import { PredefinedThemes } from "@wso2is/common.branding.v1/models/branding-preferences";
import { DARK_THEME } from "./dark-theme";
import { LIGHT_THEME } from "./light-theme";

Expand Down
1 change: 1 addition & 0 deletions apps/myaccount/src/models/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface AuthStateInterface {
location: string;
loginInit: boolean;
logoutInit: boolean;
orgName: string;
profileSchemas: ProfileSchema[];
profileInfo: BasicProfileInterface;
tenantDomain?: string;
Expand Down
2 changes: 2 additions & 0 deletions apps/myaccount/src/store/reducers/authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const authenticateInitialState: AuthStateInterface = {
location: window["AppUtils"]?.getConfig()?.routes.home,
loginInit: false,
logoutInit: false,
orgName: "",
profileInfo: createEmptyProfile(),
profileSchemas: [],
scope: "",
Expand Down Expand Up @@ -59,6 +60,7 @@ const authenticateReducer = (
isAuth: true,
loginInit: true,
logoutInit: false,
orgName: action.payload.orgName,
scope: action.payload.scope,
tenantDomain: action.payload.tenantDomain,
username: action.payload.username
Expand Down
1 change: 1 addition & 0 deletions modules/core/src/utils/authenticate-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export class AuthenticateUtils {
displayName: response?.displayName,
display_name: response?.displayName,
email: response?.email,
orgName: response.orgName,
providedUsername: response?.username,
scope: response?.allowedScopes,
tenantDomain: tenantDomain ? tenantDomain : AuthenticateUtils.deriveTenantDomainFromSubject(response?.sub),
Expand Down
2 changes: 2 additions & 0 deletions modules/unit-testing/__mocks__/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* under the License.
*/

/* eslint-disable sort-keys */

/**
* Stubs files such as .jpg, .png, etc.
*
Expand Down
106 changes: 79 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading