WordPress.org

Making WordPress.org

Changeset 9700


Ignore:
Timestamp:
04/06/2020 03:13:11 AM (7 months ago)
Author:
dd32
Message:

Trac: Redirect Gutenberg, WordCamp, Five for the future, and WordPress.org tickets to the proper bug trackers.

These apply based on the component, so if a Trac doesn't have the component it's obviously not going to do any redirection logic for it.
Bug Gardeners can always bypass, but regular users won't see the Create buttons (Except for Editor, which can by bypassed).

Fixes #4643.

Location:
sites/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/trac.wordpress.org/templates/site.html

    r9695 r9700  
    55
    66<?python
    7     scripts_version = '140'
     7    scripts_version = '141'
    88    project_slug = req.environ['HTTP_HOST'].split(':')[0].split('.')[0]
    99    wporg_endpoint = 'https://make.wordpress.org/' + project_slug + '/'
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js

    r9695 r9700  
    11/* globals wpTracAutoCompleteUsers, wpTracContributorLabels, wpTracCurrentUser */
    2 var wpTrac, coreKeywordList, gardenerKeywordList, reservedTerms, coreFocusesList, $body;
     2var wpTrac, coreKeywordList, gardenerKeywordList, reservedTerms, coreFocusesList, bugTrackerLocations, $body;
    33
    44(function($){
     
    5252    };
    5353
     54    // Other Bug Trackers which the WordPress project uses for various things.
     55    bugTrackerLocations = {
     56        'WordPress.org Site': {
     57            tracker: 'https://meta.trac.wordpress.org/newticket',
     58            tracker_text: 'WordPress.org Meta Trac',
     59            prevent_changing_to: true
     60        },
     61        'Editor': {
     62            tracker: 'https://github.com/WordPress/gutenberg/issues/new/choose',
     63            tracker_text: 'Gutenberg GitHub Repository',
     64            bug_text: "the Gutenberg Editor",
     65            disable_copy: true, // Gutenberg has a bug-report flow.
     66            allow_bypass: true,
     67        },
     68        'WordCamp Site & Plugins': {
     69            tracker: 'https://github.com/WordPress/wordcamp.org/issues/new/choose',
     70            tracker_text: 'WordCamp.org GitHub Repository',
     71            disable_copy: true // WordCamp has a bug-report flow.
     72        },
     73        'Five For The Future': {
     74            tracker: 'https://github.com/WordPress/five-for-the-future/issues/new',
     75            tracker_text: 'Five for the Future GitHub Repository'
     76        }
     77    };
     78
    5479    gardenerKeywordList = [ 'commit', 'early', 'i18n-change', 'good-first-bug', 'fixed-major' ];
    5580
     
    277302            // Ticket-only tweaks.
    278303            if ( content.hasClass( 'ticket' ) ) {
    279                 if ( $body.hasClass( 'core' ) ) {
    280                     wpTrac.coreToMeta();
    281                 }
     304                wpTrac.redirectTicketsToProperTracker();
    282305
    283306                // A collection of ticket hacks that must be run again after previews.
     
    690713        },
    691714
    692         coreToMeta: function() {
     715        redirectTicketsToProperTracker: function() {
    693716            var component = $('#field-component');
    694             if ( window.location.pathname !== '/newticket' ) {
    695                 if ( ! wpTrac.gardener && component.val() !== 'WordPress.org site' ) {
    696                     component.children('option[value="WordPress.org site"]').remove();
     717            // Special hack to not show the warning on Meta Trac for the WordPress.org site.
     718            if ( window.location.host === 'meta.trac.wordpress.org' ) {
     719                delete bugTrackerLocations['WordPress.org Site'];
     720            }
     721
     722            // Prevent changing to the component if need be.
     723            if ( window.location.pathname !== '/newticket' ) {
     724                for ( var c in bugTrackerLocations ) {
     725                    if ( ! bugTrackerLocations[c].prevent_changing_to ) {
     726                        continue;
     727                    }
     728                    if ( component.val() != c ) {
     729                        component.children('option[value="' + c + '"]').remove();
     730                    }
    697731                }
    698732                return;
    699733            }
    700734
     735            // Show a notice when the component is selected.
    701736            component.change( function() {
    702737                var toggle = $('input[name="attachment"]').parent().add('.ticketdraft').add('.wp-notice').add('div.buttons');
    703                 if ( $(this).val() !== 'WordPress.org site' ) {
     738
     739                // Reset.
     740                $('.wp-notice.component').remove();
     741                toggle.hide();
     742
     743                var selectedComponent = $(this).val();
     744                if ( !( selectedComponent in bugTrackerLocations ) ) {
    704745                    toggle.show();
    705                     $('.wp-notice.component').remove();
    706746                    return;
    707747                }
    708                 toggle.hide();
    709                 $('div.buttons').after( '<div class="wp-notice component"><p><strong>The WordPress.org site now has its own Trac</strong> at ' +
    710                     '<a href="//meta.trac.wordpress.org/">meta.trac.wordpress.org</a>.</p><p>Would you mind opening this ticket over there instead? ' +
    711                     '<a href="//meta.trac.wordpress.org/newticket" id="new-meta-ticket">Click here to copy your summary and description over</a>.</p></div>' );
     748
     749                var tracker = bugTrackerLocations[ selectedComponent ];
     750
     751                // If the component (ie. Editor) allows bypassing the warning.. or if it's a Bug Gardener, show the create buttons.
     752                if ( tracker.allow_bypass || wpTrac.gardener ) {
     753                    toggle.show();
     754                }
     755
     756                $('div.buttons').before(
     757                    '<div class="wp-notice component"><p>' +
     758                        '<strong>Tickets related to ' + ( tracker.bug_text || selectedComponent ) + '</strong> should be filed on the ' +
     759                        '<a href="' + tracker.tracker + '">' + ( tracker.tracker_text || tracker.tracker ) + '</a>' +
     760                    '</p><p>' +
     761                        'Would you mind opening this ticket over there instead? ' +
     762                        ( tracker.disable_copy ? '' : '<a href="' + tracker.tracker + '" id="new-tracker-ticket">Click here to copy your summary and description over</a>.' ) +
     763                    '</p>' +
     764                        ( tracker.allow_bypass ? '<p>If this isn\'t related to ' + ( tracker.bug_text || selectedComponent ) + ', please continue to open this ticket here.</p>' : '' ) +
     765                    '</div>'
     766                );
    712767            });
    713768
    714             $('#propertyform').on( 'click', '#new-meta-ticket', function() {
    715                 var url, href = $(this).attr( 'href' );
    716                 url = href + '?' + $.param({ summary: $('#field-summary').val(), description: $('#field-description').val() });
     769            $('#propertyform').on( 'click', '#new-tracker-ticket', function() {
     770                var url, url_params = {}, href = $(this).attr( 'href' ),
     771                    summary_field = 'summary', description_field = 'description';
     772
     773                // Trac (default) and GitHub are supported.
     774                if ( href.match( /github.com/ ) ) {
     775                    summary_field = 'title';
     776                    description_field = 'body';
     777                }
     778
     779                url_params[summary_field]     = $('#field-summary').val();
     780                url_params[description_field] = $('#field-description').val()
     781
     782                url = href + '?' + $.param( url_params );
    717783                if ( url.length > 1500 ) {
    718                     url = href + '?' + $.param({
    719                         summary: $('#field-summary').val(),
    720                         description: '(Couldn\'t copy over your description as it was too long. Please paste it here. Your old window was not closed.)'
    721                     });
     784                    url_params[description_field] = '(Couldn\'t copy over your description as it was too long. Please paste it here. Your old window was not closed.)';
     785                    url = href + '?' + $.param( url_params );
    722786                    window.open( url );
    723787                } else {
Note: See TracChangeset for help on using the changeset viewer.