From 39b76861d90bc2d4556e354978e16edb87d24edc Mon Sep 17 00:00:00 2001 From: Mercy Date: Thu, 13 Feb 2025 15:19:54 -0500 Subject: [PATCH] Alphabetical order for relationship types and template names (#7669) * sorting of relationshipTypes and templates * updates expected template order in filters * eslint fix * fixes selectors * update of snapshots --- app/react/Entities/components/EntityViewer.js | 3 +- app/react/Relationships/actions/actions.js | 5 ++- .../components/FormConfigRelationship.js | 9 +++-- .../RelationshipTypes/RelationshipTypes.tsx | 37 ++++++++++-------- .../components/TableComponents.tsx | 6 +-- app/react/V2/atoms/store.ts | 5 ++- app/react/entry-server.tsx | 6 +-- e2e/suite1/connections.test.ts | 2 +- ...and-keep-the-search-bar-visible-1-snap.png | Bin 154059 -> 103859 bytes ...ally-and-keep-the-sticky-header-1-snap.png | Bin 140458 -> 150623 bytes e2e/suite2/searchFilters.test.ts | 14 +++---- e2e/suite2/tableView.test.ts | 3 +- 12 files changed, 51 insertions(+), 39 deletions(-) diff --git a/app/react/Entities/components/EntityViewer.js b/app/react/Entities/components/EntityViewer.js index c2ec8b20c3..38d51872c3 100644 --- a/app/react/Entities/components/EntityViewer.js +++ b/app/react/Entities/components/EntityViewer.js @@ -6,6 +6,7 @@ import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { Helmet } from 'react-helmet'; +import { sortBy } from 'lodash'; import PropTypes from 'prop-types'; import { Icon } from 'UI'; import { withContext, withRouter } from 'app/componentWrappers'; @@ -417,7 +418,7 @@ EntityViewer.propTypes = { const selectRelationTypes = createSelector( s => s.relationTypes, - r => r.toJS() + r => sortBy(r.toJS(), 'name') ); const mapStateToProps = state => { diff --git a/app/react/Relationships/actions/actions.js b/app/react/Relationships/actions/actions.js index 8828bbe834..0a48c8e713 100644 --- a/app/react/Relationships/actions/actions.js +++ b/app/react/Relationships/actions/actions.js @@ -1,3 +1,4 @@ +import { sortBy } from 'lodash'; import api from 'app/utils/api'; import { actions } from 'app/BasicReducer'; import debounce from 'app/utils/debounce'; @@ -248,7 +249,9 @@ const selectRelationTypes = createSelector( name, }; }); - return [{ _id: null, name: t('System', 'No Label', null, false) }].concat(relations); + return [{ _id: null, name: t('System', 'No Label', null, false) }].concat( + sortBy(relations, 'name') + ); } ); diff --git a/app/react/Templates/components/FormConfigRelationship.js b/app/react/Templates/components/FormConfigRelationship.js index 86afdada4e..6f01bcecef 100644 --- a/app/react/Templates/components/FormConfigRelationship.js +++ b/app/react/Templates/components/FormConfigRelationship.js @@ -5,7 +5,7 @@ import Immutable from 'immutable'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { createSelector } from 'reselect'; - +import { sortBy } from 'lodash'; import { Select } from 'app/ReactReduxForms'; import { Translate, t } from 'app/I18N'; import { Icon } from 'app/UI'; @@ -52,7 +52,10 @@ export class FormConfigRelationship extends Component { inheritSelectPropertyType, } = this.props; - const options = templates.toJS().filter(template => template._id !== templateId); + const options = sortBy( + templates.toJS().filter(template => template._id !== templateId), + 'name' + ); const labelClass = labelError ? 'form-group has-error' : 'form-group'; const canBeFilter = @@ -76,7 +79,7 @@ export class FormConfigRelationship extends Component {