diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 02d21c10..3a6f708f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,28 +1,49 @@ name: CI GitHub Action -on: "push" -#permissions: -# contents: read +on: push jobs: test: runs-on: ubuntu-latest + services: + selenium: + image: selenium/standalone-chrome + ports: + - 4444:4444 + steps: - uses: actions/checkout@v3 + - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # change this to (see https://github.com/ruby/setup-ruby#versioning): uses: ruby/setup-ruby@v1 with: - bundler-cache: true # runs 'bundle install' and caches installed gems automatically + ruby-version: '3.3.3' # or your preferred Ruby version + bundler-cache: true + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y xvfb libnss3-dev + gem install bundler + bundle install + - name: Run rubocop run: | bundle exec rubocop + - name: Run tests - run: bundle exec rake + env: + DISPLAY: :99.0 + run: | + Xvfb :99 -ac & + bundle exec rspec + - name: Coveralls uses: coverallsapp/github-action@v2 + - name: Brakeman linter run: bundle exec brakeman --no-exit-on-warn --no-exit-on-error + - name: 'Run Bundler Audit' run: bundle exec bundler-audit + diff --git a/app/assets/javascripts/filtermanagement.js b/app/assets/javascripts/filtermanagement.js new file mode 100644 index 00000000..fa499f03 --- /dev/null +++ b/app/assets/javascripts/filtermanagement.js @@ -0,0 +1,17 @@ +// Specific to software_records.html.erb +function clearFilters() { + document.getElementById("vendor-record-filter").style.display = "none"; + document.getElementById("software-type-filter").style.display = "none"; + var loaded = window.location.host; + window.location = "software_records"; +} + +function handleRadio(myRadio) { + if(myRadio.value === "vendor_records") { + document.getElementById("vendor-record-filter").style.display = "block"; + document.getElementById("software-type-filter").style.display = "none"; + } else { + document.getElementById("vendor-record-filter").style.display = "none"; + document.getElementById("software-type-filter").style.display = "block"; + } +} diff --git a/app/assets/javascripts/inputsanitization.js b/app/assets/javascripts/inputsanitization.js new file mode 100644 index 00000000..3cb7bc43 --- /dev/null +++ b/app/assets/javascripts/inputsanitization.js @@ -0,0 +1,4 @@ +var createdbyfield = document.getElementsByClassName('regex-createdby')[0]; +createdbyfield.onkeyup = function() { + createdbyfield.value = createdbyfield.value.replace(/[^a-zA-Z0-9 ]/, ''); +} diff --git a/app/assets/javascripts/multivalueinputs.js b/app/assets/javascripts/multivalueinputs.js new file mode 100644 index 00000000..7a671b29 --- /dev/null +++ b/app/assets/javascripts/multivalueinputs.js @@ -0,0 +1,78 @@ +window.onload = function() { + window.counts = { + + developers: window.counts?.developers || 1, + tech_leads: window.counts?.tech_leads || 1, + departments: window.counts?.departments || 1, + product_owners: window.counts?.product_owners || 1, + admin_users: window.counts?.admin_users || 1 + + }; +}; + +function add(name, value) { + var count = window.counts[name]++; + var elementId = name + count; + var inputId = "software_record_" + name + "_" + count; + + var element = document.createElement("div"); + element.className = "input-group mt-2"; + element.id = elementId; + + var inputElement = document.createElement("input"); + inputElement.type = "text"; + inputElement.required = true; + inputElement.name = "software_record[" + name + "][]"; + inputElement.id = inputId; // Ensure unique ID for each input element + inputElement.className = "form-control"; + if (value != "") { + inputElement.value = value; + } + element.appendChild(inputElement); + + var inputGroupAppend = document.createElement("div"); + inputGroupAppend.className = "input-group-append btnRemove"; + element.appendChild(inputGroupAppend); + + var spanElement = document.createElement("span"); + spanElement.className = "input-group-text"; + inputGroupAppend.appendChild(spanElement); + + var removeButton = document.createElement("i"); + removeButton.className = "fas fa-minus remove"; + removeButton.innerHTML = " Delete"; + spanElement.appendChild(removeButton); + + // Update the onclick handler to directly remove the parent element + inputGroupAppend.onclick = function() { + element.remove(); + }; + + var valued = "multiple_" + name; + var multiValued = document.getElementById(valued); + multiValued.appendChild(element); +} + +document.getElementById("btnAddProductOwners").onclick = function() { + add("product_owners", ""); +}; + +document.getElementById("btnAddAdminUsers").onclick = function() { + add("admin_users", ""); +}; + +document.getElementById("btnAddDepartments").onclick = function() { + add("departments", ""); +}; + +document.getElementById("btnAddDevelopers").onclick = function() { + add("developers", ""); +}; + +document.getElementById("btnAddTechLeads").onclick = function() { + add("tech_leads", ""); +}; + +function remove(id) { + document.getElementById(id).remove(); +} diff --git a/app/assets/javascripts/navigation.js b/app/assets/javascripts/navigation.js new file mode 100644 index 00000000..777f8df1 --- /dev/null +++ b/app/assets/javascripts/navigation.js @@ -0,0 +1,11 @@ +function openNav() { + document.getElementById("mySidenav").style.visibility = "visible"; + document.getElementById("mySidenav").style.width = "250px"; + document.getElementById("main").style.marginLeft = "250px"; +} + +function closeNav() { + document.getElementById("mySidenav").style.visibility = "hidden"; + document.getElementById("mySidenav").style.width = "0"; + document.getElementById("main").style.marginLeft = "0"; +} diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index bbec0fdd..dbc2b4cb 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,138 +6,33 @@ <%= csp_meta_tag %> <%= favicon_link_tag asset_path('favicon.ico'), :rel => 'icon', :type => 'image/x-icon' %> - + - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> -
- <%= render 'shared/dashboard_menu' %> -