const TTYG_ASK_DEFAULT_TITLE = 'guide.step-action.ask-ttyg-agent';
const EXPLORE_SPARQL = 'guide.step_plugin.ask-ttyg-agent.explore-sparql';
/**
* @name ttyg-ask-agent-explore-sparql
* @memberof module:Interactive Guide
*
* @description
* This step focuses on guiding the user to explore the SPARQL query generated by the TTYG agent.
* It highlights the "Open in SPARQL editor" button and provides instructions on how to proceed.
*
* Click on explore SPARQL button<br>
* <img src="resources/guides/ttyg/ttyg-ask-agent-explore-sparql.png" style="height:200px; border: solid; border-width:1px"/><br>
*
* @example
* ```JSON
* {
* "guideBlockName": "ttyg-ask-agent-explore-sparql",
* }
* ```
*/
const step = {
guideBlockName: 'ttyg-ask-agent-explore-sparql',
getSteps: function(options, pluginService) {
const GuideUtils = pluginService.GuideUtils;
const exploreSparqlBtnSelector = GuideUtils.getLastGuideElementSelector('open-in-sparql-editor-btn');
const elementSelector = GuideUtils.getLastGuideElementSelector('chat-item', exploreSparqlBtnSelector);
const translate = pluginService.translate;
const title = options.title ? options.title : translate(this.translationBundle, TTYG_ASK_DEFAULT_TITLE);
return [
{
// If button is not visible for some reason, skip the whole step
guideBlockName: 'info-message',
options: {
url: 'ttyg',
beforeShowPromise: (guide, currentStep) => GuideUtils.waitFor(elementSelector, 1)
.then(() => {
// Using a timeout because the library executes logic to show the step in a then clause which causes current and next steps to show
setTimeout(() => guide.next());
})
.catch(() => {
const stepId = currentStep.id;
// Using a timeout because the library executes logic to show the step in a then clause which causes current and next steps to show
setTimeout(() => guide.show(stepId + 2));
}),
...options
}
},
{
guideBlockName: 'clickable-element',
options: {
title,
content: translate(this.translationBundle, EXPLORE_SPARQL),
class: 'explore-sparql',
disableNextFlow: true,
...options,
url: 'ttyg',
elementSelector
}
}
];
},
translationBundle: {
en: {
[TTYG_ASK_DEFAULT_TITLE]: 'Ask the agent',
[EXPLORE_SPARQL]: 'You can open the query in the SPARQL editor by clicking on \'Open in SPARQL editor\' button. When you are ready, return to the page.'
},
fr: {
[TTYG_ASK_DEFAULT_TITLE]: 'Demander à l\'agent',
[EXPLORE_SPARQL]: 'Vous pouvez ouvrir la requête dans l\'éditeur SPARQL en cliquant sur le bouton \'Ouvrir dans l\'éditeur SPARQL\'. Lorsque vous êtes prêt, retournez à la page'
}
}
};
export function register(registry) {
registry.add('guide.step', step);
}
Source