FEATURE: Add export poll button (PR #8370)


You’ve signed the CLA, xfalcox. Thank you! This pull request is ready for review.

          disabled: poll.voters === 0,
          poll_name: attrs.poll.name,

be sure to configure prettier, this should (and other places of your code) with double quotes.

      pom.setAttribute("download", "poll.csv");

maybe we should have poll-${topicId}-${postId}.csv or something like that

what does pom means here ?

do we need explicit check on true here ?

    if (isStaff && dataExplorerEnabled && poll.voters > 0) {
    }).then(csvContent => {

Yeah, the data explorer can be either missing (plugin not installed) or false (plugin disabled)

good idea!

renamed, that was just lazy copy & paste :stuck_out_tongue:

so it will work for a if anyways:

if (false) // not called if (undefined) // not called

cool, fixed

    if (isStaff && dataExplorerEnabled && poll.voters > 0 && exportQueryID) {

if (0) // not called

still needs prettier, various things are not formatted correctly like these quotes

nitpick, but I guess this could be put in one line, there’s no value for that intermediate property here:

downloadLink.href = URL.createObjectURL(blob);

I was thinking maybe post_number would be better

name and post_id are the primary keys for polls, so this will guarantee unique named files.