Skip to content

Commit 7d39a32

Browse files
authored
Scoot UI around and expose counts (#1943)
* Scoot syncs closer to scripts since they are related. Post #1736 * Expose previous counts to the authed user... still tracking at admin+ but may allow mod+ for just the counts but not content for mods... still pondering... votes may not be necessary and they already have access to "anonymous" flagging... thinking out loud... still pondering. * Flags include historical count regardless of action taken. This will eventually change. Post #1942 #785 NOTE: * Btw AuthAs is great however it's really annoying at times *(think reauthentication confirmations)* so this is why Admin+ have quicker access to see what's going on without authAs then end session and restart a new Admin+ session. Auto-merge
1 parent 3422bbe commit 7d39a32

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

controllers/user.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@ exports.view = function (aReq, aRes, aNext) {
567567
user.aboutRendered = renderMd(user.about);
568568
options.isYou = authedUser && user && authedUser._id == user._id;
569569

570+
options.isYouOrAdmin = options.isYou || options.isAdmin;
571+
options.isYouOrMod = options.isYou || options.isMod;
572+
570573
// Page metadata
571574
pageMetadata(options, [user.name, 'Users']);
572575
options.isUserPage = true;
@@ -679,6 +682,9 @@ exports.userCommentListPage = function (aReq, aRes, aNext) {
679682
user = options.user = modelParser.parseUser(aUser);
680683
options.isYou = authedUser && user && authedUser._id == user._id;
681684

685+
options.isYouOrAdmin = options.isYou || options.isAdmin;
686+
options.isYouOrMod = options.isYou || options.isMod;
687+
682688
// Page metadata
683689
pageMetadata(options, [user.name, 'Users']);
684690
options.isUserCommentListPage = true;
@@ -832,6 +838,9 @@ exports.userScriptListPage = function (aReq, aRes, aNext) {
832838
options.user = user = modelParser.parseUser(aUser);
833839
options.isYou = authedUser && user && authedUser._id == user._id;
834840

841+
options.isYouOrAdmin = options.isYou || options.isAdmin;
842+
options.isYouOrMod = options.isYou || options.isMod;
843+
835844
switch (aReq.query.library) {
836845
case 'true': // List just libraries
837846
options.includeLibraries = true;
@@ -950,8 +959,11 @@ exports.userSyncListPage = function (aReq, aRes, aNext) {
950959
user = options.user = modelParser.parseUser(aUser);
951960
options.isYou = authedUser && user && authedUser._id == user._id;
952961

962+
options.isYouOrAdmin = options.isYou || options.isAdmin;
963+
options.isYouOrMod = options.isYou || options.isMod;
964+
953965
// If not you or not synacable auth strategy move along
954-
if (!options.isYou || !options.user.canSync) {
966+
if (!options.isYouOrAdmin || !options.user.canSync) {
955967
aNext();
956968
return;
957969
}

routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ module.exports = function (aApp) {
366366
// User routes
367367
aApp.route('/users').get(listRateLimiter, listCapLimiter, user.userListPage);
368368
aApp.route('/users/:username').get(user.view);
369-
aApp.route('/users/:username/comments').get(listRateLimiter, listCapLimiter, user.userCommentListPage);
370369
aApp.route('/users/:username/scripts').get(listRateLimiter, listCapLimiter, user.userScriptListPage);
371370
aApp.route('/users/:username/syncs').get(listRateLimiter, listCapLimiter, user.userSyncListPage);
371+
aApp.route('/users/:username/comments').get(listRateLimiter, listCapLimiter, user.userCommentListPage);
372372

373373
aApp.route('/users/:username/github/repos').get(authentication.validateUser, user.userGitHubRepoListPage);
374374
aApp.route('/users/:username/github/repo').get(authentication.validateUser, user.userGitHubRepoPage);

views/includes/userPageHeader.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ <h2 class="page-heading">
1212
<ul class="nav navbar-nav">
1313
<li class="{{#isUserPage}}active{{/isUserPage}}"><a href="{{{user.userPageUrl}}}">Profile</a></li>
1414
<li class="{{#isUserScriptListPage}}active{{/isUserScriptListPage}}"><a href="{{{user.userScriptListPageUrl}}}" class="{{^user.userScriptListPageUrl}}disabled{{/user.userScriptListPageUrl}}">Scripts{{#scriptListCount}} <span class="badge">{{scriptListCount}}</span>{{/scriptListCount}}</a></li>
15-
<li class="{{#isUserCommentListPage}}active{{/isUserCommentListPage}}"><a href="{{{user.userCommentListPageUrl}}}" class="{{^user.userCommentListPageUrl}}disabled{{/user.userCommentListPageUrl}}">Comments{{#commentListCount}} <span class="badge">{{commentListCount}}</span>{{/commentListCount}}</a></li>
16-
{{#isAdmin}}
17-
<li class=""><a href="#">Votes{{#voteListCount}} <span class="badge">{{voteListCount}}</span>{{/voteListCount}}</a></li>
18-
<li class=""><a href="#">Flags{{#flagListCount}} <span class="badge">{{flagListCount}}</span>{{/flagListCount}}</a></li>
19-
{{/isAdmin}}
20-
{{#isYou}}
15+
{{#isYouOrAdmin}}
2116
{{#user.canSync}}
2217
<li class="{{#isUserSyncListPage}}active{{/isUserSyncListPage}}"><a href="{{{user.userSyncListPageUrl}}}" class="{{^user.userSyncListPageUrl}}disabled{{/user.userSyncListPageUrl}}">Syncs{{#syncListCount}} <span class="badge">{{syncListCount}}</span>{{/syncListCount}}</a></li>
2318
{{/user.canSync}}
24-
{{/isYou}}
19+
{{/isYouOrAdmin}}
20+
<li class="{{#isUserCommentListPage}}active{{/isUserCommentListPage}}"><a href="{{{user.userCommentListPageUrl}}}" class="{{^user.userCommentListPageUrl}}disabled{{/user.userCommentListPageUrl}}">Comments{{#commentListCount}} <span class="badge">{{commentListCount}}</span>{{/commentListCount}}</a></li>
21+
{{#isYouOrAdmin}}
22+
<li class=""><a href="#">Votes{{#voteListCount}} <span class="badge">{{voteListCount}}</span>{{/voteListCount}}</a></li>
23+
<li class=""><a href="#">Flags{{#flagListCount}} <span class="badge">{{flagListCount}}</span>{{/flagListCount}}</a></li>
24+
{{/isYouOrAdmin}}
2525
</ul>
2626
</div>
2727
</nav>

0 commit comments

Comments
 (0)