Repository: mozilla/send
File: frontend/src/upload.js (JavaScript)

Code before:
            populateFileList(file);
          }
        } else if (xhr.status === 404) {
          storage.remove(id);
          if (storage.numFiles === 0) {
            toggleHeader();
          }
        }
      }
    };
    xhr.open('get', '/exists/' + id, true);
    xhr.send();
  }

  //update file table with current files in storage
  function populateFileList(file) {
    const row = document.createElement('tr');
    const name = document.createElement('td');
    const link = document.createElement('td');
    const $copyIcon = $('<img>', {
      src: '/resources/copy-16.svg',
      class: 'icon-copy',
      'data-l10n-id': 'copyUrlHover'
    });
    if (!allowedCopy()) {
      $copyIcon.addClass('disabled');
    }
    const expiry = document.createElement('td');
    const del = document.createElement('td');
    const $delIcon = $('<img>', {
      src: '/resources/close-16.svg',
      class: 'icon-delete',
      'data-l10n-id': 'deleteButtonHover'
    });
    const popupDiv = document.createElement('div');
    const $popupText = $('<div>', { class: 'popuptext' });
    const cellText = document.createTextNode(file.name);

    const url = file.url.trim() + `#${file.secretKey}`.trim();

    $('#link').attr('value', url);
    $('#copy-text').attr('data-l10n-args', '{"filename": "' + file.name + '"}');
    $('#copy-text').attr('data-l10n-id', 'copyUrlFormLabelWithName');
    $popupText.attr('tabindex', '-1');

    name.appendChild(cellText);

    // create delete button

    const delSpan = document.createElement('span');
    $(delSpan).addClass('icon-cancel-1');

Review comment (suggestion):
since 'disabled' is really common, can we add a 'disabled' attribute instead? Then check the css with :disabled
we already have a rule for `#copy-btn:disabled` that can be reused.

Code after:
          if (populate) {
            populateFileList(file);
          }
        } else if (xhr.status === 404) {
          storage.remove(id);
          if (storage.numFiles === 0) {
            toggleHeader();
          }
        }
      }
    };
    xhr.open('get', '/exists/' + id, true);
    xhr.send();
  }

  //update file table with current files in storage
  function populateFileList(file) {
    const row = document.createElement('tr');
    const name = document.createElement('td');
    const link = document.createElement('td');
    const $copyIcon = $('<img>', {
      src: '/resources/copy-16.svg',
      class: 'icon-copy',
      'data-l10n-id': 'copyUrlHover',
      disabled: !allowedCopy()
    });

    const expiry = document.createElement('td');
    const del = document.createElement('td');
    const $delIcon = $('<img>', {
      src: '/resources/close-16.svg',
      class: 'icon-delete',
      'data-l10n-id': 'deleteButtonHover'
    });
    const popupDiv = document.createElement('div');
    const $popupText = $('<div>', { class: 'popuptext' });
    const cellText = document.createTextNode(file.name);

    const url = file.url.trim() + `#${file.secretKey}`.trim();

    $('#link').attr('value', url);
    $('#copy-text').attr('data-l10n-args', '{"filename": "' + file.name + '"}');
    $('#copy-text').attr('data-l10n-id', 'copyUrlFormLabelWithName');
    $popupText.attr('tabindex', '-1');

    name.appendChild(cellText);

    // create delete button

    const delSpan = document.createElement('span');
    $(delSpan).addClass('icon-cancel-1');