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

added my collections button #592

Merged
merged 7 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 6 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
19 changes: 19 additions & 0 deletions src/client/components/pages/parts/collections-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,32 @@ class CollectionsTable extends React.Component {
// 2.Check if user is logged In if so checks the page is central public collections page or not
const showNewCollectionButton = (user && user.id === ownerId) ||
(user && !ownerId);

const myCollectionButton = (
<Button
bsStyle="success"
className="margin-bottom-d5"
href={`/editor/${user.id}/collections`}
type="button"
>
&nbsp;My Collections
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
&nbsp;My Collections
My Collections

Since there's no icon before the text we don't need that space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made the suggested changes.

</Button>
);

// Display My collections button when
// 1.the user is logged in and not viewing the user's collections
// 2.the user is logged in and viewing public collections
const showMyCollectionButton = user && (user.id !== ownerId || !ownerId);

return (
<div>
<div>
<h1 className="text-center">
{tableHeading}
</h1>
<div className="collection-page-buttons">
{showMyCollectionButton &&
myCollectionButton}
{showNewCollectionButton &&
newCollectionButton}
{entityTypeSelect}
Expand Down
5 changes: 3 additions & 2 deletions src/server/routes/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ router.get('/', async (req, res, next) => {
if (!entityTypes.includes(type) && type !== null) {
throw new error.BadRequestError(`Type ${type} do not exist`);
}

const {user} = req;
// fetch 1 more collections than required to check nextEnabled
const orderedRevisions = await getOrderedPublicCollections(from, size + 1, type, orm);
const {newResultsArray, nextEnabled} = utils.getNextEnabledAndResultsArray(orderedRevisions, size);
Expand All @@ -57,7 +57,8 @@ router.get('/', async (req, res, next) => {
showLastModified: true,
showOwner: true,
size,
tableHeading: 'Public Collections'
tableHeading: 'Public Collections',
user
});

/*
Expand Down