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

[#3708] Sort status alphabetically #3712

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions frontend/control-center/src/pages/Status/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useEffect, useState} from 'react';
import {connect, ConnectedProps, useSelector} from 'react-redux';
import {connect, ConnectedProps} from 'react-redux';
import {getClientConfig, getConnectorsConfiguration, listComponents} from '../../actions';
import {StateModel} from '../../reducers';
import {ComponentListItem} from './ComponentListItem';
Expand All @@ -14,12 +14,17 @@ const mapDispatchToProps = {
listComponents,
};

const connector = connect(null, mapDispatchToProps);
const mapStateToProps = (state: StateModel) => {
return {
components: Object.entries(state.data.config.components),
catalog: state.data.catalog,
};
};

const connector = connect(mapStateToProps, mapDispatchToProps);

const Status = (props: ConnectedProps<typeof connector>) => {
const {getClientConfig, getConnectorsConfiguration, listComponents} = props;
const components = useSelector((state: StateModel) => Object.entries(state.data.config.components));
const catalogList = useSelector((state: StateModel) => state.data.catalog);
const {components, catalog, getClientConfig, getConnectorsConfiguration, listComponents} = props;
const [spinAnim, setSpinAnim] = useState(true);
const [lastRefresh, setLastRefresh] = useState(new Date().toLocaleString());
const {t} = useTranslation();
Expand Down Expand Up @@ -56,7 +61,7 @@ const Status = (props: ConnectedProps<typeof connector>) => {
const formatToComponentName = (name: string) => {
let formattedName;
if (name.includes('enterprise')) {
formattedName = `'airy-enterprise'/${name}`;
formattedName = `airy-enterprise/${name}`;
} else {
formattedName = `airy-core/${name}`;
}
Expand Down Expand Up @@ -85,10 +90,10 @@ const Status = (props: ConnectedProps<typeof connector>) => {
</button>
</div>
<div className={styles.listItems}>
{Object.entries(catalogList).length > 0 &&
{Object.entries(catalog).length > 0 &&
components.map((component, index) => {
const formattedName = formatToComponentName(component[0]);
const catalogItem = catalogList[formattedName];
const catalogItem = catalog[formattedName];
return (
<ComponentListItem
key={index}
Expand Down
5 changes: 4 additions & 1 deletion lib/typescript/model/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ export enum Language {

export const getComponents = (config: Config) => {
const {services} = config;
const servicesSorted = Object.fromEntries(
Object.entries(services).sort((a, b) => a[1].component.localeCompare(b[1].component))
);

return Object.keys(services).reduce((agg, key) => {
return Object.keys(servicesSorted).reduce((agg, key) => {
const {healthy, enabled, component} = services[key];

return {
Expand Down