How to use the ramda.pathOr function in ramda

To help you get started, we’ve selected a few ramda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linode / manager / packages / manager / src / App.tsx View on Github external
const mapStateToProps: MapState = state => ({
  /** Profile */
  profileError: path(['read'], state.__resources.profile.error),
  linodes: state.__resources.linodes.entities,
  linodesError: path(['read'], state.__resources.linodes.error),
  domainsError: state.__resources.domains.error.read,
  imagesError: path(['read'], state.__resources.images.error),
  notificationsError: state.__resources.notifications.error,
  settingsError: state.__resources.accountSettings.error.read,
  typesError: state.__resources.types.error,
  regionsError: state.__resources.regions.error,
  volumesError: path(['read'], state.__resources.volumes.error),
  bucketsError: state.__resources.buckets.error,
  userId: path(['data', 'uid'], state.__resources.profile),
  username: pathOr('', ['data', 'username'], state.__resources.profile),
  accountData: state.__resources.account.data,
  documentation: state.documentation,
  isLoggedInAsCustomer: pathOr(
    false,
    ['authentication', 'loggedInAsCustomer'],
    state
  ),
  accountCapabilities: pathOr(
    [],
    ['__resources', 'account', 'data', 'capabilities'],
    state
  ),
  accountSettingsLoading: pathOr(
    true,
    ['__resources', 'accountSettings', 'loading'],
    state
github coderplanets / coderplanets_admin / stores / PostsPaperStore / index.js View on Github external
get curFilter() {
      return R.pathOr('', ['js'], self.filters.toJSON())
    },
github OpenCTI-Platform / opencti / opencti-front / src / private / components / sector / SectorsLines.js View on Github external
render() {
    const { dummy } = this.props;
    const { scrollToIndex } = this.state;
    const list = dummy
      ? []
      : this.filterList(pathOr([], ['sectors', 'edges'], this.props.data));
    const listLength = this.props.relay.isLoading()
      ? list.length + 25
      : list.length;
    const rowCount = dummy
      ? listLength > 0
        ? listLength - 1
        : 24
      : listLength;
    return (
      
        {({
          height, isScrolling, onChildScroll, scrollTop,
        }) => (
          <div>
            </div>
github linode / manager / src / features / linodes / LinodesCreate / TabbedContent / FromBackupsContent.tsx View on Github external
}

                if (
                  hasBackups &amp;&amp;
                  typeDisplayInfo &amp;&amp;
                  typeDisplayInfo.backupsMonthly
                ) {
                  displaySections.push(
                    renderBackupsDisplaySection(
                      accountBackupsEnabled,
                      typeDisplayInfo.backupsMonthly
                    )
                  );
                }

                let calculatedPrice = pathOr(0, ['monthly'], typeDisplayInfo);
                if (
                  hasBackups &amp;&amp;
                  typeDisplayInfo &amp;&amp;
                  typeDisplayInfo.backupsMonthly
                ) {
                  calculatedPrice += typeDisplayInfo.backupsMonthly;
                }

                return (
github apiko-dev / Perfi / app / screens / CategoryEditor / CategoryEditorContainer.js View on Github external
const accountProp = (propName, def) => R.pathOr(def, ['category', propName]);
github OpenCTI-Platform / opencti / opencti-front / src / private / components / report / ReportAddObservable.js View on Github external
}).then((data) => {
      const result = pathOr([], ['threatActors', 'edges'], data)
        .concat(pathOr([], ['intrusionSets', 'edges'], data))
        .concat(pathOr([], ['campaigns', 'edges'], data))
        .concat(pathOr([], ['incidents', 'edges'], data))
        .concat(pathOr([], ['malwares', 'edges'], data));
      const threats = map(
        n => ({
          label: n.node.name,
          value: n.node.id,
          type: n.node.entity_type,
        }),
        result,
      );
      this.setState({ threats: union(this.state.threats, threats) });
    });
  }
github OpenCTI-Platform / opencti / opencti-platform / opencti-front / src / private / components / threats / threat_actors / ThreatActorEditionOverview.js View on Github external
render() {
    const {
      t, threatActor, editUsers, me,
    } = this.props;
    const createdByRef = pathOr(null, ['createdByRef', 'node', 'name'], threatActor) === null
      ? ''
      : {
        label: pathOr(null, ['createdByRef', 'node', 'name'], threatActor),
        value: pathOr(null, ['createdByRef', 'node', 'id'], threatActor),
        relation: pathOr(
          null,
          ['createdByRef', 'relation', 'id'],
          threatActor,
        ),
      };
    const killChainPhases = pipe(
      pathOr([], ['killChainPhases', 'edges']),
      map((n) => ({
        label: `[${n.node.kill_chain_name}] ${n.node.phase_name}`,
        value: n.node.id,
        relationId: n.relation.id,
github eventespresso / event-espresso-core / assets / prototype / domain / eventEditor / data / queries / useCacheRehydrationData.ts View on Github external
const useCacheRehydrationData = (): RehydrationData =&gt; {
	const eventData = pathOr(null, ['eeEditorData', 'event'], window);
	const currentUser = pathOr(null, ['eeEditorData', 'currentUser'], window);
	const generalSettings = pathOr(null, ['eeEditorData', 'generalSettings'], window);

	return { ...eventData, currentUser, generalSettings };
};
github linode / manager / src / features / linodes / LinodesDetail / LinodeVolumes / LinodeVolumes.tsx View on Github external
setDialogError = (errorResponse: Linode.ApiFieldError) => {
    const { updateDialog } = this.state;
    const fallbackError = [{ reason: 'Unable to detach volume.' }];
    const apiError = pathOr(fallbackError, ['response', 'data', 'errors'], errorResponse);
    const error = apiError[0].reason;
    this.setState({
      updateDialog: {
        ...updateDialog,
        error,
        submitting: false,
      }
    })
  }