Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
plugins: add archived information
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Apr 2, 2023
1 parent 566d40a commit 6bebae6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
26 changes: 22 additions & 4 deletions Contents/Resources/web/js/item_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ let populate_results = function (plugins_list, container, update_counts = false)

// for PluggerDB plugins
if (plugins_list[plugin]['html_url']) {
// add archived plugin category if the plugin is archived
if (plugins_list[plugin]['archived'] === true && !plugins_list[plugin]['categories'].includes('Archived Plugin')) {
// add to beginning of array
plugins_list[plugin]['categories'].unshift('Archived Plugin')
}

// create a badge for each category
for (let category in plugins_list[plugin]['categories']) {
// if category is not in search_type drop down, add it
Expand Down Expand Up @@ -205,7 +211,7 @@ let populate_results = function (plugins_list, container, update_counts = false)
// increment the count
if (update_counts) {
let count = parseInt(search_options.children[i].children[2].textContent)
search_options.children[i].children[2].textContent = `${count + 1}`
search_options.children[i].children[2].textContent = (count + 1).toString()
}
break
}
Expand Down Expand Up @@ -234,7 +240,7 @@ let populate_results = function (plugins_list, container, update_counts = false)
category_column.appendChild(category_badge)
}
// add a categories edit button using fontawesome icon
// todo - pass categories to the issue form
// todo - pass categories to the issue form... if it's possible
let edit_link = `https://github.com/LizardByte/PluggerDB/issues/new?assignees=&labels=request-plugin&template=plugin.yml&title=${encodeURIComponent('[PLUGIN]: ')}${encodeURIComponent(plugins_list[plugin]['html_url'].replace('https://github.com/', ''))}&github_url=${encodeURIComponent(plugins_list[plugin]['html_url'])}`
let category_column = document.createElement("div")
category_column.className = "col-auto align-self-center"
Expand Down Expand Up @@ -429,6 +435,18 @@ let populate_results = function (plugins_list, container, update_counts = false)
issues_link.appendChild(issues_text)
}

// add archived warning
if (plugins_list[plugin]['archived'] === true) {
let archived_column = document.createElement("div")
archived_column.className = "col-auto align-self-center me-1"
stats_row.appendChild(archived_column)
let archived_icon = document.createElement("i")
archived_icon.className = "fa-solid fa-triangle-exclamation align-middle"
archived_icon.style.color = "#ffb02e"
archived_icon.setAttribute('title', getTranslation('Archived'))
archived_column.appendChild(archived_icon)
}

}
else if (plugins_list[plugin]['installed_data']['type'] === "system") {
// add the system plugin category
Expand All @@ -443,7 +461,7 @@ let populate_results = function (plugins_list, container, update_counts = false)
// increment the count in the search_options drop down
if (update_counts) {
let system_plugin_count = document.getElementById("count_system_plugin")
system_plugin_count.textContent = `${parseInt(system_plugin_count.textContent) + 1}`
system_plugin_count.textContent = (parseInt(system_plugin_count.textContent) + 1).toString()
}

let category_column = document.createElement("div")
Expand Down Expand Up @@ -521,7 +539,7 @@ let populate_results = function (plugins_list, container, update_counts = false)
// increment the count in the search_options drop down
if (update_counts) {
let installed_plugin_count = document.getElementById("count_installed_plugin")
installed_plugin_count.textContent = `${parseInt(installed_plugin_count.textContent) + 1}`
installed_plugin_count.textContent = (parseInt(installed_plugin_count.textContent) + 1).toString()
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions Contents/Resources/web/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,26 @@ <h2 class="fw-bolder">{{ _('Plugins') }}</h2>
success: function (result) {
let plugin = result[github_id]

// archived alert
if (plugin['archived'] === true) {
let archived_alert = document.createElement('div')
archived_alert.className = 'alert alert-danger alert-dismissible fade show'
archived_alert.setAttribute('role', 'alert')

let archived_alert_message = document.createElement('div')
archived_alert_message.innerHTML = `{{ _('This plugin is archived and is no longer being maintained. It is highly unlikely this plugin will function properly.') }}`
archived_alert.appendChild(archived_alert_message)

let archived_alert_close = document.createElement('button')
archived_alert_close.className = 'btn-close'
archived_alert_close.setAttribute('type', 'button')
archived_alert_close.setAttribute('data-bs-dismiss', 'alert')
archived_alert_close.setAttribute('aria-label', "{{ _('Close') }}")
archived_alert.appendChild(archived_alert_close)

install_section.appendChild(archived_alert)
}

// global alert
let alert = document.createElement('div')
alert.className = 'alert alert-warning alert-dismissible fade show'
Expand Down
2 changes: 2 additions & 0 deletions Contents/Resources/web/templates/translations.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
{# General strings #}
{{ _('Clear Results') }}
{{ _('Installed Version:') }}
{{ _('Archived Plugin') }}
{{ _('Installed Plugin') }}
{{ _('System Plugin') }}

{# Tooltips #}
{{ _('Archived') }}
{{ _('Edit Categories') }}
{{ _('Force Update') }}
{{ _('Forks') }}
Expand Down

0 comments on commit 6bebae6

Please sign in to comment.