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

Fix : the issue with the success message not displaying after deployment #1072

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
57 changes: 45 additions & 12 deletions src/dev-center/js/dev-center.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ async function create_app(title, source_path = null, items = null) {

})
.then(async (app) => {
$('.new-app-modal').get(0).close();
window.location.reload();
let app_dir;
// ----------------------------------------------------
// Create app directory in AppData
Expand All @@ -313,6 +315,8 @@ async function create_app(title, source_path = null, items = null) {
maximizeOnStart: false,
background: false,
}).then(async (app) => {
$('.new-app-modal').get(0).close();
window.location.reload();
// refresh app list
puter.apps.list().then(async (resp) => {
apps = resp;
Expand Down Expand Up @@ -509,7 +513,7 @@ function generate_edit_app_section(app) {
</ul>

<div class="section-tab active" data-tab="deploy">
<div class="success deploy-success-msg">
<div id="deploy-success-msg" class="success deploy-success-msg">
New version deployed successfully 🎉<span class="close-success-msg">&times;</span>
<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>
</div>
Expand Down Expand Up @@ -802,7 +806,7 @@ async function edit_app_section(cur_app_name) {
dropped_items = items[0].path;
$('.drop-area').removeClass('drop-area-hover');
$('.drop-area').addClass('drop-area-ready-to-deploy');
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>`;
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">index.html</p><p>Ready to deploy 🚀</p>`;
$('.drop-area').html(drop_area_content);

// enable deploy button
Expand Down Expand Up @@ -836,7 +840,7 @@ async function edit_app_section(cur_app_name) {
dropped_items = items;
$('.drop-area').removeClass('drop-area-hover');
$('.drop-area').addClass('drop-area-ready-to-deploy');
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>`;
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">${items.length} items</p><p>Ready to deploy 🚀</p>`;
$('.drop-area').html(drop_area_content);

// enable deploy button
Expand Down Expand Up @@ -877,7 +881,7 @@ async function edit_app_section(cur_app_name) {

$('.drop-area').removeClass('drop-area-hover');
$('.drop-area').addClass('drop-area-ready-to-deploy');
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>`;
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">${rootItems}</p><p>Ready to deploy 🚀</p>`;
$('.drop-area').html(drop_area_content);

// enable deploy button
Expand Down Expand Up @@ -951,7 +955,7 @@ async function edit_app_section(cur_app_name) {
rootItems = html_encode(rootItems);
$('.drop-area').removeClass('drop-area-hover');
$('.drop-area').addClass('drop-area-ready-to-deploy');
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>`;
drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">${rootItems}</p><p>Ready to deploy 🚀</p>`;
$('.drop-area').html(drop_area_content);

// enable deploy button
Expand Down Expand Up @@ -1645,7 +1649,7 @@ window.deploy = async function (app, items) {
$('.deploy-btn').addClass('disabled');

// change drop area text
$('.drop-area').html(deploying_spinner + ' <div>Deploying <span class="deploy-percent">(0%)</span></div>');
$('.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>');

if (typeof items === 'string' && (items.startsWith('/') || items.startsWith('~'))) {
$('.drop-area').removeClass('drop-area-hover');
Expand Down Expand Up @@ -1725,6 +1729,7 @@ window.deploy = async function (app, items) {
// update progress
$('.deploy-percent').text(`(${Math.round((files.indexOf(file) / files.length) * 100)}%)`);
}

}
}
// --------------------------------------------------------------------
Expand Down Expand Up @@ -1761,7 +1766,7 @@ window.deploy = async function (app, items) {
// set the 'Index URL' field for the 'Settings' tab
$('#edit-app-index-url').val(protocol + `://${hostname}.` + static_hosting_domain);
// show success message
$('.deploy-success-msg').show();
$('#deploy-success-msg').show();
// reset drop area
reset_drop_area();
})
Expand Down Expand Up @@ -1829,8 +1834,13 @@ window.deploy = async function (app, items) {
createMissingAncestors: true,
progress: function (operation_id, op_progress) {
$('.deploy-percent').text(`(${op_progress}%)`);

},
}).then(async (uploaded) => {
// show success message
$('#deploy-success-msg').show();
// reset drop area
reset_drop_area()
// new hostname
let hostname = `${currently_editing_app.name}-${(Math.random() + 1).toString(36).substring(7)}`;

Expand All @@ -1853,7 +1863,7 @@ window.deploy = async function (app, items) {
// set the 'Index URL' field for the 'Settings' tab
$('#edit-app-index-url').val(protocol + `://${hostname}.` + static_hosting_domain);
// show success message
$('.deploy-success-msg').show();
$('#deploy-success-msg').show();
// reset drop area
reset_drop_area()
})
Expand Down Expand Up @@ -2016,7 +2026,7 @@ $(document).on('click', '.insta-deploy-existing-app-deploy-btn', function (e) {

$('.drop-area').removeClass('drop-area-hover');
$('.drop-area').addClass('drop-area-ready-to-deploy');
let drop_area_content = `<p style="margin-bottom:0; font-weight: 500;">Ready to deploy 🚀</p><p class="reset-deploy"><span>Cancel</span></p>`;
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>`;
$('.drop-area').html(drop_area_content);

// deploy
Expand Down Expand Up @@ -2458,9 +2468,32 @@ function enable_window_settings(){
$('#edit-app-hide-titlebar').prop('disabled', false);
}

$(document).on('click', '.reset-deploy', function (e) {
reset_drop_area();
})
$(document).on('click', '.reset-deploy', async function (e) {
// Display a confirmation dialog to ask the user
const alert_resp = await puter.ui.alert(
'Are you sure you want to cancel the deployment?',
[
{
label: 'Yes, cancel deployment',
value: 'cancel',
type: 'danger', // This can style the button as red/danger
},
{
label: 'No, keep it',
value: 'keep'
}
]
);

if (alert_resp === 'cancel') {
// If the user clicks "Yes, cancel deployment", reset the drop area
reset_drop_area();
} else {
// If the user clicks "No, keep it", do nothing or log it
console.log('Deployment is not canceled.');
}
});


$(document).on('click', '.sidebar-toggle', function (e) {
$('.sidebar').toggleClass('open');
Expand Down
Loading