Skip to content

Commit 96c4030

Browse files
authored
Merge pull request #1072 from mariatouil/fix/success-msg-deploy
Fix : the issue with the success message not displaying after deployment
2 parents 1b5a640 + 408631d commit 96c4030

File tree

1 file changed

+45
-12
lines changed

1 file changed

+45
-12
lines changed

src/dev-center/js/dev-center.js

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ async function create_app(title, source_path = null, items = null) {
296296

297297
})
298298
.then(async (app) => {
299+
$('.new-app-modal').get(0).close();
300+
window.location.reload();
299301
let app_dir;
300302
// ----------------------------------------------------
301303
// Create app directory in AppData
@@ -321,6 +323,8 @@ async function create_app(title, source_path = null, items = null) {
321323
maximizeOnStart: false,
322324
background: false,
323325
}).then(async (app) => {
326+
$('.new-app-modal').get(0).close();
327+
window.location.reload();
324328
// refresh app list
325329
puter.apps.list({ icon_size: 64 }).then(async (resp) => {
326330
apps = resp;
@@ -518,7 +522,7 @@ function generate_edit_app_section(app) {
518522
</ul>
519523
520524
<div class="section-tab active" data-tab="deploy">
521-
<div class="success deploy-success-msg">
525+
<div id="deploy-success-msg" class="success deploy-success-msg">
522526
New version deployed successfully 🎉<span class="close-success-msg">&times;</span>
523527
<p style="margin-bottom:0;"><span class="open-app button button-action" data-uid="${html_encode(app.uid)}" data-app-name="${html_encode(app.name)}">Give it a try!</span></p>
524528
</div>
@@ -910,7 +914,7 @@ async function edit_app_section(cur_app_name, tab = 'deploy') {
910914
dropped_items = items[0].path;
911915
$('.drop-area').removeClass('drop-area-hover');
912916
$('.drop-area').addClass('drop-area-ready-to-deploy');
913-
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">index.html</p><p>Ready to deploy 🚀</p><p class="reset-deploy"><span>Cancel</span></p>`;
917+
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">index.html</p><p>Ready to deploy 🚀</p>`;
914918
$('.drop-area').html(drop_area_content);
915919

916920
// enable deploy button
@@ -944,7 +948,7 @@ async function edit_app_section(cur_app_name, tab = 'deploy') {
944948
dropped_items = items;
945949
$('.drop-area').removeClass('drop-area-hover');
946950
$('.drop-area').addClass('drop-area-ready-to-deploy');
947-
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">${items.length} items</p><p>Ready to deploy 🚀</p><p class="reset-deploy"><span>Cancel</span></p>`;
951+
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">${items.length} items</p><p>Ready to deploy 🚀</p>`;
948952
$('.drop-area').html(drop_area_content);
949953

950954
// enable deploy button
@@ -985,7 +989,7 @@ async function edit_app_section(cur_app_name, tab = 'deploy') {
985989

986990
$('.drop-area').removeClass('drop-area-hover');
987991
$('.drop-area').addClass('drop-area-ready-to-deploy');
988-
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">${rootItems}</p><p>Ready to deploy 🚀</p><p class="reset-deploy"><span>Cancel</span></p>`;
992+
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">${rootItems}</p><p>Ready to deploy 🚀</p>`;
989993
$('.drop-area').html(drop_area_content);
990994

991995
// enable deploy button
@@ -1059,7 +1063,7 @@ async function edit_app_section(cur_app_name, tab = 'deploy') {
10591063
rootItems = html_encode(rootItems);
10601064
$('.drop-area').removeClass('drop-area-hover');
10611065
$('.drop-area').addClass('drop-area-ready-to-deploy');
1062-
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">${rootItems}</p><p>Ready to deploy 🚀</p><p class="reset-deploy"><span>Cancel</span></p>`;
1066+
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">${rootItems}</p><p>Ready to deploy 🚀</p>`;
10631067
$('.drop-area').html(drop_area_content);
10641068

10651069
// enable deploy button
@@ -1893,7 +1897,7 @@ window.deploy = async function (app, items) {
18931897
$('.deploy-btn').addClass('disabled');
18941898

18951899
// change drop area text
1896-
$('.drop-area').html(deploying_spinner + ' <div>Deploying <span class="deploy-percent">(0%)</span></div>');
1900+
$('.drop-area').html(deploying_spinner + ' <div>Deploying <span class="deploy-percent">(0%)</span></div><p class="reset-deploy button button-secondary"><span>Cancel</span></p>');
18971901

18981902
if (typeof items === 'string' && (items.startsWith('/') || items.startsWith('~'))) {
18991903
$('.drop-area').removeClass('drop-area-hover');
@@ -1973,6 +1977,7 @@ window.deploy = async function (app, items) {
19731977
// update progress
19741978
$('.deploy-percent').text(`(${Math.round((files.indexOf(file) / files.length) * 100)}%)`);
19751979
}
1980+
19761981
}
19771982
}
19781983
// --------------------------------------------------------------------
@@ -2009,7 +2014,7 @@ window.deploy = async function (app, items) {
20092014
// set the 'Index URL' field for the 'Settings' tab
20102015
$('#edit-app-index-url').val(protocol + `://${hostname}.` + static_hosting_domain);
20112016
// show success message
2012-
$('.deploy-success-msg').show();
2017+
$('#deploy-success-msg').show();
20132018
// reset drop area
20142019
reset_drop_area();
20152020
})
@@ -2077,8 +2082,13 @@ window.deploy = async function (app, items) {
20772082
createMissingAncestors: true,
20782083
progress: function (operation_id, op_progress) {
20792084
$('.deploy-percent').text(`(${op_progress}%)`);
2085+
20802086
},
20812087
}).then(async (uploaded) => {
2088+
// show success message
2089+
$('#deploy-success-msg').show();
2090+
// reset drop area
2091+
reset_drop_area()
20822092
// new hostname
20832093
let hostname = `${currently_editing_app.name}-${(Math.random() + 1).toString(36).substring(7)}`;
20842094

@@ -2101,7 +2111,7 @@ window.deploy = async function (app, items) {
21012111
// set the 'Index URL' field for the 'Settings' tab
21022112
$('#edit-app-index-url').val(protocol + `://${hostname}.` + static_hosting_domain);
21032113
// show success message
2104-
$('.deploy-success-msg').show();
2114+
$('#deploy-success-msg').show();
21052115
// reset drop area
21062116
reset_drop_area()
21072117
})
@@ -2264,7 +2274,7 @@ $(document).on('click', '.insta-deploy-existing-app-deploy-btn', function (e) {
22642274

22652275
$('.drop-area').removeClass('drop-area-hover');
22662276
$('.drop-area').addClass('drop-area-ready-to-deploy');
2267-
let drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">Ready to deploy 🚀</p><p class="reset-deploy"><span>Cancel</span></p>`;
2277+
let drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">Ready to deploy 🚀</p><p class="reset-deploy button button-secondary"><span>Cancel</span></p>`;
22682278
$('.drop-area').html(drop_area_content);
22692279

22702280
// deploy
@@ -2707,9 +2717,32 @@ function enable_window_settings(){
27072717
$('#edit-app-hide-titlebar').prop('disabled', false);
27082718
}
27092719

2710-
$(document).on('click', '.reset-deploy', function (e) {
2711-
reset_drop_area();
2712-
})
2720+
$(document).on('click', '.reset-deploy', async function (e) {
2721+
// Display a confirmation dialog to ask the user
2722+
const alert_resp = await puter.ui.alert(
2723+
'Are you sure you want to cancel the deployment?',
2724+
[
2725+
{
2726+
label: 'Yes, cancel deployment',
2727+
value: 'cancel',
2728+
type: 'danger', // This can style the button as red/danger
2729+
},
2730+
{
2731+
label: 'No, keep it',
2732+
value: 'keep'
2733+
}
2734+
]
2735+
);
2736+
2737+
if (alert_resp === 'cancel') {
2738+
// If the user clicks "Yes, cancel deployment", reset the drop area
2739+
reset_drop_area();
2740+
} else {
2741+
// If the user clicks "No, keep it", do nothing or log it
2742+
console.log('Deployment is not canceled.');
2743+
}
2744+
});
2745+
27132746

27142747
$(document).on('click', '.sidebar-toggle', function (e) {
27152748
$('.sidebar').toggleClass('open');

0 commit comments

Comments
 (0)