Skip to content

Commit

Permalink
allow to refresh all contexts (#809)
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish committed Dec 20, 2024
1 parent 719d72c commit 8ef5bdb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@ import javax.swing.tree.TreePath
class RefreshAction : StructureTreeAction(IActiveContext::class.java) {

override fun actionPerformed(event: AnActionEvent?, path: TreePath?, selectedNode: Any?) {
val descriptor = selectedNode?.getDescriptor() ?: return
run("Refreshing $selectedNode...", true,
val descriptor = selectedNode?.getDescriptor()
run("Refreshing ${ selectedNode ?: "all contexts" }...", true,
Progressive {
val telemetry = TelemetryService.instance.action("refresh resource")
val telemetry = if (descriptor != null) {
TelemetryService.instance.action("refresh resource")
} else {
TelemetryService.instance.action("refresh all contexts")
}
try {
descriptor.invalidate()
sendTelemetry(getResourceKind(descriptor.element), telemetry)
if (descriptor != null) {
descriptor.invalidate()
sendTelemetry(getResourceKind(descriptor.element), telemetry)
} else {
getResourceModel()?.invalidate();
telemetry.send()
}
} catch (e: Exception) {
logger<RefreshAction>().warn("Could not refresh $descriptor resources.", e)
telemetry.error(e).send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface IResourceModel {
fun watch(definition: CustomResourceDefinition)
fun stopWatch(kind: ResourceKind<out HasMetadata>)
fun stopWatch(definition: CustomResourceDefinition)
fun invalidate()
fun invalidate(element: Any?)
fun delete(resources: List<HasMetadata>, force: Boolean)
fun canWatchLog(resource: HasMetadata): Boolean
Expand Down Expand Up @@ -171,7 +172,7 @@ open class ResourceModel : IResourceModel {
modelChange.removeListener(listener)
}

private fun invalidate() {
override fun invalidate() {
logger<ResourceModel>().debug("Invalidating all contexts.")
allContexts.refresh()
}
Expand Down

0 comments on commit 8ef5bdb

Please sign in to comment.