I'm trying to use this documentation in order to build a plugin to auto accept an inbound call. What I also want is the ability to turn auto answer on/off by a certain worker attribute. Here's what I have so far in my init(flex, manager) method :
if(manager.workerClient.attributes.[attribute name].includes('[attribute name')) {
manager.workerClient.on('reservationCreated', reservation => {
if (reservation.task.attributes.autoAnswer === 'true') {
flex.Actions.invokeAction('AcceptTask', {sid: reservation.sid});
flex.Actions.invokeAction('SelectTask', {sid: reservation.sid});
}
});
}
I've read through the documentation on accessing worker attributes and think I'm fine with getting the attribute name. However, I'm unsure of the auto answer portion.
Twilio developer evangelist here.
Your code looks correct, I have a similar example that I've used before here.
After discussing with you in the comments, if you set the plugins url to an empty string or null, then Flex will make an API request to look for plugins that it should load at flex.twilio.com/plugins, which only comprises of plugins that you have deployed. You should either set the url to your local /plugins to load the local version. Or you should deploy your plugin so that it can be loaded from flex.twilio.com/plugins in your environment.
Related
I am working on a Custom UI Dashboard Gadget using the forge documentation here. The documentation refers to the context.extension.entryPoint. I can retrieve and see the context, and context.extension in the values returned by view.getContext() but there is no entryPoint key in the returned object.
How should I determine whether the dashboard is in edit mode so that I can configure my gadget?
Relevant code is.
import { view } from '#forge/bridge';
const context = await view.getContext()
console.info(JSON.stringify(context))
The Atlassian documentation says "With a Custom UI, you can define the same resource for viewing and editing your dashboard gadget" and then goes on to describe the code I posted above for retrieving the context. I have been unable to use the same component for configuring the dashboard because there is no 'edit' information in the context. The only solution I have managed to find is to create a separate component for configuring the dashboard and thus specifying the below manifest, which points at a separate component for editing.
jira:dashboardGadget:
...
resource: dashboard-quality
resolver:
function: resolver
edit:
resource: dashboard-quality-edit
This seems to work and it isn't much additional effort, so I am going to accept this as an answer to my own Q, even though it doesn't really solve it based on my original intent.
I was curious if anyone knows how to set permissions (add/remove groups) to variable groups via the REST API. I know there is the security namespace, however it requires a resource guid and I am not sure how to get that for a specific variable group?
You want security namespace "Library" ( you need to convert it to proper namespace_id ) and with token "Library/$project_id/VariableGroup/$variable_group_id"
POST https://dev.azure.com/{organization}/_apis/accesscontrollists/{securityNamespaceId}?api-version=5.1
For ACL management REST API see https://learn.microsoft.com/en-us/rest/api/azure/devops/security/access%20control%20lists/set%20access%20control%20lists?view=azure-devops-rest-5.1
Example request:
"value": [
{
"inheritPermissions": true,
"token": "Library/$project_id/VariableGroup/$variable_group_id",
"acesDictionary": {
"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-1204400969-2402986413-2179408616-0-0-0-0-1": {
"descriptor": "Microsoft.TeamFoundation.Identity;S-1-9-1551374245-1204400969-2402986413-2179408616-0-0-0-0-1",
"allow": 31,
"deny": 0
}
}
}
]
Warning1 - At the moment the Microsoft doc on that topic is quite incomplete ( see, for example my comment on github issue asking for clarification of variables groups authentication mechanism ).
Warning2 - Be careful with ACL changing requests for ALL variable groups in project ( e.g. token=Library/$project_id/ ), because you might end up with removing permissions from all users on your Ado project and it's could be hard to change it back.
I am afraid it is not possible to set variable groups permission via api.
There is only group id we can get from variable group api below, no resource id in the response.
https://dev.azure.com/{organization}/{project}/_apis/distributedtask/variablegroups?api-version=5.1-preview.1
When i tried fetching the http request trace with F12 chrome. There is a value at the end of request url looks like the source id. And it is the project id combined with the variable group id. Donot know if this is resource guid you were looking for.
https://dev.azure.com//_apis/securityroles/scopes/distributedtask.variablegroup/roleassignments/resources/39e13f04-cb4e-4fa8-b2f1-0ee8f4fc82c5%241
I managed to reverse engineer who to do this. If anyone is curious on how it works feel free to talk a look at the powershell library for Azure DevOps I have put together -- https://github.com/ravensorb/Posh-AzureDevOps
I am writing a web application that has a front facing website and then an admin console. I would like to be able to have a setting that when set to true means that a holding or maintenance page is displayed on the front end website.
My routes configuration is currently in a yaml file and is read on on each request. But now I want it to be clever enough to know whether it is in maintenance mode or not and if it is to direct all routes to one specific page. Or it could change the routes so that there is only one.
I have thought that this could be done with different files being loaded based on the setting but then means that all routes are static and cannot be retrieved from a database for example. Additionally I have had problems reading from the database during the setup phase of the request. I configured the system to read from the DB as service but this does not appear to be usable at the setup phase, have i got this wrong?
Any pointers gratefully recieved.
Russell
I often use maintenance page with Silex:
At the same place I define $app['debug'] = true; I also define an other variable $app['maintenance'] = true; that I use for various check.
Among them I define a maintenance page as following:
$app->before(function (Request $request, Application $app) {
if($app['maintenance']){
$subRequest = Request::create('/maintenance', 'GET');
return $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
});
$app->get('/maintenance', function () use ($app) {
// Here you can return your maintenance page
return $app->render('maintenance.twig');
});
Then when I turn on the maintenance variable, every request is redirected to the maintenance route.
As you can see I don't use any yaml configuration file in my app, but the idea is the same with them.
We are working on transitioning to Zephyr for JIRA from HP QC/QTP; but a tiny wiggle has presented itself:
When creating a new issue from a test run; the tester has to manually enter version info for the new defect, which on its own is fine, but it's an additional step, and on occasion forgotten.
What we would like then, is for the field "Affects Version/s" to be automatically filled based on either the state of the project, or the sepcific values set in fields in the test.
How can this be achieved?
Allright. You can add custom javascript to JIRA by going to JIRA Administration -> System -> User Interface -> Announcement Banner.
The easiest way is to add a tag linking to your javascript file (wherever it is, must be available to all users. Preferably on the same server as your JIRA installation or a public domain).
Example:
<script type="text/javascript" src="http://YOUR_JIRA_SERVER/includes/custom/javascript/custom.js"></script>
If you add it like above, go into your JIRA installation into the atlassian-jira/includes/ folder and add a folder called custom within which you add another folder called javascript and create a file called custom.js.
In that file, add the following code:
AJS.$(document).ready(function()
{
AJS.$(document.body).on('change', '#issuetype-field', function()
{
var issuetype = AJS.$(this).val();
if(issuetype === "Test") //Might want to change this!
{
AJS.$("#fixVersions").val(17403); //Might want to change this!
}
});
});
This will add an eventlistener to the issuetype-field input found in the create modal window in JIRA. When it changes (which it automatically does on load, then on every user select) it check its value to see if it's Test and if so changes the fixVersion input to a whatever you want to set it to (change this to match your own preferences).
Using jQuery with jira is a bit tricky, you need to use the AJS object to access the jQuery object (more information here: https://docs.atlassian.com/aui/latest/docs/applicationHeader.html).
The two parts you need to change are the actual names and values of your issuetype and your fix version (use firebug or your browsers equivalent to get this).
I've tried this and it worked well! Good luck!
I'm currently running a fairly out-of-the-box JIRA setup that is live and being used.
Now I'm at a point where I would like a custom field in each bug that will display the total amount of times and issue/bug has been reopened.
There is a plugin (https://answers.atlassian.com/questions/19665/how-to-count-based-on-status-jira) that does something similar, however, I am looking for a solution that doesn't require purchasing a third-party plugin (OPS doesn't like plugins).
I've searched forums high and low and was unable to even find a good starting point. Your help is always appreciated. Thanks in advance!
EDIT: Current JIRA version: 5.2
Create a custom field for counting the times an issue was opened, and set it's default value to one. Then use the Behaviours Plugin to add validation script to the transitions you wish to count. In the validation script, increment the custom field and return true. should be something like:
FormField formComponent = getFieldById(fieldChanged)
FormField formUserField = getFieldByName("UserFieldA"
formUserField.setFormValue(Integer.valueOf(formUserField.getFormValue()) + 1)
If you're having trouble coding that have a look here or ask here.
An easier way would be to attack a post-function to the re-open transition using
Jira Scripting Suite and use it to increment the field, but it doesn't support Jira 5.2 yet.
If you don't want to use any plugins, you can use Webhooks attached to the re-open workflow transition that will post to an URL , which in turn, will connect back using the REST API and increment that field.
A Custom field holds some information (metric, counter, misc. info, etc.) but it is not logic by itself. So the problem here is that in order to increment a (custom) field you will have to have some logic doing that. So you're left with three options:
Use the plugin you're talking about
Custom-build a plugin for this
Use a custom-built external application utilizing the REST API that polls for changes on issues and when it detects "Reopenings" and increments the custom field's value.
Manually assign this field (not really an option)
So at the end there aren't that many options that do not require resouces - development or purchasing some plugin. Usually it's best to buy a plugin because you're also buying support with that. However beware that if the plugin is not developed by Atlassian there is the possibility that it may not support future JIRA versions or it may not be compatible right after a new JIRA version release.
My solution is to add the post-function to the 'Reopen' transition with the following code (it assumes you have Script Runner plugin installed and enabled; also you have to add custom field 'Reopen count' to the corresponding view screen):
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def componentManager = ComponentManager.getInstance()
def customFieldManager = componentManager.getCustomFieldManager()
def reopenCount = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Reopen count'}
def changeHolder = new DefaultIssueChangeHolder();
def reopenCountValue = issue.getCustomFieldValue(reopenCount)
if(reopenCountValue == null) reopenCountValue = 0.0d
reopenCount.updateValue(
null,
issue,
new ModifiedValue(
reopenCountValue,
++reopenCountValue
),
changeHolder
);