Skip to content

Align license compliance `deny` classification outcome with user expectations - Prevent MR from being mergable in UI - Slow Merge request button update

Implementation Plan

Meeting video

https://youtu.be/HRl5QYX1ids

Solution

  • Disable inline editing of license policies by removing the "Allow/Deny" buttons within the modal that appears when clicking the license policy.

License Policies

Screen_Shot_2020-07-21_at_8.06.15_AM

  • Maintainer/Owners can still edit license policies by clicking the "Manage Licenses" button to edit license policies in the "License Compliance" page. (note that this page doesn't use the modal)

Code Overview

Modal is opened in ee/app/assets/javascripts/vue_shared/license_compliance/components/license_issue_body.vue by calling setLicenseinModal

Action setLicenseinModal is in ee/app/assets/javascripts/vue_shared/license_compliance/store/actions.js

Mutation is in ee/app/assets/javascripts/vue_shared/license_compliance/store/mutations.js and sets currentLicenseInModal to the current license.

<set-license-approval-modal/> lives in ee/app/assets/javascripts/vue_shared/license_compliance/mr_widget_license_report.vue and relies on the currentLicnseInModal and canManageLicenses state.

canManageLicenses is passed from the server via a html data attribute

Code Changes

Because the modal is used in two places, (the Pipelines/Licenses tab and the MR widget), we need the button actions to be hidden only in the MR widget context. Right now we don't distinguish this when we invoke the actions and mutations needed to show the modal.

  • Add a new state field called isMRWidget
  • Add a new action/mutation to the LICENSE_MANAGEMENT vuex module called setisMRWidget
  • In ee/app/assets/javascripts/vue_shared/license_compliance/mr_widget_license_report.vue call this.setIsMRWidget and set it to true
  • In ee/app/assets/javascripts/vue_shared/license_compliance/components/set_approval_status_modal.vue add
...mapState(LICENSE_MANAGEMENT, ['isMrWidget']
  • In ee/app/assets/javascripts/vue_shared/license_compliance/components/set_approval_status_modal.vue update the canApprove and canBlacklist computed props to
    canApprove() {
      return (
        !this.isMrWidget &&
        this.canManageLicenses &&
        this.currentLicenseInModal &&
        this.currentLicenseInModal.approvalStatus !== LICENSE_APPROVAL_STATUS.ALLOWED
      );
    },
    canBlacklist() {
      return (
        !this.isMrWidget &&
        this.canManageLicenses &&
        this.currentLicenseInModal &&
        this.currentLicenseInModal.approvalStatus !== LICENSE_APPROVAL_STATUS.DENIED
      );
    },

Unit Test changes

  • Add untit tests for setisMrWidget action and mutation
  • Update unit tests for ee/spec/frontend/vue_shared/license_compliance/components/set_approval_status_modal_spec.jsregarding the show/hide logic for the "approve/deny" buttons.

Bug

This is a bugfix follow up issue for #196845 (closed). All prior work should be behind a feature flag license_compliance_denies_mr

Edge Cases that cause broken UI:

It appears that the mergeable logic is updated viaRefreshLicenseComplianceChecksWorker.perform_async(project.id) worker that runs on license policy creation, update. Don't think it happens for delete? Need to double check.

The broken edge cases occur when we make policy changes and there is a 2-60 second delay from when the job updates. Incorrect state appears as follows:

Screen_Shot_2020-07-20_at_7.16.51_PM

Screen_Shot_2020-07-20_at_7.17.10_PM

Video of proper behavior but with significant delays 40-60 seconds. Video was not sped up to maintain the perception of delay.

https://youtu.be/8QoopR96IYM

Edited by Neil McCorrison