Skip to content

Commit

Permalink
add logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MBergCap committed Nov 24, 2023
1 parent 17fc6ff commit 29ddc19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
16 changes: 13 additions & 3 deletions controllers/ctltools.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const sanitizeToolInputs = (id, body) => {
body.openNewTab = !!body.openNewTab;
body.isHidden = !!body.isHidden;
body.config.baseUrl = body.config.baseUrl || undefined;
body.restrictToContexts = Array.isArray(body.restrictToContexts) ? body.restrictToContexts : [].concat(body.restrictToContexts || []);

switch (body.config.type) {
case 'oauth2':
Expand Down Expand Up @@ -217,6 +218,12 @@ const showTools = (req, res) => {
}
}

let toolContextTypes;

api(req, {version: 'v3'}).get('/tools/context-types').then((contextTypes) => {
toolContextTypes = contextTypes.data;
})

api(req, { version: 'v3' }).get('/tools/external-tools', {
qs: {
name: req.query.q,
Expand Down Expand Up @@ -265,7 +272,8 @@ const showTools = (req, res) => {
toolTypes,
customParameterTypes,
customParameterScopes,
customParameterLocations
customParameterLocations,
toolContextTypes
});
}).catch(() => {
res.render('ctltools/ctltools', {
Expand All @@ -281,7 +289,8 @@ const showTools = (req, res) => {
toolTypes,
customParameterTypes,
customParameterScopes,
customParameterLocations
customParameterLocations,
toolContextTypes
});
}).catch(() => {
res.render('ctltools/ctltools', {
Expand All @@ -297,7 +306,8 @@ const showTools = (req, res) => {
toolTypes,
customParameterTypes,
customParameterScopes,
customParameterLocations
customParameterLocations,
toolContextTypes
});
});
};
Expand Down
8 changes: 4 additions & 4 deletions views/ctltools/forms/add-ctl-tool.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
</label>
</div>
<div class="form-group">
<label class="control-label" for="toolRestriction">Nutzung des Tools auf folgende Kontexte beschränken:</label>
<select id="toolRestriction" name="toolRestriction" multiple>
{{#each toolRestriction}}
<option value="{{this.value}}">{{this.label}}</option>
<label class="control-label" for="restrictToContexts">Nutzung des Tools auf folgende Kontexte beschränken:</label>
<select id="restrictToContexts" name="restrictToContexts" multiple>
{{#each toolContextTypes}}
<option value="{{this}}">{{this}}</option>
{{/each}}
</select>
</div>
Expand Down

0 comments on commit 29ddc19

Please sign in to comment.