Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Messenger does not display message text properly when text list is used. #534

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 192 additions & 0 deletions scripts/_change_state.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
param (
[int]$IssueId,
[string]$oldColumnName,
[string]$newColumnName,
[bool]$doNotCheckOldColumnName = 0,
[string]$repoOwner = "Inxton",
[string]$repoName = "AXOpen",
[string]$projectName = "simatic-ax"
)

gh issue list --assignee "@me" --state "open"
$issues = gh issue list --state "open" --assignee "@me" --json number,title | ConvertFrom-Json
$issueIDs = $issues | ForEach-Object { $_.number }
if (-not $IssueId)
{
$IssueId = Read-Host "Please enter an ID value of the issue"
}

# Fetch project IDs using GraphQL
$projectIds = gh api graphql -f query='
query($repoOwner: String!, $repoName: String!) {
repository(owner: $repoOwner, name: $repoName) {
projectsV2(first: 10) {
nodes {
id
title
}
}
}
}' -f repoOwner=$repoOwner -F repoName=$repoName

$projectId = ($projectIds | ConvertFrom-Json).data.repository.projectsV2.nodes | Where-Object { $_.title -eq $projectName } | Select-Object -ExpandProperty id

$projectOptions = gh api graphql -f query='
query($projectId: ID!) {
node(id: $projectId) {
... on ProjectV2 {
fields(first: 20) {
nodes {
... on ProjectV2SingleSelectField {
id
name
options {
id
name
}
}
}
}
}
}
}' -f projectId=$projectId | ConvertFrom-Json

$projectColumns = $projectOptions.data.node.fields.nodes | Where-Object { $_.name -eq 'Status'}
$projectColumnId =$projectColumns.id

$oldColumn = $projectColumns.options | Where-Object { $_.name -eq $oldColumnName}
if (-not $oldColumn) {
Write-Output "Error: No state '$oldColumnName' defined in project ID $projectId (name: $projectName)."
exit 1
}
$oldColumnId = $oldColumn.id

$newColumn = $projectColumns.options | Where-Object { $_.name -eq $newColumnName}
if (-not $newColumn) {
Write-Output "Error: No state '$newColumnName' defined in project ID $projectId (name: $projectName)."
exit 1
}
$newColumnId = $newColumn.id

Write-Output "Fetching all items from project: $projectId (name: $projectName)."
# Initialize variables
$hasNextPage = $true
$endCursor = $null
$allItems = @()
$pageNumber = 1
$itemsCount = 0

# Loop through pages
while ($hasNextPage) {
Write-Output "Fetching a page #$pageNumber of items..."
# Execute GraphQL query with pagination
$result = gh api graphql -f query='
query($projectId: ID!, $cursor: String) {
node(id: $projectId) {
... on ProjectV2 {
items(first: 100, after: $cursor) {
nodes {
id
fieldValues(first: 10) {
nodes{
... on ProjectV2ItemFieldSingleSelectValue {
name
field {
... on ProjectV2FieldCommon {
name
}
}
}
}
}
content {
... on Issue {
number
}
}
}
pageInfo {
endCursor
hasNextPage
}
}
}
}
}' -F projectId=$projectId -F cursor=$endCursor -F fieldId=$projectColumnId | ConvertFrom-Json

# Append fetched items to $allItems
$allItems += $result.data.node.items.nodes
$pageNumber = $pageNumber + 1
$itemsCount = $itemsCount + $allItems.Count
# Update pagination variables
$endCursor = $result.data.node.items.pageInfo.endCursor
$hasNextPage = $result.data.node.items.pageInfo.hasNextPage
Write-Output "Fetched #$itemsCount items..."
}

# Output all items
Write-Output "Fetched all items: #$itemsCount"

Write-Output "Fetching project cards for issue #$IssueId in the '$oldColumnName' column"
# Find the card associated with the issue
$issueCard = $allItems | Where-Object { $_.content.number -eq $IssueId }
if (-not $issueCard) {
Write-Output "Error: No project card found for issue #$IssueId in project ID $projectId (name: $projectName)."
exit 1
}

# Discover the 'Status' field value
$fieldValues = $issueCard.fieldValues.nodes
$issueCardHasStatusField = 0
$issueCardIsInOldColumnName = ""
foreach ($fieldValue in $fieldValues )
{
if ($fieldValue.field.name -eq "Status")
{
$issueCardHasStatusField = 1
$issueCardIsInOldColumnName = $fieldValue.name
break
}
}

if ($issueCardHasStatusField -eq 0)
{
Write-Output "Error: The issue #$IssueId in project ID $projectId (name: $projectName) does not have defined the 'Status' value."
exit 1
}

if ($issueCardIsInOldColumnName -ne $oldColumnName)
{
if($doNotCheckOldColumnName -eq 0)
{
Write-Output "Error: The issue #$IssueId in project ID $projectId (name: $projectName) cannot be moved from '$oldColumnName' to '$newColumnName' as it is in '$issueCardIsInOldColumnName'."
exit 1
}
Write-Output "Moving issue #$IssueId to '$newColumnName' in project ID $projectId (name: $projectName)."
}
else
{
Write-Output "Moving issue #$IssueId from '$oldColumnName' to '$newColumnName' in project ID $projectId (name: $projectName)."
}


$cardId = $issueCard.id

# Move the issue card to $newColumnName
gh api graphql -f query='
mutation($projectId: ID!, $cardId: ID!, $projectColumnId: ID!, $newColumnId: String!) {
updateProjectV2ItemFieldValue(
input: {
projectId: $projectId
itemId: $cardId
fieldId: $projectColumnId
value: {
singleSelectOptionId: $newColumnId
}
}
) {
projectV2Item {
id
}
}
}' -F projectId=$projectId -F cardId=$cardId -F projectColumnId=$projectColumnId -F newColumnId=$newColumnId
16 changes: 13 additions & 3 deletions scripts/_create_issue_branch.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
param (
[int]$IssueId )
[int]$IssueId ,
[bool]$doNotCheckOldColumnName = 0
)

gh issue list --assignee "@me" --state "open"
$issues = gh issue list --state "open" --assignee "@me" --json number,title | ConvertFrom-Json
Expand All @@ -16,10 +18,11 @@ if ([int]::TryParse($IssueId, [ref]$null))
# Check if any of the open issue IDs assigned to @me is equal to entered value
if ($issueIDs -contains [int]$IssueId)
{
# Get selected issue id and issue title
# Get selected issue id ,issue title and issue label
$selectedIssue = $issues | Where-Object { $_.number -eq [int]$IssueId }
$selectedIssueNumber = $selectedIssue.number
$selectedIssueTitle = $selectedIssue.title
$currentLabels = $selectedIssue.labels | ForEach-Object { $_.name }
# Checkout dev
Write-Output "Checkout to dev"
git checkout dev
Expand All @@ -46,7 +49,14 @@ if ([int]::TryParse($IssueId, [ref]$null))
Write-Output "Sync local and remote branches"
git pull origin $(git branch --show-current)
git push
} else
# Get the current script directory
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
# Construct the full path to _change_stateScriptPath.ps1
$_change_stateScriptPath = Join-Path -Path $scriptDir -ChildPath "_change_state.ps1"
# Call _change_state.ps1 with the parameters IssueId, oldColumnName, newColumnName,doNotCheckOldColumnName, repoOwner, repoName, projectName
& $_change_stateScriptPath -IssueId $issueID -oldColumnName "Ready" -newColumnName "In progress" -doNotCheckOldColumnName $doNotCheckOldColumnName -repoOwner "Inxton" -repoName "AXOpen" -projectName "simatic-ax"
}
else
{
Write-Output "Unable to checkout to dev"
Write-Output "Commit your local changes, sync your local 'dev' branch with th remote and start this script again."
Expand Down
8 changes: 4 additions & 4 deletions scripts/create_new_issue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ if ($issue -match ".*/(\d+)$") {
# Get the current script directory
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent

# Construct the full path to SecondScript.ps1
$create_issue_branchScriptPath = Join-Path -Path $scriptDir -ChildPath "_create_issue_branch.ps1"
# Construct the full path to _create_issue_branch.ps1
$_create_issue_branchScriptPath = Join-Path -Path $scriptDir -ChildPath "_create_issue_branch.ps1"

# Call create_issue_branch.ps1 with the parameter IssueId
& $create_issue_branchScriptPath -IssueId $issueID
# Call _create_issue_branch.ps1 with the parameter IssueId and doNotCheckOldColumnName
& $_create_issue_branchScriptPath -IssueId $issueID -doNotCheckOldColumnName 1
} else {
Write-Output "No numeric ID found for this issue."
}
Expand Down
19 changes: 18 additions & 1 deletion scripts/ready_for_review.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ else
{
# Get current branch name
$currentBranch = $(git branch --show-current)
Write-Output "Working tree is clean. Marking '$currentBranch' as ready fore review"
Write-Output "Working tree is clean. Marking '$currentBranch' as ready for review"
# Extract the issue number (assuming "issue-<number>" or "<type>/<number>-description" format)
if ($currentBranch -match "\d+")
{
$issueID = $matches[0]
Write-Output "issueID: $issueID"
# Get the current script directory
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
# Construct the full path to _change_stateScriptPath.ps1
$_change_stateScriptPath = Join-Path -Path $scriptDir -ChildPath "_change_state.ps1"
# Call _change_state.ps1 with the parameters IssueId, oldColumnName, newColumnName,doNotCheckOldColumnName, repoOwner, repoName, projectName
& $_change_stateScriptPath -IssueId $issueID -oldColumnName "In progress" -newColumnName "In review" -doNotCheckOldColumnName $doNotCheckOldColumnName 0 -repoOwner "Inxton" -repoName "AXOpen" -projectName "simatic-ax"
}
else
{
Write-Output "No issue number found in the branch name. Unable to move the issue to 'In review'"
}

# Get the list of pull requests
$pullRequests = gh pr list --state open --json number,headRefName | ConvertFrom-Json
if (-not $pullRequests) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,58 @@
<div class="container text-left">
<div class="row">
<div class="col">
<div class="card ps-2">
<label>RenderableContentControl Context="@Entry.Plc.AxoMessengers" Presentation="Command-Control"</label>
@* <div class="card ps-2">
<label>RenderableContentControl Context="@Entry.Plc.AxoMessengers" Presentation="Command-Control"</label>
<RenderableContentControl Context="@Entry.Plc.AxoMessengers" Presentation="Command-Control" Class="ps-2" />
</div>
*@
<div class="card ps-2">
<label>_messenger1</label>
<div class="card ps-2">
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger1condition" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger1conditionWithCode" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger1code" Presentation="Command-Control" />
<AXOpen.Messaging.Static.AxoMessengerDetailedCommandView Component="@Entry.Plc.AxoMessengers._messenger1" />
</div>
</div>
<div class="card ps-2">
<label>_messenger2</label>
<div class="card ps-2">
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger2condition" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger2code" Presentation="Command-Control" />
<AXOpen.Messaging.Static.AxoMessengerDetailedCommandView Component="@Entry.Plc.AxoMessengers._messenger2" />
</div>
</div>
<div class="card ps-2">
<label>_messenger3</label>
<div class="card ps-2">
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger3condition" Presentation="Command-Control" />
<AXOpen.Messaging.Static.AxoMessengerDetailedCommandView Component="@Entry.Plc.AxoMessengers._messenger3" />
</div>
</div>
<div class="card ps-2">
<label>_messenger4</label>
<div class="card ps-2">
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger4condition" Presentation="Command-Control" />
<AXOpen.Messaging.Static.AxoMessengerDetailedCommandView Component="@Entry.Plc.AxoMessengers._messenger4" />
</div>
</div>
<div class="card ps-2">
<label>_messenger5</label>
<div class="card ps-2">
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_1" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_2" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_3" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_4" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_5" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_6" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_7" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_8" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5condition_9" Presentation="Command-Control" />
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger5callcondition" Presentation="Command-Control" />
<AXOpen.Messaging.Static.AxoMessengerDetailedCommandView Component="@Entry.Plc.AxoMessengers._messenger5" />
</div>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@

public override async void OnComponentChanged()
{
if (observedObjects.Count() == 0
|| !observedObjects.First().Equals(this.Component))
{
observedObjects = new[] { this.Component };
}
// if (observedObjects.Count() == 0
// && !observedObjects.First().Equals(this.Component))
// {
// observedObjects = new[] { this.Component };
// }

MessageProvider = AxoMessageProvider.Create(observedObjects);
await LoadMessages();
base.OnComponentChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public async Task ReadDetails()
p.AcknowledgedBeforeFallen
});

await Messengers?.First()?.GetConnector()?.ReadBatchAsync(r)!;
await Messengers?.FirstOrDefault()?.GetConnector()?.ReadBatchAsync(r)!;
}

public async Task ReadMessageStateAsync()
Expand All @@ -185,8 +185,9 @@ public async Task ReadMessageStateAsync()
{
p.MessengerState,
});


await Messengers?.First()?.GetConnector()?.ReadBatchAsync(r)!;
await Messengers?.FirstOrDefault()?.GetConnector()?.ReadBatchAsync(r)!;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
<label>RenderableContentControl Context="@Entry.Plc.AxoMessengers" Presentation="Command-Control"</label>
<RenderableContentControl Context="@Entry.Plc.AxoMessengers" Presentation="Command-Control" Class="ps-2" />
</div>
<div class="card ps-2">
<label>_messenger1 </label>
<RenderableContentControl Context="@Entry.Plc.AxoMessengers._messenger1" Presentation="Status-Display" Class="ps-2" />
</div>
<div class="card ps-2">
<label>_messenger1 </label>
<AXOpen.Messaging.Static.AxoMessengerView Context="@Entry.Plc.AxoMessengers._messenger1" Class="ps-2" />
</div>
</div>
</div>
</div>
Expand Down
Loading