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 3, 2023
1 parent 566d40a commit 467816d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 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
34 changes: 32 additions & 2 deletions Contents/Resources/web/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,42 @@ <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_icon = document.createElement('i')
archived_alert_icon.className = 'fa-solid fa-exclamation-triangle fa-lg me-2'
archived_alert.appendChild(archived_alert_icon)

let archived_alert_message = document.createElement('span')
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'
alert.setAttribute('role', 'alert')

// alert icon
let alert_icon = document.createElement('i')
// set class later
alert.appendChild(alert_icon)

// alert message
let alert_message = document.createElement('div')
let alert_message = document.createElement('span')
// add the text later
alert.appendChild(alert_message)

Expand Down Expand Up @@ -279,7 +308,8 @@ <h2 class="fw-bolder">{{ _('Plugins') }}</h2>
warning = `${warning} ${emoji.replace_colons(":warning: {{ _('This is not the default branch.') }}")}<br>`
}
if (download['default_branch'] === true && latest_release !== null) {
alert_message.textContent = emoji.replace_colons(":interrobang: {{ _('The default branch is older than the latest release. This plugin may not support installing from branches.') }}")
alert_icon.className = 'fa-solid fa-exclamation-triangle fa-lg me-2'
alert_message.textContent = "{{ _('The default branch (<default_branch>) is older than the latest release. This plugin may not support installing from branches.') }}".replace('<default_branch>', download['name'])
install_section.appendChild(alert)
}
}
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 467816d

Please sign in to comment.