861
862
namespace._safely_render_description = safely_render_description;
865
* This is a simple helper function for the *_action functions below. It
866
* takes an id and returns a Y.Node div with that id.
863
868
function make_action(id) {
864
869
return Y.Node.create('<div/>')
865
870
.addClass('hidden')
875
* Return a node for muting the bug.
869
877
function mute_action() {
870
878
return make_action(action_ids.mute)
871
.set('text', 'MUTE'); // TODO fill in actual contents
881
'mute all emails from this bug',
884
namespace._mute_action = mute_action;
887
* Return a node for unmuting the bug.
874
889
function unmute_action() {
875
890
return make_action(action_ids.unmute)
876
.set('text', 'UNMUTE'); // TODO fill in actual contents
893
'receive emails about this bug from other subscriptions',
894
'yes', 'unmute', {}));
896
namespace._unmute_action = unmute_action;
899
* Return a node for subscribing to all emails from the bug.
879
901
function subscribe_all_action() {
880
902
return make_action(action_ids.subscribe_all)
881
.set('text', 'SUBSCRIBE ALL'); // TODO fill in actual contents
903
.append(make_subscribe_link(
904
'receive all emails about this bug', 'Discussion'));
906
namespace._subscribe_all_action = subscribe_all_action;
909
* Return a node for subscribing to emails from this bug other than comments.
884
911
function subscribe_metadata_action() {
885
912
return make_action(action_ids.subscribe_metadata)
886
.set('text', 'SUBSCRIBE METADATA'); // TODO fill in actual contents
913
.append(make_subscribe_link(
914
'receive all emails about this bug except comments', 'Details'));
916
namespace._subscribe_metadata_action = subscribe_metadata_action;
919
* Return a node for subscribing to emails about this bug closing.
889
921
function subscribe_closed_action() {
890
922
return make_action(action_ids.subscribe_closed)
891
.set('text', 'SUBSCRIBE CLOSED'); // TODO fill in actual contents
923
.append(make_subscribe_link(
924
'only receive email when this bug is closed', 'Lifecycle'));
926
namespace._subscribe_closed_action = subscribe_closed_action;
929
* Return a node for reducing emails received from this bug to eliminate
930
* comments. This is functionally identical to subscribe_metadata_action,
931
* but has different text and is presented as a reduction, not an increase.
894
933
function subscribe_only_metadata_action() {
895
934
return make_action(action_ids.subscribe_only_metadata)
896
.set('text', 'SUBSCRIBE ONLY METADATA'); // TODO fill in
935
.append(make_subscribe_link(
936
'stop receiving comments from this bug', 'Details'));
938
namespace._subscribe_only_metadata_action = subscribe_only_metadata_action;
941
* Return a node for reducing emails received from this bug to eliminate
942
* everything but closing notifications. This is functionally identical to
943
* subscribe_closed_action, but has different text and is presented as a
944
* reduction, not an increase.
899
946
function subscribe_only_closed_action() {
900
947
return make_action(action_ids.subscribe_only_closed)
901
.set('text', 'SUBSCRIBE ONLY CLOSED'); // TODO fill in actual contents
948
.append(make_subscribe_link(
949
'only receive email when this bug is closed', 'Lifecycle'));
951
namespace._subscribe_only_closed_action = subscribe_only_closed_action;
954
* Return a node for unsubscribing to emails about this bug.
904
956
function unsubscribe_action() {
905
957
return make_action(action_ids.unsubscribe)
906
.set('text', 'UNSUBSCRIBE'); // TODO fill in actual contents
960
'unsubscribe from this bug',
961
'remove', 'unsubscribe', {}));
963
namespace._unsubscribe_action = unsubscribe_action;
966
* Return a node for unsubscribing to emails about this bug. This is
967
* functionally identical to unsubscribe_action, but has different text and
968
* includes a warning that unsubscribing may not stop all emails. This node
969
* is intended to be used if there are other, non-direct non-personal
970
* subscriptions that will cause the person to receive emails.
909
972
function unsubscribe_with_warning_action() {
910
973
return make_action(action_ids.unsubscribe_with_warning)
911
.set('text', 'UNSUBSCRIBE WITH WARNING'); // TODO fill in
975
Y.Node.create('<span/>')
976
.set('text', 'You can also '))
979
'unsubscribe from this bug',
980
'remove', 'unsubscribe', {}))
982
Y.Node.create('<span/>')
984
'. However, you also have other subscriptions to '+
985
'this bug that may send you email once you have '+
988
namespace._unsubscribe_with_warning_action = unsubscribe_with_warning_action;
991
* Makes links for subscribing actions.
993
function make_subscribe_link(text, level) {
994
return make_action_link(
998
{person: LP.links.me, level: level}
1003
* Makes links for all kinds of actions.
1005
* The link will be constructed to have an icon followed by text with
1006
* it all part of the <a> link.
1008
* @param {String} text Text of the link to be created.
1009
* @param {String} sprite_class Name of the sprite to use for an icon.
1010
* @param {String} method_name API method to call on the bug_link when the
1012
* @param {Object} parameters Dict of parameters to be passed to method_name.
1014
function make_action_link(text, sprite_class, method_name, parameters) {
1015
var node = Y.Node.create('<a/>')
1017
.set('href', '#') // Makes the mouse arrow change into a hand.
1020
.addClass(sprite_class)
1021
.addClass('js-action');
1022
var client = lp_client();
1023
var handler = new Y.lp.client.ErrorHandler();
1025
handler.showError = function(error_msg) {
1026
Y.lp.app.errors.display_error(node, error_msg);
1028
handler.clearProgressUI = function () {
1029
node.replaceClass('spinner', sprite_class);
1037
function (maybe_sub) {
1038
node.replaceClass('spinner', sprite_class);
1039
var info = LP.cache.bug_subscription_info;
1040
var old = info.direct.personal[0];
1041
if (Y.Lang.isValue(maybe_sub)) {
1042
// Set the subscription in info and in cache.
1043
var sub = maybe_sub.getAttrs();
1044
if (Y.Lang.isValue(old)) {
1045
info.direct.personal[0].subscription =
1048
// We don't have enough information to
1049
// calculate everything on the fly.
1050
// Luckily, we don't need most of it,
1051
// and we think it is alright to not
1052
// include the extra information about
1053
// principal_is_reporter,
1054
// security_contact_pillars, and
1055
// bug_supervisor_pillars.
1056
info.direct.personal.push(
1060
principal_is_reporter: false,
1061
security_contact_pillars: [],
1062
bug_supervisor_pillars: []
1064
info.direct.count += 1;
1068
sub.bug_notification_level ===
1071
if (Y.Lang.isValue(old)) {
1072
info.direct.personal.pop();
1073
info.direct.count -= 1;
1078
reveal_direct_description_actions(
1079
Y.one('#direct-subscription'),
1080
get_direct_subscription_information(info));
1082
failure: handler.getFailureHandler()
1084
parameters: parameters
1086
node.replaceClass(sprite_class, 'spinner');
1088
LP.cache.context.bug_link,
1095
namespace._make_action_link = make_action_link;
914
1097
function border_box(title, content_div) {
915
1098
return Y.Node.create('<div/>')
916
1099
.addClass('hidden')
917
1100
.setStyle('border', '1px solid #ddd')
918
1101
.setStyle('padding', '0 1em 1em 1em')
1102
.setStyle('marginTop', '1em')
919
1103
.append(Y.Node.create('<span/>')
920
1104
.setStyle('backgroundColor', '#fff')
921
1105
.setStyle('float', 'left')
922
.setStyle('marginTop', '-0.6em')
923
.setStyle('padding', '0 1ex')
1106
.setStyle('marginTop', '-0.8em')
1107
.setStyle('padding', '0 0.5em')
924
1108
.set('text', title))
925
1109
.append(content_div
926
1110
.setStyle('clear', 'both')