Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new code block component for Dev UI Code displays #38848

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bom/dev-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<vaadin-router.version>1.7.5</vaadin-router.version>
<lit-state.version>1.7.0</lit-state.version>
<echarts.version>5.4.3</echarts.version>
<wc-codemirror.version>2.1.0</wc-codemirror.version>
<codeblock.version>1.0.10</codeblock.version>
<es-module-shims.version>1.8.2</es-module-shims.version>
<path-to-regexp.version>2.4.0</path-to-regexp.version>

Expand Down Expand Up @@ -262,12 +262,12 @@

<!-- Code editor -->
<dependency>
<groupId>org.mvnpm.at.vanillawc</groupId>
<artifactId>wc-codemirror</artifactId>
<version>${wc-codemirror.version}</version>
<groupId>org.mvnpm.at.mvnpm</groupId>
<artifactId>codeblock</artifactId>
<version>${codeblock.version}</version>
<scope>runtime</scope>
</dependency>

<!-- Polyfill for importmaps -->
<dependency>
<groupId>org.mvnpm</groupId>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/dev-ui.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ image::dev-ui-qui-code-block-v2.png[alt=Dev UI Code Block,role="center"]

[source,javascript]
----
import 'qui-code-block';
import '@quarkus-webcomponents/codeblock';
----

[source,html]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ import { QwcHotReloadElement, html, css} from 'qwc-hot-reload-element';
import { JsonRpc } from 'jsonrpc';
import { columnBodyRenderer } from '@vaadin/grid/lit.js';
import { gridRowDetailsRenderer } from '@vaadin/grid/lit.js';
import { observeState } from 'lit-element-state';
import { themeState } from 'theme-state';
import '@quarkus-webcomponents/codeblock';
import '@vaadin/progress-bar';
import '@vaadin/grid';
import '@vaadin/grid/vaadin-grid-sort-column.js';
import '@vaadin/vertical-layout';
import '@vaadin/tabs';
import '@vaadin/split-layout';
import 'qui-badge';
import 'qui-code-block';
import 'qui-ide-link';
import '@vaadin/button';

/**
* This component shows the Grpc Services
*/
export class QwcGrpcServices extends QwcHotReloadElement {
export class QwcGrpcServices extends observeState(QwcHotReloadElement) {
jsonRpc = new JsonRpc(this);
streamsMap = new Map();

Expand Down Expand Up @@ -214,14 +216,16 @@ export class QwcGrpcServices extends QwcHotReloadElement {
mode='json'
content='${method.prototype}'
value='${method.prototype}'
theme='${themeState.theme.name}'
editable>
</qui-code-block>
</master-content>
<detail-content style="width: 50%;">
<qui-code-block
id='${this._responseId(service.name, method)}'
mode='json'
content='\n\n\n\n'>
content='\n\n\n\n'
theme='${themeState.theme.name}'>
</qui-code-block>
</detail-content>
</vaadin-split-layout>`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import '@vaadin/button';
import '@vaadin/grid';
import { columnBodyRenderer } from '@vaadin/grid/lit.js';
import { notifier } from 'notifier';
import { observeState } from 'lit-element-state';
import { themeState } from 'theme-state';
import '@quarkus-webcomponents/codeblock';

export class HibernateOrmPersistenceUnitsComponent extends LitElement {
export class HibernateOrmPersistenceUnitsComponent extends observeState(LitElement) {

static styles = css`
.full-height {
height: 100%;
}
.ddl-script {
padding: 5px;
}
a.script-heading {
display: block;
float:left;
Expand Down Expand Up @@ -81,7 +81,11 @@ export class HibernateOrmPersistenceUnitsComponent extends LitElement {
</vaadin-button>
</vaadin-horizontal-layout>
</vaadin-details-summary>
<pre class="ddl-script">${pu.createDDL}</pre>
<qui-code-block
mode="sql"
content="${pu.createDDL}"
theme="${themeState.theme.name}">
</qui-code-block>
</vaadin-details>
<vaadin-details>
<vaadin-details-summary slot="summary" theme="filled">
Expand All @@ -96,7 +100,11 @@ export class HibernateOrmPersistenceUnitsComponent extends LitElement {
</vaadin-button>
</vaadin-horizontal-layout>
</vaadin-details-summary>
<pre class="ddl-script">${pu.updateDDL}</pre>
<qui-code-block
mode="sql"
content="${pu.updateDDL}"
theme="${themeState.theme.name}">
</qui-code-block>
</vaadin-details>
<vaadin-details>
<vaadin-details-summary slot="summary" theme="filled">
Expand All @@ -111,13 +119,17 @@ export class HibernateOrmPersistenceUnitsComponent extends LitElement {
</vaadin-button>
</vaadin-horizontal-layout>
</vaadin-details-summary>
<pre class="ddl-script">${pu.dropDDL}</pre>
<qui-code-block
mode="sql"
content="${pu.dropDDL}"
theme="${themeState.theme.name}">
</qui-code-block>
</vaadin-details>`;
}

_copyToClipboard(event, what) {
event.stopPropagation();
var text = event.target.closest("vaadin-details").querySelector(".ddl-script").textContent;
var text = event.target.closest("vaadin-details").querySelector("qui-code-block").value;
var listener = function(ev) {
ev.clipboardData.setData("text/plain", text);
ev.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import { columnBodyRenderer, gridRowDetailsRenderer } from '@vaadin/grid/lit.js'
import '@vaadin/dialog';
import { dialogRenderer } from '@vaadin/dialog/lit.js';
import '@vaadin/button';
import 'qui-code-block';
import { observeState } from 'lit-element-state';
import { themeState } from 'theme-state';
import '@quarkus-webcomponents/codeblock';
import '@vaadin/split-layout';
import './qwc-kafka-add-message.js';

/**
* This component shows the Kafka Messages for a certain topic
*/
export class QwcKafkaMessages extends QwcHotReloadElement {
export class QwcKafkaMessages extends observeState(QwcHotReloadElement) {

static styles = css`
.kafka {
Expand Down Expand Up @@ -171,7 +173,8 @@ export class QwcKafkaMessages extends QwcHotReloadElement {
<div class="code-block">
<qui-code-block
mode='json'
content='${message.value}'>
content='${message.value}'
theme='${themeState.theme.name}'>
</qui-code-block>
</div>
</master-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import '@vaadin/details';
import '@vaadin/tabs';
import '@vaadin/vertical-layout';
import 'qui-badge';
import 'qui-code-block';
import { observeState } from 'lit-element-state';
import { themeState } from 'theme-state';
import '@quarkus-webcomponents/codeblock';

/**
* This component shows the Kafka Streams Topology
*/
export class QwcKafkaStreamsTopology extends QwcHotReloadElement {
export class QwcKafkaStreamsTopology extends observeState(QwcHotReloadElement) {

jsonRpc = new JsonRpc(this);

Expand Down Expand Up @@ -132,15 +134,15 @@ export class QwcKafkaStreamsTopology extends QwcHotReloadElement {
}

_selectDescribeTab() {
this._tabContent = html`<qui-code-block mode='text' content='${this._topology.describe}' class="codeBlock"></qui-code-block>`;
this._tabContent = html`<qui-code-block theme='${themeState.theme.name}' content='${this._topology.describe}' class="codeBlock"></qui-code-block>`;
}

_selectGraphvizTab() {
this._tabContent = html`<qui-code-block mode='gv' content='${this._topology.graphviz}' class="codeBlock"></qui-code-block>`;
this._tabContent = html`<qui-code-block mode='gv' theme="${themeState.theme.name}" content='${this._topology.graphviz}' class="codeBlock"></qui-code-block>`;
}

_selectMermaidTab() {
this._tabContent = html`<qui-code-block mode='mermaid' content='${this._topology.mermaid}' class="codeBlock"></qui-code-block>`;
this._tabContent = html`<qui-code-block mode='mermaid' theme="${themeState.theme.name}" content='${this._topology.mermaid}' class="codeBlock"></qui-code-block>`;
}
}
customElements.define('qwc-kafka-streams-topology', QwcKafkaStreamsTopology);
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { LitElement, html, css} from 'lit';
import { JsonRpc } from 'jsonrpc';
import 'qui-code-block';
import { observeState } from 'lit-element-state';
import { themeState } from 'theme-state';
import '@quarkus-webcomponents/codeblock';
import '@vaadin/icon';
import '@vaadin/tabs';
import '@vaadin/tabsheet';
import '@vaadin/progress-bar';

export class QwcKubernetesManifest extends LitElement {
export class QwcKubernetesManifest extends observeState(LitElement) {

jsonRpc = new JsonRpc(this);

Expand Down Expand Up @@ -98,8 +100,9 @@ export class QwcKubernetesManifest extends LitElement {

return html`<div class="codeBlock">
<qui-code-block
mode='yaml'
content='${yaml}'>
mode="yaml"
content="${yaml}"
theme="${themeState.theme.name}">
</qui-code-block>
</div>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ InternalImportMapBuildItem createKnownInternalImportMap(NonApplicationRootPathBu

internalImportMapBuildItem.add("qui-badge", contextRoot + "qui/qui-badge.js");
internalImportMapBuildItem.add("qui-alert", contextRoot + "qui/qui-alert.js");
internalImportMapBuildItem.add("qui-code-block", contextRoot + "qui/qui-code-block.js");
internalImportMapBuildItem.add("qui-ide-link", contextRoot + "qui/qui-ide-link.js");

// Echarts
Expand Down
4 changes: 2 additions & 2 deletions extensions/vertx-http/dev-ui-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@

<!-- Code editor -->
<dependency>
<groupId>org.mvnpm.at.vanillawc</groupId>
<artifactId>wc-codemirror</artifactId>
<groupId>org.mvnpm.at.mvnpm</groupId>
<artifactId>codeblock</artifactId>
<scope>runtime</scope>
</dependency>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { LitElement, html, css } from 'lit';
import { JsonRpc } from 'jsonrpc';
import { notifier } from 'notifier';
import 'qui-code-block';
import { observeState } from 'lit-element-state';
import { themeState } from 'theme-state';
import '@quarkus-webcomponents/codeblock';
import '@vaadin/button';
import '@vaadin/icon';
import '@vaadin/progress-bar';

/**
* This component allows users to change the configuration in an online editor
*/
export class QwcConfigurationEditor extends LitElement {
export class QwcConfigurationEditor extends observeState(LitElement) {
jsonRpc = new JsonRpc(this);

static styles = css`
Expand Down Expand Up @@ -77,6 +79,7 @@ export class QwcConfigurationEditor extends LitElement {
mode='${this._type}'
content='${this._value}'
value='${this._value}'
theme='${themeState.theme.name}'
editable>
</qui-code-block>`;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { LitElement, html, css} from 'lit';
import { RouterController } from 'router-controller';
import 'qui-code-block';
import { observeState } from 'lit-element-state';
import { themeState } from 'theme-state';
import '@quarkus-webcomponents/codeblock';

/**
* This component renders build time data in raw json format
*/
export class QwcDataRawPage extends LitElement {
export class QwcDataRawPage extends observeState(LitElement) {
routerController = new RouterController(this);

static styles = css`
Expand All @@ -16,11 +18,6 @@ export class QwcDataRawPage extends LitElement {
padding-left: 10px;
padding-right: 10px;
}
.jsondata {
height: 100%;
overflow: scroll;
padding-bottom: 100px;
}
`;

static properties = {
Expand Down Expand Up @@ -55,8 +52,10 @@ export class QwcDataRawPage extends LitElement {

return html`<div class="codeBlock">
<qui-code-block
mode='javascript'
content='${json}'>
mode='json'
content='${json}'
theme='${themeState.theme.name}'
showLineNumbers>
</qui-code-block>
</div>`;
}
Expand Down
Loading
Loading