Add customizable plugin display names and weights (#8459)
* feat: add customizable plugin display names and weights - Add weight field to JobTypeCapability proto message - Modify ListKnownJobTypes() to return JobTypeInfo with display names and weights - Modify ListPluginJobTypes() to return JobTypeInfo instead of string - Sort plugins by weight (descending) then alphabetically - Update admin API to return enriched job type metadata - Update plugin UI template to display names instead of IDs - Consolidate API by reusing existing function names instead of suffixed variants * perf: optimize plugin job type capability lookup and add null-safe parsing - Pre-calculate job type capabilities in a map to reduce O(n*m) nested loops to O(n+m) lookup time in ListKnownJobTypes() - Add parseJobTypeItem() helper function for null-safe job type item parsing - Refactor plugin.templ to use parseJobTypeItem() in all job type access points (hasJobType, applyInitialNavigation, ensureActiveNavigation, renderTopTabs) - Deterministic capability resolution by using first worker's capability * templ * refactor: use parseJobTypeItem helper consistently in plugin.templ Replace duplicated job type extraction logic at line 1296-1298 with parseJobTypeItem() helper function for consistency and maintainability. * improve: prefer richer capability metadata and add null-safety checks - Improve capability selection in ListKnownJobTypes() to prefer capabilities with non-empty DisplayName and higher Weight across all workers instead of first-wins approach. Handles mixed-version clusters better. - Add defensive null checks in renderJobTypeSummary() to safely access parseJobTypeItem() result before property access - Ensures malformed or missing entries won't break the rendering pipeline * fix: preserve existing DisplayName when merging capabilities Fix capability merge logic to respect existing DisplayName values: - If existing has DisplayName but candidate doesn't, preserve existing - If existing doesn't have DisplayName but candidate does, use candidate - Only use Weight comparison if DisplayName status is equal - Prevents higher-weight capabilities with empty DisplayName from overriding capabilities with non-empty DisplayName
This commit is contained in:
@@ -1209,6 +1209,7 @@ type JobTypeCapability struct {
|
||||
MaxExecutionConcurrency int32 `protobuf:"varint,5,opt,name=max_execution_concurrency,json=maxExecutionConcurrency,proto3" json:"max_execution_concurrency,omitempty"`
|
||||
DisplayName string `protobuf:"bytes,6,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
|
||||
Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"`
|
||||
Weight int32 `protobuf:"varint,8,opt,name=weight,proto3" json:"weight,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -1292,6 +1293,13 @@ func (x *JobTypeCapability) GetDescription() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *JobTypeCapability) GetWeight() int32 {
|
||||
if x != nil {
|
||||
return x.Weight
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type RequestConfigSchema struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
JobType string `protobuf:"bytes,1,opt,name=job_type,json=jobType,proto3" json:"job_type,omitempty"`
|
||||
@@ -3948,7 +3956,7 @@ const file_plugin_proto_rawDesc = "" +
|
||||
"\bjob_type\x18\x03 \x01(\tR\ajobType\x12&\n" +
|
||||
"\x05state\x18\x04 \x01(\x0e2\x10.plugin.JobStateR\x05state\x12)\n" +
|
||||
"\x10progress_percent\x18\x05 \x01(\x01R\x0fprogressPercent\x12\x14\n" +
|
||||
"\x05stage\x18\x06 \x01(\tR\x05stage\"\xab\x02\n" +
|
||||
"\x05stage\x18\x06 \x01(\tR\x05stage\"\xc3\x02\n" +
|
||||
"\x11JobTypeCapability\x12\x19\n" +
|
||||
"\bjob_type\x18\x01 \x01(\tR\ajobType\x12\x1d\n" +
|
||||
"\n" +
|
||||
@@ -3958,7 +3966,8 @@ const file_plugin_proto_rawDesc = "" +
|
||||
"\x19max_detection_concurrency\x18\x04 \x01(\x05R\x17maxDetectionConcurrency\x12:\n" +
|
||||
"\x19max_execution_concurrency\x18\x05 \x01(\x05R\x17maxExecutionConcurrency\x12!\n" +
|
||||
"\fdisplay_name\x18\x06 \x01(\tR\vdisplayName\x12 \n" +
|
||||
"\vdescription\x18\a \x01(\tR\vdescription\"U\n" +
|
||||
"\vdescription\x18\a \x01(\tR\vdescription\x12\x16\n" +
|
||||
"\x06weight\x18\b \x01(\x05R\x06weight\"U\n" +
|
||||
"\x13RequestConfigSchema\x12\x19\n" +
|
||||
"\bjob_type\x18\x01 \x01(\tR\ajobType\x12#\n" +
|
||||
"\rforce_refresh\x18\x02 \x01(\bR\fforceRefresh\"\xda\x01\n" +
|
||||
|
||||
Reference in New Issue
Block a user