12.2.0 • Published 10 months ago

@leafygreen-ui/mongo-nav v12.2.0

Weekly downloads
227
License
Apache-2.0
Repository
-
Last release
10 months ago

← Back to mongodb/leafygreen-ui repository

NOTE: This component is a submodule for the mongodb/leafygreen-ui repository. That repository includes the environment and scripts to build and run tests for this package. It is highly recommended that when working with this repository, you work within the context of the leafygreen-ui repository itself.

Mongo Nav

npm (scoped)

Installation

Yarn

yarn add @leafygreen-ui/mongo-nav @leafygreen-ui/leafygreen-provider

NPM

npm install @leafygreen-ui/mongo-nav @leafygreen-ui/leafygreen-provider@1.1.0

Peer Dependencies

PackageVersion
@leafygreen-ui/leafygreen-provider^1.1.0

Example

<MongoNav
  mode="dev"
  activeProduct="cloud"
  activeNav="accessManager"
  onOrganizationChange={onOrganizationChange}
  onProjectChange={onProjectChange}
  admin={true}
/>

Properties

PropTypeDescriptionDefault
activeProduct'cloud', 'realm', 'charts'Describes what product is currently active
activeNavActiveNavElementDetermines what nav item is currently active
adminbooleanDescribes whether or not user is an adminfalse
mode'production', 'dev'Describes what environment the component is being used in'production'
onOrganizationChange({value: string, setData: Function, event: React.ChangeEvent}) => voidCallback invoked when user types in the OrgSelect filter box. The function receives an object as its argument with three keys. The first is the current value of the filter box, the second is a Function that allows the consumer to control what data is rendered based on the current search, and the final is the ChangeEvent.
onProjectChange({value: string, setData: Function, event: React.ChangeEvent}) => voidCallback invoked when user types in the ProjectSelect filter box. The function receives an object as its argument with three keys. The first is the current value of the filter box, the second is a Function that allows the consumer to control what data is rendered based on the current search, and the final is the ChangeEvent.
constructOrganizationURL(Organization) => stringFunction that allows consumers to determine destination URL when user selects an organization from the organization picker, see also hosts(org) => '${hosts.cloud}/v2#/org/${org.orgId}/projects'
constructProjectURL(Project) => stringFunction that allows consumers to determine destination URL when user selects a project from the project picker, see also hosts(project) => '${hosts.cloud}/v2#/${project.projectId}'
showProjectNavbooleanDetermines whether the project navigation should be showntrue
hosts{cloud: '', realm: '', charts: '', account: '', university: '', support: ''}Object where keys are MDB products and values are the desired hostURL override for that product, to enable <MongoNav /> to work across all environments
urlsURLInterfaceObject to enable custom overrides for every href used in <MongoNav />
onError(ErrorCode) => {},Function that is passed an error code as a string, so that consuming application can handle fetch failures() => {}
onSuccess(response) => {}Callback that receives the response of the fetched data, having been converted from JSON into an object() => {}
onPrem{enabled: boolean, mfa: boolean, version: string}onPrem config object with three keys: enabled, version and mfa{enabled: false, mfa: false, version: ''}
onPrem.enabledbooleanDetermines whether or not a user is onPremfalse
onPrem.mfabooleanDetermines if an onPrem user has multi-factor authentication enabledfalse
onPrem.versionstringDescribes the version of Ops Manager that an onPrem user is using''
activeOrgIdstringID for active organization, will trigger a POST request to cloud to update current active organization.
activeProjectIdstringID for active project, will trigger a POST request to cloud to update current active project.
classNamestringApplies a className to the root element
loadDatabooleanDetermines whether or not the component will fetch data from cloudtrue
onElementClick(type: NavElement, event: React.MouseEvent => void)Click EventHandler that receives a NavElement type as its first argument and the associated MouseEvent as its second. This prop provides a hook into product link and logout link clicks and allows consuming applications to handle routing internally() => {}
dataFixturesDataInterfaceAllows consumers to control fixture data when in dev mode
activePlatform'account', 'cloud', 'support','university', 'devHub', 'forums', 'docs'Describes what platform is currently active
alertPollingIntervalnumberDefines interval for alert polling600e3 // 10 minutes

Any other properties will be spread on the root element

NavElement

type NavElement =
  | 'orgNavOrgSettings'
  | 'orgNavAccessManagerDropdown'
  | 'orgNavSupport'
  | 'orgNavNewCase'
  | 'orgNavBilling'
  | 'orgNavAdmin'
  | 'orgNavDocs'
  | 'orgNavAllClusters'
  | 'logout'
  | 'leaf'
  | 'orgNavOrgSelectTrigger'
  | 'orgNavOrgSelectSearch'
  | 'orgNavViewAllOrganizations'
  | 'orgNavDropdownOrgAccessManager'
  | 'orgNavDropdownProjectAccessManager'
  | 'orgNavDropdownGetHelp'
  | 'projectNavProjectSelectTrigger'
  | 'projectNavProjectSelectSearch'
  | 'projectNavViewAllProjects'
  | 'projectNavAddProject'
  | 'projectNavProjectDropdown'
  | 'projectNavProjectSettings'
  | 'projectNavProjectSupport'
  | 'projectNavProjectIntegrations'
  | 'projectNavCloud'
  | 'projectNavRealm'
  | 'projectNavCharts'
  | 'projectNavInvite'
  | 'projectNavActivityFeed'
  | 'projectNavAlerts'
  | 'userMenuTrigger'
  | 'userMenuFeedback'
  | 'userMenuCloud'
  | 'userMenuCloudMFA'
  | 'userMenuCloudInvitations'
  | 'userMenuCloudOrganizations'
  | 'userMenuCloudUserPreferences'
  | 'userMenuCloudOther'
  | 'userMenuOnPremProfile'
  | 'userMenuOnPremTwoFactorAuth'
  | 'userMenuOnPremPersonalization'
  | 'userMenuOnPremInvitations'
  | 'userMenuOnPremOrganizations'
  | 'userMenuOnPremPublicApiAccess'
  | 'userMenuOnPremFeatureRequest'
  | 'userMenuOnPremSignOut'
  | 'userMenuOnPremOther'
  | 'userMenuDocs'
  | 'userMenuUniversity'
  | 'userMenuDevHub'
  | 'userMenuForums'
  | 'userMenuSupport'
  | 'userMenuLogout';
ActiveNavElement
type ActiveNavElement =
  | 'orgNavOrgSettings'
  | 'orgNavAccessManagerDropdown'
  | 'orgNavSupport'
  | 'orgNavBilling'
  | 'orgNavAdmin'
  | 'orgNavAllClusters'
  | 'orgNavDropdownOrgAccessManager'
  | 'orgNavDropdownProjectAccessManager'
  | 'projectNavInvite'
  | 'projectNavActivityFeed'
  | 'projectNavAlerts'
  | 'projectNavProjectSettings'
  | 'projectNavProjectSupport'
  | 'projectNavProjectIntegrations'
  | 'userMenuCloudMFA'
  | 'userMenuCloudInvitations'
  | 'userMenuCloudOrganizations'
  | 'userMenuCloudUserPreferences'
  | 'userMenuCloudOther'
  | 'userMenuOnPremProfile'
  | 'userMenuOnPremTwoFactorAuth'
  | 'userMenuOnPremPersonalization'
  | 'userMenuOnPremInvitations'
  | 'userMenuOnPremOrganizations'
  | 'userMenuOnPremPublicApiAccess'
  | 'userMenuOnPremPublicApiAccess';
URLInterface
export interface URLSInterface {
  userMenu?: {
    cloud?: {
      userPreferences: string;
      organizations: string;
      invitations: string;
      mfa: string;
    };
    university?: {
      universityPreferences: string;
    };
    support?: {
      userPreferences: string;
    };
    account?: {
      homepage?: string;
    };
    logout?: string;
  };
  mongoSelect?: {
    viewAllProjects?: string;
    viewAllOrganizations?: string;
    newProject?: string;
    orgSettings?: string;
  };
  orgNav?: {
    settings?: string;
    accessManager?: string;
    support?: string;
    billing?: string;
    allClusters?: string;
    admin?: string;
  };
  projectNav?: {
    settings?: string;
    accessManager?: string;
    support?: string;
    integrations?: string;
    alerts?: string;
    activityFeed?: string;
    invite?: string;
    realm?: string;
    charts?: string;
  };
  onPrem?: {
    profile?: string;
    mfa?: string;
    personalization?: string;
    invitations?: string;
    organizations?: string;
    publicApiAccess?: string;
    featureRequest?: string;
  };
}
DataInterface
export interface AccountInterface {
  email: string;
  firstName: string;
  lastName: string;
  shouldSeeAccountMfaBanner?: boolean;
  hasLegacy2fa?: boolean;
  openInvitations?: number;
  username?: string;
  admin?: boolean;
}

export interface ProjectInterface {
  projectId: string;
  projectName: string;
  planType?: PlanType;
  orgId?: string;
}

export interface CurrentProjectInterface extends ProjectInterface {
  alertsOpen: number;
  chartsActivated: boolean;
  status?: ProjectStatus;
}

export interface OrganizationInterface {
  orgId: string;
  orgName: string;
  planType: PlanType;
}

export interface CurrentOrganizationInterface extends OrganizationInterface {
  paymentStatus?: OrgPaymentLabel;
}

export interface DataInterface {
  readonly account: AccountInterface;
  currentOrganization?: CurrentOrganizationInterface;
  currentProject?: CurrentProjectInterface;
  readonly organizations: Array<OrganizationInterface>;
  readonly projects: Array<ProjectInterface>;
}

Imperative API Handle

We have customized the ref instance value that is exposed to components wrapping MongoNav, such that the instance's current property contains a reloadData key. Invoking reloadData triggers a refetch of data from MongoNav.

Example

const mongoNavRef = React.useRef(null);

const onClick = () => {
  mongooNavRef.current.reloadData();
};

<MongoNav
  ref={mongoNavRef}
  mode="dev"
  activeProduct="cloud"
  activeNav="accessManager"
  onOrganizationChange={onOrganizationChange}
  onProjectChange={onProjectChange}
  admin={true}
/>;
12.2.0

10 months ago

12.1.2

11 months ago

15.0.0

11 months ago

12.1.0

12 months ago

12.0.1

1 year ago

10.0.1

1 year ago

12.0.0

1 year ago

11.1.1

1 year ago

11.1.0

1 year ago

11.0.0

1 year ago

9.4.2

2 years ago

9.4.1

2 years ago

10.0.0

2 years ago

9.4.0

2 years ago

9.3.0

2 years ago

9.2.1-next.0

2 years ago

9.1.0

2 years ago

9.2.0

2 years ago

9.0.6

2 years ago

9.0.5

2 years ago

9.0.4

2 years ago

9.0.3

2 years ago

9.0.2

2 years ago

9.0.1

2 years ago

9.0.0

2 years ago

8.1.0

2 years ago

8.0.0

3 years ago

7.2.2

3 years ago

7.2.1

3 years ago

7.2.0

3 years ago

7.1.3

3 years ago

7.1.2

3 years ago

7.1.1

3 years ago

7.1.0

3 years ago

6.0.3

3 years ago

6.0.2

3 years ago

6.0.4

3 years ago

7.0.0

3 years ago

7.0.1

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.2.6

3 years ago

5.2.5

3 years ago

5.2.4

3 years ago

5.2.3

3 years ago

5.2.2

3 years ago

5.2.1

3 years ago

5.2.0

3 years ago

5.1.3

3 years ago

5.1.2

3 years ago

5.1.1

3 years ago

5.1.0

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.2.0

3 years ago

4.1.0

3 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.3.0

4 years ago

3.2.0

4 years ago

3.1.9

4 years ago

3.1.8

4 years ago

3.1.7

4 years ago

3.1.6

4 years ago

3.1.5

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.0.0

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago

0.23.0

4 years ago

0.22.0

4 years ago

0.21.0

4 years ago

0.20.0

4 years ago

0.19.0

4 years ago

0.18.0

4 years ago

0.17.0

4 years ago

0.16.0

4 years ago

0.15.0

4 years ago

0.14.0

4 years ago

0.13.0

4 years ago

0.12.0

4 years ago

0.11.1

4 years ago

0.11.0

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago