Skip to content

Commit

Permalink
Add copy outputs to outputs table (#2194)
Browse files Browse the repository at this point in the history
- Remove redundant actions, allow cell based selection
- fixes #2179
  • Loading branch information
hunterwerlla authored Nov 12, 2020
1 parent 1f5060f commit 679faa8
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 233 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "feature",
"description" : "Add copy actions to CloudFormation outputs (#2179)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class DynamicTableView<T>(private vararg val fields: Field<T>) : View {
private val table = JBTable(model).apply {
autoCreateRowSorter = true
autoscrolls = true
cellSelectionEnabled = true
setShowColumns(true)
setPaintBusy(true)
fields.forEach { field ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@ internal class EventsTableImpl : EventsTable, Disposable {
) { e -> e.resourceStatusReason() ?: "" }
).apply { component.border = IdeBorderFactory.createBorder(SideBorder.BOTTOM) }

init {
table.addMouseListener(ResourceActionPopup(this::selected))
}

private fun selected(): SelectedResource? {
val row = table.selectedRow() ?: return null
val logicalId = row[logicalId] as? String ?: return null
val physicalId = row[physicalId] as? String
return SelectedResource(logicalId, physicalId?.takeIf { it.isNotBlank() })
}

override val component: JComponent = table.component

override fun showBusyIcon() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ class ResourceTableView : View, ResourceListener, Disposable {
) { it.resourceStatusReason() }
).apply { component.border = JBUI.Borders.empty() }

init {
table.addMouseListener(ResourceActionPopup(this::selected))
}

private fun selected(): SelectedResource? {
val row = table.selectedRow() ?: return null
val logicalId = row[logicalId] as? String ?: return null
val physicalId = row[physicalId] as? String
return SelectedResource(logicalId, physicalId?.takeIf { it.isNotBlank() })
}

override val component: JComponent = table.component

override fun updatedResources(resources: List<StackResource>) = table.updateItems(resources, clearExisting = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,10 @@ internal class TreeViewImpl(private val project: Project, stackName: String) : T
val rootNode = DefaultMutableTreeNode(descriptor, true)
model = DefaultTreeModel(rootNode)
tree = Tree(model).also { it.name = "$stackName.tree" }
tree.addMouseListener(ResourceActionPopup(this::selected))
tree.setPaintBusy(true)
component = JBScrollPane(tree)
}

private fun selected(): SelectedResource? {
val node = tree.selectionPaths ?: return null
if (node.size != 1) {
return null
}
val selectedNode = (node.first().lastPathComponent as? DefaultMutableTreeNode)?.userObject as? StackNodeDescriptor ?: return null
return SelectedResource(selectedNode.name, selectedNode.physicalId)
}

override fun getIconsAndUpdaters() =
(StreamEx.of(rootNode.children()) + listOf(rootNode))
.filterIsInstance<DefaultMutableTreeNode>()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.actionSystem.Separator
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.ui.PopupHandler
Expand All @@ -23,7 +22,6 @@ import software.aws.toolkits.jetbrains.services.cloudwatch.logs.CloudWatchLogsAc
import software.aws.toolkits.jetbrains.services.cloudwatch.logs.LogStreamEntry
import software.aws.toolkits.jetbrains.services.cloudwatch.logs.LogStreamFilterActor
import software.aws.toolkits.jetbrains.services.cloudwatch.logs.LogStreamListActor
import software.aws.toolkits.jetbrains.services.cloudwatch.logs.actions.CopyFromTableAction
import software.aws.toolkits.jetbrains.services.cloudwatch.logs.actions.ShowLogsAroundActionGroup
import software.aws.toolkits.jetbrains.utils.ApplicationThreadPoolScope
import software.aws.toolkits.jetbrains.utils.ui.bottomReached
Expand Down Expand Up @@ -103,8 +101,6 @@ class LogStreamTable(

private fun addActionsToTable() {
val actionGroup = DefaultActionGroup().apply {
add(CopyFromTableAction(logsTable))
add(Separator())
add(ShowLogsAroundActionGroup(project, logGroup, logStream, logsTable))
}
PopupHandler.installPopupHandler(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@ cloudformation.stack.logical_id=Logical ID
cloudformation.stack.logical_id.copy=Copy Logical ID
cloudformation.stack.outputs.description=Description
cloudformation.stack.outputs.export=Export Name
cloudformation.stack.outputs.export.copy=Copy Export Name
cloudformation.stack.outputs.key=Key
cloudformation.stack.outputs.key.copy=Copy Key
cloudformation.stack.outputs.value=Value
cloudformation.stack.outputs.value.copy=Copy Value
cloudformation.stack.physical_id=Physical ID
cloudformation.stack.physical_id.copy=Copy Physical ID
cloudformation.stack.reason=Status Reason
Expand All @@ -196,7 +199,6 @@ cloudformation.yaml.invalid_root_type=Template does not start with a mapping: {0
cloudformation.yaml.too_many_documents=There should only be 1 YAML document per file: {0}
cloudformation.yaml.too_many_files=Found {0} YAML files but only expected 1
cloudwatch.logs.compare.start.end.date=Start date must be before end date
cloudwatch.logs.copy_action=Copy {0, choice, 1#message|2#messages}
cloudwatch.logs.delete_log_group=Delete Log Group
cloudwatch.logs.download=Download Log Stream
cloudwatch.logs.download.description=Select a folder to save the Log Stream to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ package software.aws.toolkits.jetbrains.uitests.tests

import com.intellij.remoterobot.stepsProcessing.log
import com.intellij.remoterobot.stepsProcessing.step
import com.intellij.remoterobot.utils.attempt
import org.assertj.core.api.AbstractStringAssert
import org.assertj.core.api.Assertions.assertThat
import org.assertj.swing.core.MouseButton
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
Expand All @@ -25,8 +22,6 @@ import software.aws.toolkits.jetbrains.uitests.fixtures.findAndClick
import software.aws.toolkits.jetbrains.uitests.fixtures.idea
import software.aws.toolkits.jetbrains.uitests.fixtures.pressOk
import software.aws.toolkits.jetbrains.uitests.fixtures.welcomeFrame
import java.awt.Toolkit
import java.awt.datatransfer.DataFlavor
import java.nio.file.Path
import java.nio.file.Paths
import java.time.Duration
Expand All @@ -39,7 +34,6 @@ class CloudFormationBrowserTest {
private val stack = "uitest-${UUID.randomUUID()}"

private val cloudFormation = "CloudFormation"
private val queueName = "SQSQueue"
private val deleteStackText = "Delete Stack..."

@TempDir
Expand Down Expand Up @@ -72,49 +66,13 @@ class CloudFormationBrowserTest {
doubleClickExplorer(cloudFormation, stack)
}
}
step("Can copy IDs from tree") {
val queueNode = step("Finding '$queueName [CREATE_COMPLETE]'") {
attempt(5) {
findText("$queueName [CREATE_COMPLETE]")
}
}
step("Logical ID") {
queueNode.click(MouseButton.RIGHT_BUTTON)
findAndClick("//div[@text='Copy Logical ID']")

assertClipboardContents().isEqualTo(queueName)
}
step("Physical ID") {
queueNode.click(MouseButton.RIGHT_BUTTON)
findAndClick("//div[@text='Copy Physical ID']")
assertClipboardContents().startsWith("https").contains(queueName)
}
}
step("Check events") {
clickOn("Events")
val resource = step("Assert that there are two CREATE_COMPLETE events shown") {
step("Assert that there are two CREATE_COMPLETE events shown") {
val createComplete = findAllText("CREATE_COMPLETE")
assertThat(createComplete).hasSize(2)
createComplete.first()
}

step("Check Logical ID action") {
resource.click(MouseButton.RIGHT_BUTTON)
findAndClick("//div[@text='Copy Logical ID']")
assertClipboardContents().satisfiesAnyOf(
{ assertThat(it).isEqualTo(queueName) },
{ assertThat(it).startsWith("uitest") }
)
}
step("Check Physical ID action") {
resource.click(MouseButton.RIGHT_BUTTON)
findAndClick("//div[@text='Copy Physical ID']")

assertClipboardContents().satisfiesAnyOf(
{ assertThat(it).startsWith("https").contains(queueName) },
{ assertThat(it).startsWith("arn") }
)
}
}
step("Check outputs") {
clickOn("Outputs")
Expand All @@ -124,24 +82,11 @@ class CloudFormationBrowserTest {
}
step("Check resources") {
clickOn("Resources")
val resource = step("Assert that the stack resource is there") {
step("Assert that the stack resource is there") {
val createComplete = findAllText("CREATE_COMPLETE")
assertThat(createComplete).hasSize(1)
createComplete.first()
}

step("Check Logical ID action") {
resource.click(MouseButton.RIGHT_BUTTON)
findAndClick("//div[@text='Copy Logical ID']")

assertClipboardContents().isEqualTo(queueName)
}
step("Check Physical ID action") {
resource.click(MouseButton.RIGHT_BUTTON)
findAndClick("//div[@text='Copy Physical ID']")

assertClipboardContents().startsWith("https").contains(queueName)
}
}
step("Delete stack $stack") {
showAwsExplorer()
Expand Down Expand Up @@ -176,9 +121,6 @@ class CloudFormationBrowserTest {
}
}

private fun assertClipboardContents(): AbstractStringAssert<*> =
assertThat(Toolkit.getDefaultToolkit().systemClipboard.getData(DataFlavor.stringFlavor) as String)

private fun IdeaFrame.clickOn(tab: String) {
findAndClick("//div[@accessiblename='$tab' and @class='JLabel' and @text='$tab']")
}
Expand Down

0 comments on commit 679faa8

Please sign in to comment.