todos-contra-el-fuego-web/imports/ui/pages/ViewDocument/ViewDocument.js
vjrj a1a1b9a801 deps: react-bootstrap 0.31 -> 2 (Bootstrap 5 CSS deferred as debt)
Removes the largest batch of React-19-blocking warnings: the 0.31
components (Grid, FormGroup, ControlLabel, Navbar.Header/Brand, Checkbox,
SafeAnchor) all leaned on legacy context / defaultProps.

29 files converted: Grid->Container, FormGroup/ControlLabel/FormControl/
HelpBlock -> Form.Group/Label/Control/Text, Checkbox -> Form.Check (label
as prop), bsStyle->variant (default->secondary), bsSize->size,
pull-right->float-end. Custom Col.js now re-exports v2's Col; custom
NavItem.js rewritten self-contained (no SafeAnchor/createChainedFunction);
Navigation.js drops react-bootstrap Navbar (raw markup anyway).

CSS stays on Bootstrap 4 (alexwine:bootstrap-4) for now: the BS4->5 jump
is entangled with the jQuery carousel/swipe + navbar-collapse and is
tracked as separate debt in UPGRADE.md. Only .form-label needed a shim
(forms.scss). Browser-verified home carousel+navbar, signup form + terms
checkbox, login form; REST smoke byte-identical.
2026-07-21 12:44:46 +02:00

62 lines
1.9 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { ButtonToolbar, ButtonGroup, Button } from 'react-bootstrap';
import { withTracker } from 'meteor/react-meteor-data';
import { Meteor } from 'meteor/meteor';
import { Bert } from 'meteor/themeteorchef:bert';
import Documents from '../../../api/Documents/Documents';
import NotFound from '../NotFound/NotFound';
import Loading from '../../components/Loading/Loading';
const handleRemove = (documentId, history) => {
if (confirm('Are you sure? This is permanent!')) {
Meteor.call('documents.remove', documentId, (error) => {
if (error) {
Bert.alert(error.reason, 'danger');
} else {
Bert.alert('Document deleted!', 'success');
history.push('/documents');
}
});
}
};
const renderDocument = (doc, match, history) => (doc ? (
<div className="ViewDocument">
<div className="page-header clearfix">
<h4 className="pull-left">{ doc && doc.title }</h4>
<ButtonToolbar className="float-end">
<ButtonGroup size="sm">
<Button onClick={() => history.push(`${match.url}/edit`)}>Edit</Button>
<Button onClick={() => handleRemove(doc._id, history)} className="text-danger">
Delete
</Button>
</ButtonGroup>
</ButtonToolbar>
</div>
{ doc && doc.body }
</div>
) : <NotFound />);
const ViewDocument = ({
loading, doc, match, history
}) => (
!loading ? renderDocument(doc, match, history) : <Loading />
);
ViewDocument.propTypes = {
loading: PropTypes.bool.isRequired,
doc: PropTypes.object,
match: PropTypes.object.isRequired,
history: PropTypes.object.isRequired
};
export default withTracker(({ match }) => {
const documentId = match.params._id;
const subscription = Meteor.subscribe('documents.view', documentId);
return {
loading: !subscription.ready(),
doc: Documents.findOne(documentId)
};
})(ViewDocument);