I've spent a long time going over documentation but have not been able to get a confirmation view to show up before running my action. What are the steps to adding a confirmation view to a capsule?
I have an action called Evaluate and an address input that i automatically pull from the user's profile. I would like to confirm this address before running Evaluate in case the user wants to use a different address
Here's what I have done:
1) import viv.common in capsule.bxb:
import (viv.common) {
as (common)
version (3.30.0)
}
2) add confirm/by statement to Evaluate action:
confirm {
by (common.Confirmation)
}
3) add a confirmation view that will match on the evaluate action:
confirmation-view {
match: common.Confirmation {
confirming {Evaluate (action) }
}
mode (PositiveEmphasis)
message ("Is this the correct address?")
render {
layout {
section {
content{
paragraph {
style (Title_XS)
value {
template (
"#{value(action.address)}}?"
)
}
}
}
}
}
}
confirm-options {
label ("Yes")
}
abort-options {
label ("Try another Address")
on-abort {
intent {
goal: InputAddress
}
}
}
}
I was hoping that would do it, but I think i'm missing something else. Any ideas?
I've been looking into this and my guess is that it doesn't work with a Calculation action (or Constructor action), you need a transaction action, based on the following sentence in the confirmation-view documentation:
There must be a corresponding transactional action asking for confirmation with the confirm key.
Take a look at the sample capsule capsule-sample-bank. Committing a transfer prompts the user for Confirmation. They use two confirmation prompts:
The first one is done before to prompt the user to confirm before evaluating CreateTransfer and results in a Transfer model. This is the one you're looking for.
The second one is done using transaction-support and a match { Transfer } to match the output of the first one and starts a new intent on CommitTransfer upon user confirmation.
The relevant files in the folder structure are:
+-- models/
| +-- actions/
| | +-- CreateTransfer.model.bxb
+-- resources/
| +-- base/
| | +-- dialog/
| | | +-- CreateTransfer_Confirmation.dialog.bxb
| | | +-- Transfer_Result.dialog.bxb
| | +-- transactions/
| | | +-- precommit.transaction.bxb
| | +-- views/
| | | +-- CreateTransfer_Confirmation.view.bxb
Maybe someone from the Bixby developer team can expand this answer. I don't see a reason why it shouldn't be possible to use a confirmation on a Calculation action.
Related
I am starting using jest to test simple component SysError.js in my React Native 0.68 app. SysError displays some message on screen when it is called (routed by react-navigation 6.x) and the jest test is to check if the page view does contain the message. The #testing-library/react-native used is v11.0.0
Here is the SysError.js:
import React, {useState, useContext, Component} from 'react';
import {Platform, Button, Text, TouchableOpacity, View } from 'react-native';
export default function SysError({route}) { //<<== routed by react-navigation
const message = route.params.message ? JSON.stringify(route.params.message) : "";
return (
<View styles={{marginTop: 32, paddingHorizontal: 24, alignItems:"center", alignContent:"center"}}>
<Text>{route.params.message} System NOT available right now. Try again later</Text>
</View>
)
};
Here is the jest test:
import React from 'react';
import { render, cleanup } from "#testing-library/react-native";
import SysError from './SysError';
afterEach(cleanup);
it ('describe SysError page view with a message', () => {
const route = {params: {message:"nnmm"}};
const {toJSON, getByText} = render(<SysError route={route} />);
const foundmsg = getByText("System NOT available right now"); //<<==this throws error
expect(toJSON()).toMatchSnapshot();
expect(foundmsg.props.children).toEqual("System NOT available right now");
})
To my surprise, there is an error:
FAIL src/components/app/SysError.test.js
● describe SysError page view with a message
Unable to find an element with text: System NOT available right now
9 | const route = {params: {message:"nnmm"}};
10 | const {toJSON, getByText} = render(<SysError route={route} />);
> 11 | const foundmsg = getByText("System NOT available right now");
| ^
12 | expect(toJSON()).toMatchSnapshot();
13 | expect(foundmsg.props.children).toEqual("System NOT available right now");
14 |
at Object.getByText (src/components/app/SysError.test.js:11:22)
However if the test code is changed to reg expression:
const foundmsg = getByText(/System NOT available right now/i);
Then the error becomes:
expect(received).toEqual(expected) // deep equality
Expected: "System NOT available right now"
Received: ["nnmm", " System NOT available right now. Try again later"]
11 | const foundmsg = getByText(/System NOT available right now/i);
12 | expect(toJSON()).toMatchSnapshot();
> 13 | expect(foundmsg.props.children).toEqual("System NOT available right now");
Is there way re-code expect(foundmsg.props.children).toEqual("System NOT available right now"); and make it pass? I tried toEqual(/System NOT available right now/i) and it didn't work.
As the react-native testing library shows in the documentation examples the getByText query, if provided a string, will look for the exact match.
That's the reason why on your first attempt the query is unable to find the element. As you found out, you can also provide a regex to look for partial match so on your second attempt the query is capable of finding the element.
Now that you have the element:
<Text>{route.params.message} System NOT available right now. Try again later</Text>
You can see that it actually has two children: One for the dynamic part that prints the route.params.message and the other one for the static part.
You can check both values in your test with:
expect(foundmsg.props.children).toEqual(["nnmm", "System NOT available right now"]);
If you only want to check that the static part is present you could also do:
expect(foundmsg.props.children).toContain("System NOT available right now");
Please let me know how to include metadata in the insight query for QnAMaker logs
something as this, here the meatadata field comes empty
| where url endswith "generateAnswer"
| project timestamp, id, url, resultCode, duration, performanceBucket
| parse kind = regex url with *"(?i)knowledgebases/"KbId"/generateAnswer"
| join kind= inner (
traces | extend id = operation_ParentId
) on id
| extend question = tostring(customDimensions['traces'])
| extend answer = tostring(customDimensions['Answer'])
| extend score = tostring(customDimensions['Score'])
| extend metadata = tostring(customDimensions['qnaMakerOptions'])
| project answer,['metadata']
To help the other community Members posting the suggestion from the GITHUB where the issue is discussed.
If you look within the customEvents table, you can find an event with the name 'QnAMessage' - this is an event that is produced by the underlying QnAMaker service within the Bot Framework SDK, and produces more information beyond the trace event you identified. The corresponding class is Microsoft.Bot.Builder.AI.QnA.QnAMaker, located within the microsoft/botbuilder-dotnet repo.
With this class, it is possible to supply custom event properties and metrics that can be captured within Application Insights. To do this, the recommendation would be to create a custom dialog that inherits from QnAMakerDialog, and add logic as appropriate to supply any additional telemetry properties and metrics.
There is a sample custom dialog, the MultiplyDialog in the samples repo that shows how to write a custom dialog.
The general approach you would take is to write a custom dialog extending from QnAMakerDialog, probably overriding the protected getQnaMakerClient(...) method to return a custom QnAMaker implementation that includes the metadata you care about in the on QnaResults method. Below is some pseudocode that illustrates the example
class CustomQnAMakerDialog extends QnAMakerDialog {
async getQnaMakerClient(dialogContext) {
const client = await super.getQnAMakerClient(dialogContext);
const onQnaResults = client.onQnaResults.bind(client);
client.onQnaResults = (qnaResults, turnContext, properties = {}, metrics = {}) => {
properties = { ...properties, custom: 'property' };
metrics = { ...metrics, custom: 1.0 };
return onQnaResults(qnaResults, turnContext, properties, metrics);
}
}
}
For more information about logging metadata into app insights for qna maker service refer the below git hub link with complete code
QnaMakerDialog & QnaMaker
My DB schema has business objects in it, for example those three tables that describe patient/doctor relations:
doctor doctor_patient_relation patient
--------- ----------------------- ----------
id <- doctor_id |--> id
name: str patient_id --------------| name: str
is_main_doctor: bool
The rules are:
You can patient:view and patient:edit if you are a doctor with a doctor/patient relation with that patient.
You can patient:delete if you are the main doctor for that patient.
For my RBAC system, should I just hard code the rules in my system? Like so for example (pseudo code):
route.DELETE('/patient/delete/:patientId', (req) => {
if (req.user.hasRole('doctor') && req.user.patientRelations.where(patientRel.patient_id == req.patientId)) {
return true; // can perform action
}
else return false; // unauthorized
});
OR should I make RBAC tables for permissions and keep a parallel record of permissions for each doctor/patient relations? And do that with all the other business objects in my DB? Example:
permission_name | resource_id | user_id
--------------- | --------------- | -------------
patient:delete | <id of patient> | <id of doctor>
It just seems to me that keeping parallel records of permissions will explose the number of rows in my DB and will be hard to maintain. However, it also provides an abstraction between the permissions module and the business modules.
I've been pondering about this for a few days now and I'm quite unsure which is the best option. What do you think?
I am using cucumber JVM, I have below scenario outline:
Scenario Outline:
Given a user login in as <username>
When the user login
Then welcome message shoule show to <username>
Examples:
| username |
| alice |
| bob |
| steve |
I want to access the data from scenario hooks, for example:
#Before
public void beforeScenario() {
List<String> headers = examples.getHeaders()
String header = headers.filter(header -> header.equals("username")).findFirst().get();
example.get(header); // should be alice, bob, steve in sequence
}
Above code for hooks is not working, is it possible to access the Example table from hooks? if it's possible, how to do it?
I'm creating a relatively simple grammar which parses and breaks down strings into sub-components. A simplified version of the grammer is shown below
stmt: location type ID;
location :
location_A
| location_B
| location_C
;
location_A : 'LOCATION TOKEN 1';
location_B : 'LOCATION TOKEN 2';
location_C : 'LOCATION TOKEN 3';
Within my listener I have implemented ExitLocation to catch the token matched by this rule, but I would also like to extract the rule name of the sub-rule with which the token was matched (i.e. location_A/B/C).
Is it possible, from within the listener, to determine which sub-rule matched the token found?
Best Wishes
Dines Madsen
Alternative labels will help you here. Decorate all alternatives with a unique #name:
location
: location_A #alt1
| location_B #alt2
| location_C #alt3
;
and in your listener and visitor, there are enter- and exit-methods created for these labels (exitAlt1(...), exitAlt2(...), ...).
Another option is to assign the result of the subrules (which are by default rule contexts) to a local variable and check that in your listeners:
location:
value = location_A
| value = location_B
| value = location_C
;
LocationContext.value then contains the matched location rule.
I ended up simply grabbing the context name from the child node. As this information is only required for debugging purposes, it should be enough:
public override void ExitLocations([NotNull] TagParserParser.LocationsContext context)
{
try
{
this.myLocationToken = context.GetText();
this.myLocationRule = context.children[0].GetType().Name;
}
catch (Exception)
{
}
}
Thank you for your suggestions.