Skip to content

Commit a1d9acf

Browse files
Added a update and copy bundle assets
1 parent d97c4eb commit a1d9acf

File tree

6 files changed

+101
-31
lines changed

6 files changed

+101
-31
lines changed

ProcessMaker/Http/Controllers/Api/DevLinkController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,12 @@ public function deleteBundle(Bundle $bundle)
167167

168168
public function installRemoteBundle(Request $request, DevLink $devLink, $remoteBundleId)
169169
{
170+
$updateType = $request->input('updateType', 'update');
170171
DevLinkInstall::dispatch(
171172
$request->user()->id,
172173
$devLink->id,
173174
$remoteBundleId,
174-
'update'
175+
$updateType
175176
);
176177
}
177178

ProcessMaker/Models/DevLink.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function remoteAssetsListing($request)
107107
);
108108
}
109109

110-
public function installRemoteBundle($bundleId)
110+
public function installRemoteBundle($bundleId, $updateType)
111111
{
112112
if (!$this->logger) {
113113
$this->logger = new Logger();
@@ -129,30 +129,37 @@ public function installRemoteBundle($bundleId)
129129
[
130130
'name' => $bundleInfo['name'],
131131
'published' => $bundleInfo['published'],
132-
'locked' => $bundleInfo['locked'],
133132
'version' => $bundleInfo['version'],
134133
]
135134
);
136135

137136
$this->logger->status('Installing bundle on the this instance');
138137
$this->logger->setSteps($bundleExport['payloads']);
139138

139+
$options = [
140+
'mode' => $updateType,
141+
'saveAssetsMode' => 'saveAllAssets',
142+
'isTemplate' => false,
143+
];
140144
$assets = [];
141145
foreach ($bundleExport['payloads'] as $payload) {
142-
$assets[] = $this->import($payload);
146+
$assets[] = $this->import($payload, $options);
143147
}
144148

145-
$this->logger->status('Syncing bundle assets');
146-
$bundle->syncAssets($assets);
149+
if ($updateType === 'update') {
150+
$this->logger->status('Syncing bundle assets');
151+
$bundle->syncAssets($assets);
152+
}
147153

148154
$this->logger->addWarning('Test warning message');
149155

150156
$this->logger->setStatus('done');
151157
}
152158

153-
private function import(array $payload)
159+
private function import(array $payload, $options = null)
154160
{
155-
$importer = new Importer($payload, new Options([]), $this->logger);
161+
$options = $options === null ? new Options([]) : new Options($options);
162+
$importer = new Importer($payload, $options, $this->logger);
156163
$manifest = $importer->doImport();
157164

158165
return $manifest[$payload['root']]->model;

resources/js/admin/devlink/components/Index.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,6 @@ const urlIsValid = computed(() => {
168168
</b-button>
169169
</div>
170170
</div>
171-
<b-modal
172-
ref="confirmDeleteModal"
173-
centered
174-
title="Delete DevLink"
175-
@ok="executeDelete"
176-
>
177-
<p>Are you sure you want to delete {{ selected?.name }}?</p>
178-
</b-modal>
179171

180172
<b-modal
181173
id="create"

resources/js/admin/devlink/components/Instance.vue

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ const bundles = ref([]);
1313
const filter = ref("");
1414
const warnings = ref([]);
1515
const showInstallModal = ref(false);
16+
const confirmUpdateVersion = ref(null);
17+
const selectedOption = ref('update');
18+
const bundleAttributes = {
19+
id: null,
20+
name: '',
21+
published: false,
22+
};
23+
const selected = ref(bundleAttributes);
1624
const fields = [
1725
{
1826
key: 'name',
@@ -48,6 +56,11 @@ const closeModal = () => {
4856
$("#warningsModal").modal("hide");
4957
};
5058
59+
const updateVersionBundle = (bundle) => {
60+
selected.value = bundle;
61+
confirmUpdateVersion.value.show();
62+
};
63+
5164
const load = () => {
5265
ProcessMaker.apiClient
5366
.get(`/devlink/${route.params.id}/remote-bundles?filter=${filter.value}`)
@@ -79,6 +92,16 @@ const install = (bundle) => {
7992
}
8093
});
8194
};
95+
const executeUpdate = (updateType) => {
96+
showInstallModal.value = true;
97+
ProcessMaker.apiClient
98+
.post(`/devlink/${route.params.id}/remote-bundles/${selected.value.id}/install`, {
99+
updateType,
100+
})
101+
.then((response) => {
102+
// Handle the response as needed
103+
});
104+
};
82105
83106
</script>
84107

@@ -100,7 +123,7 @@ const install = (bundle) => {
100123
<div class="btn-menu-container">
101124
<button
102125
class="btn install-bundle-btn"
103-
@click.prevent="install(data.item)"
126+
@click.prevent="updateVersionBundle(data.item)"
104127
>
105128
<i class="fp-cloud-download-outline"></i>
106129
</button>
@@ -128,6 +151,37 @@ const install = (bundle) => {
128151
</div>
129152
</div>
130153
</div>
154+
<b-modal
155+
ref="confirmUpdateVersion"
156+
centered
157+
size="lg"
158+
content-class="modal-style"
159+
:title="$t('Update Bundle Version')"
160+
:ok-title="$t('Continue')"
161+
:cancel-title="$t('Cancel')"
162+
@ok="executeUpdate(selectedOption)"
163+
>
164+
<div>
165+
<p class="mb-4">Select how you want to update the bundle <strong>Testing Processes and Assets</strong></p>
166+
167+
<b-form-group>
168+
<b-form-radio-group v-model="selectedOption" name="bundleUpdateOptions">
169+
<b-form-radio
170+
class="mb-4"
171+
value="update"
172+
>
173+
{{ $t('Quick Update') }}
174+
<p class="text-muted">{{ $t('The current bundle will be replaced completely for the new version immediately.') }}</p>
175+
</b-form-radio>
176+
177+
<b-form-radio value="copy">
178+
{{ $t('Copy Changes') }}
179+
<p class="text-muted">{{ $t('Copy and update bundle.') }}</p>
180+
</b-form-radio>
181+
</b-form-radio-group>
182+
</b-form-group>
183+
</div>
184+
</b-modal>
131185
<b-modal id="install-progress" size="lg" v-model="showInstallModal" :title="$t('Installation Progress')" hide-footer>
132186
<install-progress />
133187
</b-modal>

resources/js/admin/devlink/components/LocalBundles.vue

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import debounce from 'lodash/debounce';
44
import Origin from './Origin.vue';
55
import VersionCheck from './VersionCheck.vue';
66
import EllipsisMenu from '../../../components/shared/EllipsisMenu.vue';
7+
import InstallProgress from './InstallProgress.vue';
78
import { useRouter, useRoute } from 'vue-router/composables';
89
910
const vue = getCurrentInstance().proxy;
@@ -14,6 +15,8 @@ const editModal = ref(null);
1415
const confirmDeleteModal = ref(null);
1516
const confirmIncreaseVersion = ref(null);
1617
const confirmUpdateVersion = ref(null);
18+
const selectedOption = ref('update');
19+
const showInstallModal = ref(false);
1720
const filter = ref("");
1821
const actions = [
1922
{ value: "increase-item", content: "Increase Version", conditional: "if(not(dev_link_id), true, false)" },
@@ -162,8 +165,15 @@ const executeDelete = () => {
162165
});
163166
};
164167
165-
const executeUpdate = () => {
166-
return null;
168+
const executeUpdate = (updateType) => {
169+
showInstallModal.value = true;
170+
ProcessMaker.apiClient
171+
.post(`/devlink/${selected.value.dev_link_id}/remote-bundles/${selected.value.remote_id}/install`, {
172+
updateType,
173+
})
174+
.then((response) => {
175+
// Handle the response as needed
176+
});
167177
};
168178
169179
// Debounced function
@@ -200,8 +210,8 @@ const deleteWaring = computed(() => {
200210
@click="createNewBundle"
201211
class="new-button"
202212
>
203-
<i class="fas fa-plus-circle" style="padding-right: 8px;"></i>
204-
{{ $t('Create Bundle') }}
213+
<i class="fas fa-plus-circle" style="padding-right: 8px;"></i>
214+
{{ $t('Create Bundle') }}
205215
</b-button>
206216
</div>
207217
</div>
@@ -228,25 +238,29 @@ const deleteWaring = computed(() => {
228238
<b-modal
229239
ref="confirmUpdateVersion"
230240
centered
241+
size="lg"
231242
content-class="modal-style"
232243
:title="$t('Update Bundle Version')"
233244
:ok-title="$t('Continue')"
234245
:cancel-title="$t('Cancel')"
235-
@ok="executeUpdate"
246+
@ok="executeUpdate(selectedOption)"
236247
>
237248
<div>
238-
<p>Select how you want to update the bundle <strong>Testing Processes and Assets</strong></p>
249+
<p class="mb-4">Select how you want to update the bundle <strong>Testing Processes and Assets</strong></p>
239250
240251
<b-form-group>
241252
<b-form-radio-group v-model="selectedOption" name="bundleUpdateOptions">
242-
<b-form-radio value="quick-update">
243-
Quick Update
244-
<p class="text-muted">The current bundle will be replaced completely for the new version immediately.</p>
253+
<b-form-radio
254+
class="mb-4"
255+
value="update"
256+
>
257+
{{ $t('Quick Update') }}
258+
<p class="text-muted">{{ $t('The current bundle will be replaced completely for the new version immediately.') }}</p>
245259
</b-form-radio>
246260
247-
<b-form-radio value="review-changes">
248-
Review changes in bundle
249-
<p class="text-muted">Check and compare the changes before updating the bundle.</p>
261+
<b-form-radio value="copy">
262+
{{ $t('Copy Changes') }}
263+
<p class="text-muted">{{ $t('Copy and update bundle.') }}</p>
250264
</b-form-radio>
251265
</b-form-radio-group>
252266
</b-form-group>
@@ -269,13 +283,16 @@ const deleteWaring = computed(() => {
269283
<b-form-checkbox v-model="selected.published"></b-form-checkbox>
270284
</b-form-group>
271285
</b-modal>
286+
<b-modal id="install-progress" size="lg" v-model="showInstallModal" :title="$t('Installation Progress')" hide-footer>
287+
<install-progress />
288+
</b-modal>
272289
<div class="card local-bundles-card">
273290
<b-table
274291
hover
275292
class="clickable"
276-
@row-clicked="goToBundleAssets"
277293
:items="bundles"
278294
:fields="fields"
295+
@row-clicked="goToBundleAssets"
279296
>
280297
<template #cell(name)="data">
281298
{{ data.item.name }}

tests/Model/DevLinkTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public function testInstallRemoteBundle()
7171
'id' => 123,
7272
'name' => 'Test Bundle',
7373
'published' => true,
74-
'locked' => false,
7574
'version' => '5',
7675
]),
7776
'http://remote-instance.test/api/1.0/devlink/export-local-bundle/123' => Http::response([

0 commit comments

Comments
 (0)