Skip to content
Open
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 client/src/Components/Navigation/HomeNav/HomeNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Navbar = ({ page, user, loggedIn, isDark, toggleAdmin }) => {
</Aux>
)}
<NavItem
link="/community/rooms?privacy=all&roomType=all"
link="/community/rooms?privacy=all&roomType=all&roomStatus=default"
name="Community"
/>
{user.isAdmin ? (
Expand Down
2 changes: 1 addition & 1 deletion client/src/Components/Navigation/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Navbar = ({ user, location, toggleAdmin }) => {
<ul className={classes.NavList}>
<NavItem link="/myVMT/rooms" name="My VMT" ntf={ntf} />
<NavItem
link="/community/rooms?privacy=all&roomType=all"
link="/community/rooms?privacy=all&roomType=all&roomStatus=default"
name="Community"
/>
{user.isAdmin ? (
Expand Down
6 changes: 4 additions & 2 deletions client/src/Components/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Search extends Component {
value,
isControlled,
'data-testid': dataTestId,
roomStatus,
} = this.props;
return (
<div className={[classes.Search].join(' ')}>
Expand All @@ -29,7 +30,7 @@ class Search extends Component {
className={[classes.Input, classes[theme]].join(' ')}
type="text"
placeholder={placeholder}
onChange={(event) => _search(event.target.value)}
onChange={(event) => _search(event.target.value, roomStatus)}
/>
) : (
<input
Expand All @@ -38,7 +39,7 @@ class Search extends Component {
className={[classes.Input, classes[theme]].join(' ')}
type="text"
placeholder={placeholder}
onChange={(event) => _search(event.target.value)}
onChange={(event) => _search(event.target.value, roomStatus)}
/>
)}
<i className={['fas fa-search', classes.Icon].join(' ')} />
Expand All @@ -54,6 +55,7 @@ Search.propTypes = {
_search: PropTypes.func.isRequired,
isControlled: PropTypes.bool,
'data-testid': PropTypes.string.isRequired,
roomStatus: PropTypes.string.isRequired,
};

Search.defaultProps = {
Expand Down
78 changes: 78 additions & 0 deletions client/src/Components/UI/Modal/ArchiveModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Modal from './Modal';
import classes from './modal.css';
import Button from '../Button/Button';

// NOT READY FOR USE WITH COURSES OR ACTIVITIES
const hash = {
course: 'courses',
room: 'rooms',
activity: 'activities',
};
class ArchiveModal extends Component {
archiveResource = () => {
const {
history,
update,
closeModal,
resource,
resourceId,
restoring,
} = this.props;
const updateBody = restoring
? { isArchived: false, isTrashed: false }
: { isArchived: true };
history.push(`/myVMT/${hash[resource]}`);
update(resourceId, updateBody);
closeModal();
};

// archiveResourceAndChildren = () => {
// const { history, update, closeModal, resource, resourceId } = this.props;
// update(resourceId, {
// isArchived: true,
// archiveChildren: true,
// });
// closeModal();
// history.push(`/myVMT/${hash[resource]}`);
// };

render() {
const { show, closeModal, resource, restoring } = this.props;
const actionName = restoring ? 'restore' : 'archive';
const iconClass = restoring ? 'fas fa-undo' : 'fas fa-archive';
return (
<Modal show={show} closeModal={closeModal}>
<div>
Are you sure you want to {actionName} this {resource}?
</div>
<div className={classes.Row}>
<Button
m={10}
theme="Danger"
data-testid="confirm-archive"
click={this.archiveResource}
>
<i className={iconClass} />
{actionName} this {resource}
</Button>
<Button m={10} theme="Cancel" click={closeModal}>
Cancel
</Button>
</div>
</Modal>
);
}
}

ArchiveModal.propTypes = {
history: PropTypes.shape({}).isRequired,
update: PropTypes.func.isRequired,
show: PropTypes.bool.isRequired,
closeModal: PropTypes.func.isRequired,
resource: PropTypes.string.isRequired,
resourceId: PropTypes.string.isRequired,
restoring: PropTypes.bool.isRequired,
};
export default ArchiveModal;
1 change: 1 addition & 0 deletions client/src/Components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export { default as EditableText } from './EditableText/EditableText';
export { default as EditText } from './EditableText/EditText';
export { default as SelectionList } from './Form/SelectionList/SelectionList';
export { default as TrashModal } from './UI/Modal/TrashModal';
export { default as ArchiveModal } from './UI/Modal/ArchiveModal';
export { default as Error } from './HOC/Error';
export { default as ErrorToast } from './Error/ErrorToast';
export { default as DemoBrowser } from './DemoBrowser/DemoBrowser';
Expand Down
15 changes: 12 additions & 3 deletions client/src/Containers/Community.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class Community extends Component {
if (updatedFilters.privacySetting === 'all') {
delete updatedFilters.privacySetting;
}
if (updatedFilters.roomStatus === 'default') {
delete updatedFilters.roomStatus;
}
API.searchPaginated(
resource,
updatedFilters.search,
Expand Down Expand Up @@ -127,6 +130,10 @@ class Community extends Component {
filters.roomType = 'all';
} else if (filter === 'all-privacySetting') {
filters.privacySetting = 'all';
} else if (filter === 'isArchived' || filter === 'isTrashed') {
filters.roomStatus = filter;
} else if (filter === 'default-roomStatus') {
filters.roomStatus = 'default';
}
if (resource === 'courses') {
filters.roomType = null;
Expand All @@ -143,17 +150,18 @@ class Community extends Component {
privacySetting: params.get('privacy'),
roomType: params.get('roomType'),
search: params.get('search'),
roomStatus: params.get('roomStatus'),
};
return filters;
};

setQueryParams = (filters) => {
const { history, match } = this.props;
const { privacySetting, roomType, search } = filters;
const { privacySetting, roomType, roomStatus, search } = filters;
history.push({
pathname: match.url,
search: `?privacy=${privacySetting || 'all'}&roomType=${roomType ||
'all'}&search=${search || ''}`,
'all'}&roomStatus=${roomStatus || 'default'}&search=${search || ''}`,
});
};

Expand All @@ -166,7 +174,7 @@ class Community extends Component {
};

render() {
const { match } = this.props;
const { match, user } = this.props;
const { visibleResources, moreAvailable, searchText } = this.state;
const filters = this.getQueryParams();
let linkPath;
Expand Down Expand Up @@ -194,6 +202,7 @@ class Community extends Component {
moreAvailable={moreAvailable}
filters={filters}
toggleFilter={this.toggleFilter}
user={user}
/>
);
}
Expand Down
4 changes: 3 additions & 1 deletion client/src/Containers/MyVMT.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class MyVMT extends Component {
};

render() {
const { user, match } = this.props;
const { user, match, location } = this.props;
const { bothRoles, view, tabs } = this.state;
const { resource } = match.params;

Expand Down Expand Up @@ -128,6 +128,7 @@ class MyVMT extends Component {
}
user={user}
resource={resource}
location={location}
/>
}
tabs={<TabList routingInfo={match} tabs={tabs} />}
Expand All @@ -139,6 +140,7 @@ class MyVMT extends Component {
MyVMT.propTypes = {
match: PropTypes.shape({}).isRequired,
user: PropTypes.shape({}).isRequired,
location: PropTypes.shape({}).isRequired,
};

// @NB THE LACK OF CAMEL CASE HERE IS INTENTIONAL AND ALLOWS US TO AVOID LOTS
Expand Down
Loading