Skip to content

Commit

Permalink
Added sample validation action
Browse files Browse the repository at this point in the history
Added sample validation action
  • Loading branch information
PaoloPia authored Jan 17, 2024
2 parents c1c0d23 + 96eedc0 commit e77f00a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/validate-sample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: External validation

on:
pull_request:
branches:
- "main"

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Validate
uses: pnp/pnp-sample-validation@main
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
13 changes: 6 additions & 7 deletions samples/BotPowered-BasicAce-CollectFeedback/FeedbackBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public FeedbackBot(IConfiguration configuration)
{
Parameters = new Dictionary<string, object>()
{
{"viewToNavigateTo", OkFeedbackCardView_ID},
{"dateTimeFeedback", DateTime.Now.ToString()}
{"viewToNavigateTo", OkFeedbackCardView_ID}
}
}
}
Expand Down Expand Up @@ -212,17 +211,17 @@ protected override Task<BaseHandleActionResponse> OnSharePointTaskHandleActionAs

string viewToNavigateTo = actionParameters["data"]["viewToNavigateTo"].ToString();
var feedbackValue = actionParameters["data"]["feedbackValue"].ToString();
var dateTimeFeedback = DateTime.Parse(actionParameters["data"]["dateTimeFeedback"]?.ToString() ?? DateTime.MinValue.ToString());
var dateTimeFeedback = DateTime.Now;

var nextCard = cardViews[viewToNavigateTo];

// Configure title and description of task
var originalText = ((nextCard.CardViewParameters.Header.ToList())[0] as CardTextComponent).Text;
originalText = originalText.Replace("<feedback>", feedbackValue).Replace("<dateTimeFeedback>", dateTimeFeedback.ToString());
((nextCard.CardViewParameters.Header.ToList())[0] as CardTextComponent).Text = originalText;
var textPattern = "Here is your feedback '<feedback>' collected on '<dateTimeFeedback>'";
textPattern = textPattern.Replace("<feedback>", feedbackValue).Replace("<dateTimeFeedback>", dateTimeFeedback.ToString());
((nextCard.CardViewParameters.Header.ToList())[0] as CardTextComponent).Text = textPattern;

// Set the response for the action
response.RenderArguments = cardViews[viewToNavigateTo];
response.RenderArguments = nextCard;

Trace.Write("\n\n\nFinished handling action.\n\n\n");
return Task.FromResult<BaseHandleActionResponse>(response);
Expand Down

0 comments on commit e77f00a

Please sign in to comment.