mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-28 05:55:21 -04:00
plugins: fix plugin browser parentWindow and add similar support
This commit is contained in:
@@ -282,6 +282,11 @@ func browsePlugins() error {
|
|||||||
|
|
||||||
feedback := plugins.FetchFeedback()
|
feedback := plugins.FetchFeedback()
|
||||||
|
|
||||||
|
nameByID := make(map[string]string, len(pluginList))
|
||||||
|
for _, plugin := range pluginList {
|
||||||
|
nameByID[plugin.ID] = plugin.Name
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("\nAvailable Plugins (%d):\n\n", len(pluginList))
|
fmt.Printf("\nAvailable Plugins (%d):\n\n", len(pluginList))
|
||||||
for _, plugin := range pluginList {
|
for _, plugin := range pluginList {
|
||||||
installed, _ := manager.IsInstalled(plugin)
|
installed, _ := manager.IsInstalled(plugin)
|
||||||
@@ -313,6 +318,17 @@ func browsePlugins() error {
|
|||||||
if fb.IssueURL != "" {
|
if fb.IssueURL != "" {
|
||||||
fmt.Printf(" Discuss: %s\n", fb.IssueURL)
|
fmt.Printf(" Discuss: %s\n", fb.IssueURL)
|
||||||
}
|
}
|
||||||
|
if len(fb.Similar) > 0 {
|
||||||
|
names := make([]string, len(fb.Similar))
|
||||||
|
for i, id := range fb.Similar {
|
||||||
|
if name, ok := nameByID[id]; ok {
|
||||||
|
names[i] = name
|
||||||
|
} else {
|
||||||
|
names[i] = id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Printf(" Related: %s\n", strings.Join(names, ", "))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ type Feedback struct {
|
|||||||
Upvotes int
|
Upvotes int
|
||||||
Status []string
|
Status []string
|
||||||
IssueURL string
|
IssueURL string
|
||||||
|
Similar []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchFeedback retrieves community upvotes and moderator status from the directory API.
|
// FetchFeedback retrieves community upvotes and moderator status from the directory API.
|
||||||
@@ -35,6 +36,7 @@ func FetchFeedback() map[string]Feedback {
|
|||||||
Upvotes int `json:"upvotes"`
|
Upvotes int `json:"upvotes"`
|
||||||
Status []string `json:"status"`
|
Status []string `json:"status"`
|
||||||
IssueURL string `json:"issueUrl"`
|
IssueURL string `json:"issueUrl"`
|
||||||
|
Similar []string `json:"similar"`
|
||||||
} `json:"plugins"`
|
} `json:"plugins"`
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&payload); err != nil {
|
if err := json.NewDecoder(resp.Body).Decode(&payload); err != nil {
|
||||||
@@ -43,7 +45,7 @@ func FetchFeedback() map[string]Feedback {
|
|||||||
|
|
||||||
feedback := make(map[string]Feedback, len(payload.Plugins))
|
feedback := make(map[string]Feedback, len(payload.Plugins))
|
||||||
for _, p := range payload.Plugins {
|
for _, p := range payload.Plugins {
|
||||||
feedback[p.ID] = Feedback{Upvotes: p.Upvotes, Status: p.Status, IssueURL: p.IssueURL}
|
feedback[p.ID] = Feedback{Upvotes: p.Upvotes, Status: p.Status, IssueURL: p.IssueURL, Similar: p.Similar}
|
||||||
}
|
}
|
||||||
return feedback
|
return feedback
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ func HandleList(conn net.Conn, req models.Request) {
|
|||||||
info.Upvotes = fb.Upvotes
|
info.Upvotes = fb.Upvotes
|
||||||
info.Status = fb.Status
|
info.Status = fb.Status
|
||||||
info.IssueURL = fb.IssueURL
|
info.IssueURL = fb.IssueURL
|
||||||
|
info.Similar = fb.Similar
|
||||||
result[i] = info
|
result[i] = info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ type PluginInfo struct {
|
|||||||
Upvotes int `json:"upvotes,omitempty"`
|
Upvotes int `json:"upvotes,omitempty"`
|
||||||
Status []string `json:"status,omitempty"`
|
Status []string `json:"status,omitempty"`
|
||||||
IssueURL string `json:"issueUrl,omitempty"`
|
IssueURL string `json:"issueUrl,omitempty"`
|
||||||
|
Similar []string `json:"similar,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SuccessResult struct {
|
type SuccessResult struct {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ FloatingWindow {
|
|||||||
property bool keyboardNavigationActive: false
|
property bool keyboardNavigationActive: false
|
||||||
property bool isLoading: false
|
property bool isLoading: false
|
||||||
property var parentModal: null
|
property var parentModal: null
|
||||||
parentWindow: null
|
parentWindow: parentModal
|
||||||
property bool pendingInstallHandled: false
|
property bool pendingInstallHandled: false
|
||||||
property string typeFilter: ""
|
property string typeFilter: ""
|
||||||
property string categoryFilter: "all"
|
property string categoryFilter: "all"
|
||||||
@@ -126,6 +126,25 @@ FloatingWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function relatedNames(plugin) {
|
||||||
|
if (!plugin || !plugin.similar || plugin.similar.length === 0)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
var names = [];
|
||||||
|
for (var i = 0; i < plugin.similar.length; i++) {
|
||||||
|
var id = plugin.similar[i];
|
||||||
|
var name = id;
|
||||||
|
for (var j = 0; j < allPlugins.length; j++) {
|
||||||
|
if (allPlugins[j].id === id) {
|
||||||
|
name = allPlugins[j].name || id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
names.push(name);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
function comparePluginAuthor(a, b) {
|
function comparePluginAuthor(a, b) {
|
||||||
var authorA = (a.author || "").toLowerCase() || "zzz";
|
var authorA = (a.author || "").toLowerCase() || "zzz";
|
||||||
var authorB = (b.author || "").toLowerCase() || "zzz";
|
var authorB = (b.author || "").toLowerCase() || "zzz";
|
||||||
@@ -1076,6 +1095,15 @@ FloatingWindow {
|
|||||||
propagateComposedEvents: true
|
propagateComposedEvents: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
visible: root.relatedNames(modelData).length > 0
|
||||||
|
text: I18n.tr("Related: %1", "related plugins").arg(root.relatedNames(modelData).join(", "))
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.outline
|
||||||
|
elide: Text.ElideRight
|
||||||
|
width: parent.width
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|||||||
Reference in New Issue
Block a user