Skip to content

Commit

Permalink
Fix LabRenderer + clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ThiefMaster committed Dec 5, 2024
1 parent 5184321 commit b4a6f40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 28 deletions.
37 changes: 11 additions & 26 deletions labotel/indico_labotel/client/js/components/LabRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import PropTypes from 'prop-types';
import React from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {useDispatch} from 'react-redux';
import {Item} from 'semantic-ui-react';

import {actions as roomActions} from 'indico/modules/rb/common/rooms';
Expand All @@ -17,9 +16,10 @@ import {Slot, Markdown} from 'indico/react/util';

import './LabRenderer.module.scss';

function LabItem({roomInstance, openRoomDetails}) {
const {room} = roomInstance.props;
export default function LabItem({roomInstance, room}) {
const {actions} = Slot.split(roomInstance.props.children);
const dispatch = useDispatch();
const openRoomDetails = () => dispatch(roomActions.openRoomDetailsBook(room.id));
return (
<Item key={room.id} styleName="lab-item">
<Item.Image
Expand All @@ -32,8 +32,11 @@ function LabItem({roomInstance, openRoomDetails}) {
</Item.Image>
<Item.Content>
<Item.Header styleName="lab-item-header">
<div onClick={() => openRoomDetails(room.id)} style={{cursor: 'pointer'}}>
{room.fullName}
<div>
<span onClick={() => openRoomDetails(room.id)} style={{cursor: 'pointer'}}>
{room.fullName}
</span>{' '}
{roomInstance.renderRoomStatus()}
</div>
<div>
{actions}
Expand All @@ -42,7 +45,7 @@ function LabItem({roomInstance, openRoomDetails}) {
</Item.Header>
<Item.Meta>{room.division}</Item.Meta>
<Item.Description>
<Markdown disallowedElements={['br']}>{room.comments}</Markdown>
<Markdown targetBlank>{room.comments}</Markdown>
</Item.Description>
</Item.Content>
</Item>
Expand All @@ -51,23 +54,5 @@ function LabItem({roomInstance, openRoomDetails}) {

LabItem.propTypes = {
roomInstance: PropTypes.object.isRequired,
openRoomDetails: PropTypes.func.isRequired,
};

export function LabRenderer({roomInstance, openRoomDetails}) {
return <LabItem roomInstance={roomInstance} openRoomDetails={openRoomDetails} />;
}

LabRenderer.propTypes = {
roomInstance: PropTypes.object.isRequired,
openRoomDetails: PropTypes.func.isRequired,
room: PropTypes.object.isRequired,
};

const mapDispatchToProps = dispatch => ({
openRoomDetails: bindActionCreators(roomActions.openRoomDetailsBook, dispatch),
});

export default connect(
null,
mapDispatchToProps
)(LabRenderer);
4 changes: 2 additions & 2 deletions labotel/indico_labotel/client/js/parametrized.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import DefaultRoomList from 'indico/modules/rb/modules/roomList/RoomList';
import {Translate} from 'indico/react/i18n';
import {ConditionalRoute} from 'indico/react/util';

import LabRenderer from './components/LabRenderer';
import LabItem from './components/LabRenderer';
import MapMarkers from './components/MapMarkers';
import StatsPage from './components/StatsPage';

Expand All @@ -49,7 +49,7 @@ const RoomRenderer = parametrize(DefaultRoomRenderer, {
});

const Room = parametrize(DefaultRoom, {
customRenderer: roomInstance => <LabRenderer roomInstance={roomInstance} />,
customRoomComponent: LabItem,
});

const RoomFilterBar = parametrize(RoomFilterBarBase, {
Expand Down

0 comments on commit b4a6f40

Please sign in to comment.