Skip to content

Commit 38efe28

Browse files
Merge pull request quarkusio#47845 from phillip-kruger/devui-flyway
Dev UI Flyway: Hide clean button if clean is disabled
2 parents 5f834a5 + da32510 commit 38efe28

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

extensions/flyway/deployment/src/main/resources/dev-ui/qwc-flyway-datasources.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ export class QwcFlywayDatasources extends QwcHotReloadElement {
3030
static properties = {
3131
_ds: {state: true},
3232
_selectedDs: {state: true},
33-
_createDialogOpened: {state: true}
33+
_createDialogOpened: {state: true},
34+
_cleanDisabled: {state: true}
3435
}
3536

3637
constructor() {
3738
super();
3839
this._ds = null;
3940
this._selectedDs = null;
4041
this._createDialogOpened = false;
42+
this._cleanDisabled = true;
4143
}
4244

4345
connectedCallback() {
@@ -47,7 +49,11 @@ export class QwcFlywayDatasources extends QwcHotReloadElement {
4749

4850
hotReload(){
4951
this.jsonRpc.getDatasources().then(jsonRpcResponse => {
50-
this._ds = jsonRpcResponse.result;
52+
this._ds = jsonRpcResponse.result;
53+
});
54+
55+
this.jsonRpc.isCleanDisabled().then(jsonRpcResponse => {
56+
this._cleanDisabled = jsonRpcResponse.result;
5157
});
5258
}
5359

@@ -81,16 +87,21 @@ export class QwcFlywayDatasources extends QwcHotReloadElement {
8187

8288
_renderMigrationButtons(ds) {
8389
if(ds.hasMigrations){
84-
return html`
85-
<vaadin-button theme="small" @click=${() => this._clean(ds)} class="button">
86-
<vaadin-icon class="clearIcon" icon="font-awesome-solid:broom"></vaadin-icon> Clean
87-
</vaadin-button>
90+
return html`${this._renderCleanButton(ds)}
8891
<vaadin-button theme="small" @click=${() => this._migrate(ds)} class="button">
8992
<vaadin-icon icon="font-awesome-solid:arrow-right-arrow-left"></vaadin-icon> Migrate
9093
</vaadin-button>`;
9194
}
9295
}
9396

97+
_renderCleanButton(ds){
98+
if(!this._cleanDisabled) {
99+
return html`<vaadin-button theme="small" @click=${() => this._clean(ds)} class="button">
100+
<vaadin-icon class="clearIcon" icon="font-awesome-solid:broom"></vaadin-icon> Clean
101+
</vaadin-button>`;
102+
}
103+
}
104+
94105
_renderCreateButton(ds) {
95106
if(ds.createPossible){
96107
return html`
@@ -146,6 +157,7 @@ export class QwcFlywayDatasources extends QwcHotReloadElement {
146157
_migrate(ds) {
147158
this.jsonRpc.migrate({ds: ds.name}).then(jsonRpcResponse => {
148159
this._showResultNotification(jsonRpcResponse.result);
160+
this.hotReload();
149161
});
150162
}
151163

extensions/flyway/runtime-dev/src/main/java/io/quarkus/flyway/runtime/dev/ui/FlywayJsonRpcService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public class FlywayJsonRpcService {
3030
@ConfigProperty(name = "quarkus.flyway.locations")
3131
private List<String> locations;
3232

33+
@ConfigProperty(name = "quarkus.flyway.clean-disabled")
34+
private boolean cleanDisabled;
35+
3336
public void setInitialSqlSuppliers(Map<String, Supplier<String>> initialSqlSuppliers) {
3437
this.initialSqlSuppliers = initialSqlSuppliers;
3538
}
@@ -50,6 +53,10 @@ public Collection<FlywayDatasource> getDatasources() {
5053
return datasources.values();
5154
}
5255

56+
public boolean isCleanDisabled() {
57+
return this.cleanDisabled;
58+
}
59+
5360
public FlywayActionResponse clean(String ds) {
5461
Flyway flyway = getFlyway(ds);
5562
if (flyway != null) {

0 commit comments

Comments
 (0)