Skip to content

Commit 5cb79f3

Browse files
authored
Merge pull request #8510 from ProcessMaker/observation/FOUR-26310
observation/FOUR-26310 Added the copy or update option for devlink install assets
2 parents f13da1c + 4adfd20 commit 5cb79f3

File tree

5 files changed

+104
-41
lines changed

5 files changed

+104
-41
lines changed

ProcessMaker/Http/Controllers/Api/DevLinkController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,14 @@ public function removeSharedAsset($id)
355355

356356
public function installRemoteAsset(Request $request, DevLink $devLink)
357357
{
358+
$updateType = $request->input('updateType', DevLinkInstall::MODE_UPDATE);
359+
358360
DevLinkInstall::dispatch(
359361
$request->user()->id,
360362
$devLink->id,
361363
$request->input('class'),
362364
$request->input('id'),
363-
DevLinkInstall::MODE_UPDATE,
365+
$updateType,
364366
DevLinkInstall::TYPE_IMPORT_ASSET
365367
);
366368

ProcessMaker/Jobs/DevLinkInstall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function handle(): void
6767
$bundle->reinstall($this->importMode, $logger);
6868
break;
6969
case self::TYPE_IMPORT_ASSET:
70-
$devLink->installRemoteAsset($this->class, $this->id, $logger);
70+
$devLink->installRemoteAsset($this->class, $this->id, $this->importMode, $logger);
7171
break;
7272
default:
7373
break;

ProcessMaker/Models/DevLink.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ public function installRemoteBundle($remoteBundleId, $updateType)
191191
$this->logger->setStatus('done');
192192
}
193193

194-
public function installRemoteAsset(string $class, int $id, Logger $logger) : ProcessMakerModel
194+
public function installRemoteAsset(string $class, int $id, string $updateType, Logger $logger) : ProcessMakerModel
195195
{
196196
$payload = $this->client()->get(
197197
route('api.devlink.export-local-asset', ['class' => $class, 'id' => $id], false)
198198
)->json();
199199

200200
$options = new Options([
201-
'mode' => 'update',
201+
'mode' => $updateType,
202202
]);
203203

204204
$logger->setSteps([$payload]);

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

Lines changed: 94 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<script setup>
22
import { ref, watch, onMounted, getCurrentInstance } from 'vue';
3-
import { useRouter, useRoute } from 'vue-router/composables';
3+
import { useRoute } from 'vue-router/composables';
44
import debounce from 'lodash/debounce';
55
import InstanceTabs from './InstanceTabs.vue';
66
import types from './assetTypes';
77
import moment from 'moment';
88
import Header from './Header.vue';
99
import InstallProgress from './InstallProgress.vue';
1010
11-
const router = useRouter();
1211
const route = useRoute();
1312
const vue = getCurrentInstance().proxy;
1413
@@ -18,9 +17,30 @@ const items = ref([]);
1817
const meta = ref({});
1918
const filter = ref("");
2019
const showInstallModal = ref(false);
20+
const showConfirmModal = ref(false);
21+
const selectedAsset = ref(null);
22+
const installMode = ref('update');
2123
const page = ref(1);
2224
const perPage = ref(15);
2325
26+
const load = () => {
27+
if (!typeConfig) {
28+
return;
29+
}
30+
const queryParams = {
31+
url: typeConfig.url,
32+
filter: filter.value,
33+
per_page: perPage.value,
34+
page: page.value
35+
};
36+
ProcessMaker.apiClient
37+
.get(`devlink/${route.params.id}/remote-assets-listing`, { params: queryParams })
38+
.then((result) => {
39+
items.value = result.data.data;
40+
meta.value = result.data.meta;
41+
});
42+
};
43+
2444
watch(page, () => {
2545
load();
2646
});
@@ -57,52 +77,42 @@ const fields = [
5777
},
5878
{
5979
key: 'menu',
60-
label: ''
80+
label: '',
6181
},
6282
];
6383
6484
6585
const install = (asset) => {
66-
vue.$bvModal.msgBoxConfirm(vue.$t('Are you sure you want to install this asset onto this instance?'), {
67-
okTitle: vue.$t('Ok'),
68-
cancelTitle: vue.$t('Cancel')
69-
}).then((confirm) => {
70-
if (confirm) {
71-
showInstallModal.value = true;
72-
const params = {
73-
class: typeConfig.class,
74-
id: asset.id
75-
};
76-
ProcessMaker.apiClient
77-
.post(`/devlink/${route.params.id}/install-remote-asset`, params)
78-
.then((response) => {
79-
});
80-
}
81-
});
86+
selectedAsset.value = asset;
87+
showConfirmModal.value = true;
88+
};
89+
90+
const confirmInstall = () => {
91+
if (selectedAsset.value) {
92+
showConfirmModal.value = false;
93+
showInstallModal.value = true;
94+
const params = {
95+
class: typeConfig.class,
96+
id: selectedAsset.value.id,
97+
updateType: installMode.value
98+
};
99+
ProcessMaker.apiClient
100+
.post(`/devlink/${route.params.id}/install-remote-asset`, params)
101+
.then(() => {
102+
selectedAsset.value = null;
103+
});
104+
}
105+
};
106+
107+
const cancelInstall = () => {
108+
selectedAsset.value = null;
109+
showConfirmModal.value = false;
82110
};
83111
84112
onMounted(() => {
85113
load();
86114
});
87115
88-
const load = () => {
89-
if (!typeConfig) {
90-
return;
91-
}
92-
const queryParams = {
93-
url: typeConfig.url,
94-
filter: filter.value,
95-
per_page: perPage.value,
96-
page: page.value
97-
};
98-
ProcessMaker.apiClient
99-
.get(`devlink/${route.params.id}/remote-assets-listing`, { params: queryParams })
100-
.then((result) => {
101-
items.value = result.data.data;
102-
meta.value = result.data.meta;
103-
});
104-
};
105-
106116
// Debounced function
107117
const debouncedLoad = debounce(load, 300);
108118
@@ -152,6 +162,53 @@ const handleFilterChange = () => {
152162
@page-change="page = $event"
153163
@per-page-change="perPage = $event"
154164
/>
165+
<!-- Confirmation Modal -->
166+
<b-modal
167+
id="install-confirm"
168+
v-model="showConfirmModal"
169+
:title="$t('Install Asset')"
170+
@ok="confirmInstall"
171+
@cancel="cancelInstall"
172+
:ok-title="$t('Install')"
173+
:cancel-title="$t('Cancel')"
174+
>
175+
<div class="mb-3">
176+
<p>{{ $t('Do you want to proceed with installing the asset on your instance?') }}</p>
177+
<p v-if="selectedAsset" class="font-weight-bold">{{ selectedAsset.name || selectedAsset.title }}</p>
178+
</div>
179+
180+
<div class="form-group">
181+
<label class="font-weight-bold mb-2">{{ $t('Installation Mode:') }}</label>
182+
<div class="custom-control custom-radio">
183+
<input
184+
id="update-mode"
185+
v-model="installMode"
186+
type="radio"
187+
value="update"
188+
class="custom-control-input"
189+
>
190+
<label for="update-mode" class="custom-control-label">
191+
<strong>{{ $t('Update') }}</strong>
192+
<div class="text-muted small">{{ $t('Update existing asset with the same name (recommended)') }}</div>
193+
</label>
194+
</div>
195+
<div class="custom-control custom-radio mt-2">
196+
<input
197+
id="copy-mode"
198+
v-model="installMode"
199+
type="radio"
200+
value="copy"
201+
class="custom-control-input"
202+
>
203+
<label for="copy-mode" class="custom-control-label">
204+
<strong>{{ $t('Copy') }}</strong>
205+
<div class="text-muted small">{{ $t('Create a new asset even if one with the same name exists') }}</div>
206+
</label>
207+
</div>
208+
</div>
209+
</b-modal>
210+
211+
<!-- Progress Modal -->
155212
<b-modal id="install-progress" size="lg" v-model="showInstallModal" :title="$t('Installation Progress')" hide-footer>
156213
<install-progress />
157214
</b-modal>

resources/lang/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@
490490
"Count": "Count",
491491
"Country Codes": "Country Codes",
492492
"Country": "Country",
493+
"Create a new asset even if one with the same name exists": "Create a new asset even if one with the same name exists",
493494
"Create a bundle to easily share assets and settings between ProcessMaker instances.": "Create a bundle to easily share assets and settings between ProcessMaker instances.",
494495
"Create a new Process": "Create a new Process",
495496
"Create a Project": "Create a Project",
@@ -679,6 +680,7 @@
679680
"Do you want to delete the tab {{name}}?": "Do you want to delete the tab {{name}}?",
680681
"Do you want to delete this image?": "Do you want to delete this image?",
681682
"Do you want to delete this rule?": "Do you want to delete this rule?",
683+
"Do you want to proceed with installing the asset on your instance?": "Do you want to proceed with installing the asset on your instance?",
682684
"Docker file": "Docker file",
683685
"Docker not found.": "Docker not found.",
684686
"Document Type": "Document Type",
@@ -1125,6 +1127,7 @@
11251127
"Input Fields": "Input Fields",
11261128
"input": "input",
11271129
"Inspector": "Inspector",
1130+
"Installation Mode:": "Installation Mode:",
11281131
"Installation Progress": "Installation Progress",
11291132
"Installer completed. Consult ProcessMaker documentation on how to configure email, jobs and notifications.": "Installer completed. Consult ProcessMaker documentation on how to configure email, jobs and notifications.",
11301133
"Installing ProcessMaker database, OAuth SSL keys and configuration file.": "Installing ProcessMaker database, OAuth SSL keys and configuration file.",
@@ -2433,6 +2436,7 @@
24332436
"Update Available": "Update Available",
24342437
"Update Bundle Assets": "Update Bundle Assets",
24352438
"Update Bundle": "Update Bundle",
2439+
"Update existing asset with the same name (recommended)": "Update existing asset with the same name (recommended)",
24362440
"Update Group Successfully": "Update Group Successfully",
24372441
"Update Rule": "Update Rule",
24382442
"Update": "Update",

0 commit comments

Comments
 (0)