Can I use Javascript in haml?

Hello:

I’m trying to modify the source code of gitlab/app/views/dashboard/projects/index.html.haml.

I want to tell my other API server (a Flask API server) that a new user registered and logged in successfully.The Flask API server then generates a compressed package of tool files for this user to download. However, it takes about 5 minutes to generate the tool file. Therefore, I need to display a Loading icon on the welcome page, and ask the API server in the background every minute if the file is generated, and replace the Loading icon with a download link of the file if so.

The welcome page for downloading the tool will look something like this:

I commented out the project related code in the gitlab/app/views/dashboard/projects/index.html.haml to always render the zero_authorized_projects

# gitlab/app/views/dashboard/projects/index.html.haml

- @hide_top_links = true

= content_for :meta_tags do
  = auto_discovery_link_tag(:atom, dashboard_projects_url(rss_url_options), title: "All activity")

= render_dashboard_ultimate_trial(current_user)

- page_title    _("Projects")
- header_title  _("Projects"), dashboard_projects_path

-# = render "projects/last_push"
-# - if show_projects?(@projects, params)
-#   = render 'dashboard/projects_head'
-#   = render 'nav' unless Feature.enabled?(:project_list_filter_bar)
-#   = render 'projects'
-# - else
-#   = render "zero_authorized_projects"

= render "zero_authorized_projects"

Then I commented out the blank state welcome related code in gitlab/app/views/dashboard/projects/_zero_authorized_projects.html.haml to render my download UI

# gitlab/app/views/dashboard/projects/_zero_authorized_projects.html.haml

.blank-state-parent-container
  .section-container.section-welcome{ class: "#{ 'section-admin-welcome' if current_user.admin? }" }
    .container.section-body
      .row
        .blank-state-welcome.w-100
          %h2.blank-state-welcome-title{ data: { qa_selector: 'welcome_title_content' } }
            = _('Welcome to Gitlab Cloud')

        = render "tool_download"

        -# - if current_user.admin?
        -#   = render "blank_state_admin_welcome"
        -# - else
        -#   = render "blank_state_welcome"

My tool_download script at gitlab/app/views/dashboard/projects/_tool_download.html.haml:

# gitlab/app/views/dashboard/projects/_tool_download.html.haml

.blank-state-row
  .blank-state
    .blank-state-icon
      = custom_icon("add_new_project", size: 50)
    .blank-state-body
      %h3.blank-state-title
        Download IDE for Windows
      %p.blank-state-text
        %a{ href: '#', target: 'blank' } Download Link

  .blank-state
    .blank-state-icon
      = custom_icon("add_new_project", size: 50)
    .blank-state-body
      %h3.blank-state-title
        Download Tools for Windows
      %p.blank-state-text
        %a{ href: '#', target: 'blank' } Download Link

  .blank-state
    .blank-state-icon
      = custom_icon("add_new_project", size: 50)
    .blank-state-body
      %h3.blank-state-title
        Download IDE for Linux
      %p.blank-state-text
        %a{ href: '#', target: 'blank' } Download Link
  
  .blank-state
    .blank-state-icon
      = custom_icon("add_new_project", size: 50)
    .blank-state-body
      %h3.blank-state-title
        Download Tools for Linux
      %p.blank-state-text
        %a{ href: '#', target: 'blank' } Download Link

Now I need to add the Loading icon and logic of asking the API server in the background every minute if the file is generated.

I read the document about Working with JavaScript in Rails and tried to add a snippet of javascript code into the gitlab/app/views/dashboard/projects/index.html.haml:

# gitlab/app/views/dashboard/projects/index.html.haml

- @hide_top_links = true

= content_for :meta_tags do
  = auto_discovery_link_tag(:atom, dashboard_projects_url(rss_url_options), title: "All activity")

= render_dashboard_ultimate_trial(current_user)

- page_title    _("Projects")
- header_title  _("Projects"), dashboard_projects_path

-# = render "projects/last_push"
-# - if show_projects?(@projects, params)
-#   = render 'dashboard/projects_head'
-#   = render 'nav' unless Feature.enabled?(:project_list_filter_bar)
-#   = render 'projects'
-# - else
-#   = render "zero_authorized_projects"

= render "zero_authorized_projects"

:javascript
  alert('test content')

It does write the script tag into the HTML code of the page, but it looks like the JS code in the tag is not being executed :cry:

I also wonder where should I add the logic for the query.

Any suggestions? Really appreciate.