Clear Field Configuration

If you came here through a direct link, you may want to check the main https://jaus.atlassian.net/wiki/spaces/JAUS page first!

Clear Field Configuration is a Userscript that allow Admins to hide all fields from a Field Configuration that’s currently not in use. It can also show all fields instead (like a panic rollback :)).

How the Userscript looks in Violentmonkey once installed.

Download/installation URL:

https://bitbucket.org/jira-admin-userscripts/jaus/raw/master/src/jaus-clear-field-configuration.user.js

Use cases

Keeping Field Configurations with as minimum fields as possible is a known best-practice to prevent performance degradation (specially during re-index). See https://confluence.atlassian.com/clean/clean-up-your-jira-instance-1018788592.html (and the Advanced cleanup).

Whenever a custom field’s created it’s automatically added to all Field Configurations — and there’s no easy or quick way to “clear” a Field Configuration to the bare minimum fields.

This Userscript’s meant to help Admins create a new “Empty” Field Configuration that they may further copy, add the required fields for each Project and assign to each respectively.

New Custom Fields will continue to be automatically included into every existing Field Configuration. Admins will need to keep up with this continuous house-keeping, but the kick-off (ie. hiding all already created custom fields) is something this Userscript helps with.

Scope

The Userscript works on the “ConfigureFieldLayout” admin screen on both Cloud and Server/DC:

Configure screen for a Field Configuration with the JAUS button and the screen that pops-up.

The Userscript tries to prevent it’s execution on Field Configurations currently in use. It does that by looking for certain UI elements in the screen that shows “used by … projects”.

If it finds such elements, it’ll print a message in the console log saying it detected the Field Config’s in use and thus not injected the JAUS button and feature.

In case this checks fails or returns a false-negative, there’s a hard-coded warning to make sure the Field Config’s not currently in use. If happens nonetheless, you can quickly run it again and choose the “Show all fields” option.

Usage

On the Configuration screen for a Field Configuration, if it’s not currently in use by a Project, the JAUS button should show up.

Press the JAUS button on the top or the access key “u” to bring up the Clear Field Configuration screen.

Simple choose if you want to “Hide all fields” or “Show all fields” and press the Commit! button.

The Userscript will hide the button to prevent multiple clicks and fire all necessary requests in the background. As soon as all requests finish, the page will automatically reload and you’ll see all fields have either been hidden or brought back.

The script doesn’t mess with Locked or System fields — it literally scans for only the available links in the page (the same ones you’re seeing as “Hide” and “Show”) and simulates a click on each.

Mechanics

This Userscript doesn’t use the REST API. It fires requests to links present ion the screen.

  1. The script looks for the header elements to inject the JAUS button and also if there’s any text in the page that suggests the Field Config’s in use

    1. If there’s any <em> tag with contents either like "shared" or "used"

    2. If there’s any element with style class “shared-by”

    3. If there’s any element with style class “used-by”

  2. It then scans the page itself for every HTML link element <a> with the id attribute starting with "hide_" or "show_".

  3. It sequentially fires one request to each links fetched.

  4. When the last request finishes, the page automatically reloads.

Repository

JAUS Clear Field Configuration’s source code is hosted in BitBucket:

https://bitbucket.org/jira-admin-userscripts/jaus/src/master/src/jaus-clear-field-configuration.user.js

Notice that to download/install we advise the /raw/ URL.

Authorship

JAUS Bulk Edit Request Participant was designed and implemented by Rodrigo Martinez (Linkedin profile).

It's licensed under Creative Commons Attribution-ShareAlike 4.0 International License.

Support

If you have questions, any problem or need instructions on this Userscript’s usage, please open a request in the JAUS Help Portal.

Please select the Component jaus-clear-field-configuration.

Roadmap

Known issues

Please submit them through JAUS Help Portal!

Jira feature request

Please vote, watch and comment on these feature requests (for both DC and Cloud)!

Even though resolved as “duplicate” or “won’t do”, Atlassian may reconsider it under users' requests!