-
Notifications
You must be signed in to change notification settings - Fork 530
Expand file tree
/
Copy pathshowProjectAdmin.js
More file actions
112 lines (108 loc) · 3.56 KB
/
Copy pathshowProjectAdmin.js
File metadata and controls
112 lines (108 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import $ from 'jquery';
/**
* Dynamic generation and event bindings for project admin section of the admin box
* @param {project.js} project
*/
export default project => {
if ($('.project_admin').length) {
if (project.isProjectLevel() && project.isOwner()) {
if (project.isFrozen()) {
$('.project_admin').html(
$(
'<span>❄ Frozen! To use as an example, copy this id: <input type="text" disabled value="' +
project.getCurrentId() +
'"/><div><button id="unfreeze" class="btn btn-default btn-sm">Unfreeze</button><div></span>'
)
);
$('#unfreeze').click(function () {
project.unfreeze(function () {
window.location.reload();
});
});
} else {
$('.project_admin').html(
$(
'<button id="freeze" class="btn btn-default btn-sm">Freeze for use as an exemplar ❄</button>'
)
);
$('#freeze').click(function () {
project.freeze(function () {
window.location.reload();
});
});
}
}
}
if (!project.isPublished()) {
$('#unpublished_warning').show();
}
if ($('#bookmark_project').length && project.isProjectLevel()) {
$('#bookmark_project').click(function () {
var url = `/featured_projects/${project.getCurrentId()}/bookmark`;
$.ajax({
url: url,
type: 'PUT',
dataType: 'json',
success: function (data) {
$('#is_bookmarked_featured_project').show();
$('#bookmark_project').hide();
},
error: function (data) {
alert(
"Shucks. Something went wrong - this project wasn't bookmarked."
);
},
});
});
}
if (
$('.admin-project-sharing').length &&
(project.isProjectLevel() || !project.shouldHideShareAndRemix())
) {
var sharingDisabled = project.getSharingDisabled();
var privateOrProfane = project.hasPrivacyProfanityViolation();
var abuseScore = project.getAbuseScore();
$('.admin-abuse-score').text(abuseScore);
$('#admin-abuse-reset').click(function () {
project.adminResetAbuseScore(0);
});
var abusive = project.exceedsAbuseThreshold();
if (sharingDisabled || privateOrProfane || abusive) {
$('.blocked').show();
$('.blocked-reasons').show();
$('.unblocked').hide();
if (sharingDisabled) {
$('.admin-sharing').show();
}
if (privateOrProfane) {
$('.privacy-profanity').show();
var textViolationEnglish = project.privacyProfanityDetailsEnglish();
if (textViolationEnglish) {
$('.eng-flagged-text').text(textViolationEnglish);
$('.privacy-profanity-details-english').show();
}
var textViolationsIntl = project.privacyProfanityDetailsIntl();
var secondLanguage = project.privacyProfanitySecondLanguage();
if (textViolationsIntl && secondLanguage) {
$('.intl-flagged-text').text(textViolationsIntl);
$('.intl-flagged-language').text(secondLanguage);
$('.privacy-profanity-details-intl').show();
}
}
if (abusive) {
// The image moderation service sets the abuse score to 15 to
// differentiate from manual reports.
if (abuseScore === 15) {
$('.abusive-image').show();
$('.image-mod-controls').show();
} else {
$('.reported-abuse').show();
}
}
} else {
$('.unblocked').show();
$('.blocked').hide();
$('.blocked-reasons').hide();
}
}
};