-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12811 from mvdbeek/show_tool_source_in_tool_form
Display tool source in tool form
- Loading branch information
Showing
19 changed files
with
202 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<template> | ||
<ToolSourceProvider :id="toolId" v-slot="{ result, loading, error }"> | ||
<loading-span v-if="loading" message="Waiting on tool source" /> | ||
<alert v-else-if="error" :message="error" variant="error" /> | ||
<prism v-else :language="result.language" :code="result.source" :plugins="['normalize-whitespace']"></prism> | ||
</ToolSourceProvider> | ||
</template> | ||
<script> | ||
import Alert from "components/Alert"; | ||
import LoadingSpan from "components/LoadingSpan"; | ||
import { ToolSourceProvider } from "components/providers/ToolSourceProvider"; | ||
import Prism from "vue-prismjs"; | ||
import "prismjs/themes/prism.css"; | ||
import "prismjs/plugins/normalize-whitespace/prism-normalize-whitespace.js"; | ||
export default { | ||
components: { | ||
Alert, | ||
LoadingSpan, | ||
Prism, | ||
ToolSourceProvider, | ||
}, | ||
props: { | ||
toolId: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template> | ||
<CurrentUser v-slot="{ user }"> | ||
<ConfigProvider v-slot="{ config }"> | ||
<div v-if="config.enable_tool_source_display || (user && user.is_admin)"> | ||
<b-dropdown-item v-b-modal.tool-source-viewer | ||
><span class="fa fa-eye" /><span v-localize>View Tool source</span> | ||
</b-dropdown-item> | ||
<b-modal | ||
id="tool-source-viewer" | ||
:title="`Tool Source for ${toolId}`" | ||
size="lg" | ||
ok-only | ||
ok-title="Close" | ||
> | ||
<ToolSource :tool-id="toolId" /> | ||
</b-modal> | ||
</div> | ||
</ConfigProvider> | ||
</CurrentUser> | ||
</template> | ||
<script> | ||
import ConfigProvider from "components/providers/ConfigProvider"; | ||
import CurrentUser from "components/providers/CurrentUser"; | ||
import ToolSource from "components/Tool/ToolSource"; | ||
export default { | ||
components: { | ||
ConfigProvider, | ||
CurrentUser, | ||
ToolSource, | ||
}, | ||
props: { | ||
toolId: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import axios from "axios"; | ||
import { getAppRoot } from "onload/loadConfig"; | ||
import { SingleQueryProvider } from "components/providers/SingleQueryProvider"; | ||
import { rethrowSimple } from "utils/simple-error"; | ||
import beautify from "xml-beautifier"; | ||
|
||
async function toolSource({ id }) { | ||
const url = `${getAppRoot()}api/tools/${id}/raw_tool_source`; | ||
try { | ||
const { data, headers } = await axios.get(url); | ||
const result = {}; | ||
result.language = headers.language; | ||
if (headers.language === "xml") { | ||
result.source = beautify(data); | ||
} else { | ||
result.source = data; | ||
} | ||
return result; | ||
} catch (e) { | ||
rethrowSimple(e); | ||
} | ||
} | ||
|
||
export const ToolSourceProvider = SingleQueryProvider(toolSource); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2729,6 +2729,14 @@ babel-preset-jest@^27.2.0: | |
babel-plugin-jest-hoist "^27.2.0" | ||
babel-preset-current-node-syntax "^1.0.0" | ||
|
||
babel-runtime@^6.26.0: | ||
version "6.26.0" | ||
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" | ||
integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= | ||
dependencies: | ||
core-js "^2.4.0" | ||
regenerator-runtime "^0.11.0" | ||
|
||
[email protected]: | ||
version "3.0.0-canary-5" | ||
resolved "https://registry.yarnpkg.com/babel-walk/-/babel-walk-3.0.0-canary-5.tgz#f66ecd7298357aee44955f235a6ef54219104b11" | ||
|
@@ -3831,6 +3839,11 @@ core-js-pure@^3.0.0: | |
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.18.3.tgz#7eed77dcce1445ab68fd68715856633e2fb3b90c" | ||
integrity sha512-qfskyO/KjtbYn09bn1IPkuhHl5PlJ6IzJ9s9sraJ1EqcuGyLGKzhSM1cY0zgyL9hx42eulQLZ6WaeK5ycJCkqw== | ||
|
||
core-js@^2.4.0: | ||
version "2.6.12" | ||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" | ||
integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== | ||
|
||
core-js@^3.19.1: | ||
version "3.19.1" | ||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.19.1.tgz#f6f173cae23e73a7d88fa23b6e9da329276c6641" | ||
|
@@ -10070,7 +10083,7 @@ pretty@^2.0.0: | |
extend-shallow "^2.0.1" | ||
js-beautify "^1.6.12" | ||
|
||
prismjs@^1.17.1, prismjs@^1.23.0: | ||
prismjs@^1.17.1, prismjs@^1.23.0, prismjs@^1.6.0: | ||
version "1.25.0" | ||
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.25.0.tgz#6f822df1bdad965734b310b315a23315cf999756" | ||
integrity sha512-WCjJHl1KEWbnkQom1+SzftbtXMKQoezOCYs5rECqMN+jP+apI7ftoflyqigqzopSO3hMhTEb0mFClA8lkolgEg== | ||
|
@@ -10736,6 +10749,11 @@ regenerate@^1.4.0, regenerate@^1.4.2: | |
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" | ||
integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== | ||
|
||
regenerator-runtime@^0.11.0: | ||
version "0.11.1" | ||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" | ||
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== | ||
|
||
regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.7, regenerator-runtime@^0.13.9: | ||
version "0.13.9" | ||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" | ||
|
@@ -10867,7 +10885,7 @@ repeat-element@^1.1.2: | |
resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.4.tgz#be681520847ab58c7568ac75fbfad28ed42d39e9" | ||
integrity sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ== | ||
|
||
repeat-string@^1.0.0, repeat-string@^1.6.1: | ||
repeat-string@1.6.1, repeat-string@^1.0.0, repeat-string@^1.6.1: | ||
version "1.6.1" | ||
resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" | ||
integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= | ||
|
@@ -12933,6 +12951,13 @@ vue-observe-visibility@^1.0.0: | |
resolved "https://registry.yarnpkg.com/vue-observe-visibility/-/vue-observe-visibility-1.0.0.tgz#17cf1b2caf74022f0f3c95371468ddf2b9573152" | ||
integrity sha512-s5TFh3s3h3Mhd3jaz3zGzkVHKHnc/0C/gNr30olO99+yw2hl3WBhK3ng3/f9OF+qkW4+l7GkmwfAzDAcY3lCFg== | ||
|
||
vue-prismjs@^1.2.0: | ||
version "1.2.0" | ||
resolved "https://registry.yarnpkg.com/vue-prismjs/-/vue-prismjs-1.2.0.tgz#b137f5ed958685ce1fd55ca6b068289f3359b8b7" | ||
integrity sha512-1mICbMknMiKw4mfM1AU7vkFT3VX4Cq8ySyDU7IBr9tYW1fzxIPkfLoERkRMbQLBc+J74K3FIiuuZ+WfBjO3SCQ== | ||
dependencies: | ||
prismjs "^1.6.0" | ||
|
||
vue-router@^3.5.2: | ||
version "3.5.2" | ||
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-3.5.2.tgz#5f55e3f251970e36c3e8d88a7cd2d67a350ade5c" | ||
|
@@ -13544,6 +13569,13 @@ ws@~7.4.2: | |
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" | ||
integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== | ||
|
||
xml-beautifier@^0.5.0: | ||
version "0.5.0" | ||
resolved "https://registry.yarnpkg.com/xml-beautifier/-/xml-beautifier-0.5.0.tgz#476fd7118b972c2ec5863babca6812934d34bb56" | ||
integrity sha512-QG/qiHeolHUd1tAtM+5zHxTzDprb8qvhmIYUYV1E9QK/jTFlrAa1Mz7QQqJPeqc3uuFAGzTOhjvbdx2hOP6bHw== | ||
dependencies: | ||
repeat-string "1.6.1" | ||
|
||
xml-name-validator@^3.0.0: | ||
version "3.0.0" | ||
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.