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

Federation view fixes #923

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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
exclude: '(api|chat|control)/migrations/.*'
repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v2.3.0
rev: v4.5.0
Copy link
Member Author

@KoalaSat KoalaSat Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I upgraded pre-commit, I hope it's fine

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

hooks:
- id: check-merge-conflict
- id: check-yaml
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/basic/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const NavBar = (): JSX.Element => {
useEffect(() => {
// change tab (page) into the current route
const pathPage: Page | string = location.pathname.split('/')[1];
if (pathPage === 'index.html') {
if (pathPage === 'index.html' || !pathPage) {
navigate('/robot');
setPage('robot');
}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/basic/SettingsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Grid, Paper } from '@mui/material';
import SettingsForm from '../../components/SettingsForm';
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
import FederationTable from '../../components/FederationTable';
import { FederationContext, UseFederationStoreType } from '../../contexts/FederationContext';

const SettingsPage = (): JSX.Element => {
const { windowSize, navbarHeight, settings, setOpen, open, hostUrl } =
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Dialogs/Coordinator.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react';
import React, { useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';

import {
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/FederationTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const FederationTable = ({
fillContainer = false,
}: FederationTableProps): JSX.Element => {
const { t } = useTranslation();
const { federation, setFocusedCoordinator } =
const { federation, setFocusedCoordinator, coordinatorUpdatedAt } =
useContext<UseFederationStoreType>(FederationContext);
const { hostUrl } = useContext<UseAppStoreType>(AppContext);
const theme = useTheme();
Expand All @@ -47,11 +47,12 @@ const FederationTable = ({
const height = defaultPageSize * verticalHeightRow + verticalHeightFrame;

const [useDefaultPageSize, setUseDefaultPageSize] = useState(true);

useEffect(() => {
if (useDefaultPageSize) {
setPageSize(defaultPageSize);
}
});
}, [coordinatorUpdatedAt]);

const localeText = {
MuiTablePagination: { labelRowsPerPage: t('Coordinators per page:') },
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/models/Coordinator.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,11 @@ export class Coordinator {
});
};

enable = () => {
enable = (onEnabled: () => void = () => {}) => {
this.enabled = true;
this.update(() => {
onEnabled();
});
};

disable = () => {
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/models/Federation.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,13 @@ export class Federation {

disableCoordinator = (shortAlias: string) => {
this.coordinators[shortAlias].disable();
this.triggerHook('onCoordinatorUpdate');
};

enableCoordinator = (shortAlias: string) => {
this.coordinators[shortAlias].enable();
this.coordinators[shortAlias].enable(() => {
this.triggerHook('onCoordinatorUpdate');
});
};
}

Expand Down
Loading