diff --git a/src/dev-center/css/style.css b/src/dev-center/css/style.css index a5f23f6c89..184125f433 100644 --- a/src/dev-center/css/style.css +++ b/src/dev-center/css/style.css @@ -867,7 +867,7 @@ ol li:before { .reset-deploy{ color: #8a8a8a; font-size: 15px; - margin-top: 0; + margin-top:40px; } .reset-deploy:hover{ color: black; diff --git a/src/dev-center/js/dev-center.js b/src/dev-center/js/dev-center.js index 88ff3fa7b3..56660db0a3 100644 --- a/src/dev-center/js/dev-center.js +++ b/src/dev-center/js/dev-center.js @@ -289,6 +289,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 @@ -314,6 +316,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({ icon_size: 64 }).then(async (resp) => { apps = resp; @@ -561,8 +565,8 @@ function generate_edit_app_section(app) { -

A list of file type specifiers. For example if you include .txt your apps could be opened when a user clicks on a TXT file.

- +

A comma-separated list of file type specifiers. For example if you include .txt, your apps could be opened when a user clicks on a TXT file.

+

Window

@@ -904,7 +908,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 = `

index.html

Ready to deploy 🚀

Cancel

`; + drop_area_content = `

index.html

Ready to deploy 🚀

`; $('.drop-area').html(drop_area_content); // enable deploy button @@ -938,7 +942,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 = `

${items.length} items

Ready to deploy 🚀

Cancel

`; + drop_area_content = `

${items.length} items

Ready to deploy 🚀

`; $('.drop-area').html(drop_area_content); // enable deploy button @@ -979,7 +983,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 = `

${rootItems}

Ready to deploy 🚀

Cancel

`; + drop_area_content = `

${rootItems}

Ready to deploy 🚀

`; $('.drop-area').html(drop_area_content); // enable deploy button @@ -1053,7 +1057,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 = `

${rootItems}

Ready to deploy 🚀

Cancel

`; + drop_area_content = `

${rootItems}

Ready to deploy 🚀

`; $('.drop-area').html(drop_area_content); // enable deploy button @@ -1203,7 +1207,6 @@ $(document).on('click', '.edit-app-save-btn', async function (e) { icon = null; } } - // parse filetype_associations if(filetype_associations !== ''){ filetype_associations = JSON.parse(filetype_associations); @@ -1228,7 +1231,6 @@ $(document).on('click', '.edit-app-save-btn', async function (e) { } }).filter(Boolean); } - // error? if (error) { $('#edit-app-error').show(); @@ -1239,6 +1241,9 @@ $(document).on('click', '.edit-app-save-btn', async function (e) { // show working spinner puter.ui.showSpinner(); + + // parse filetype_associations + filetype_associations = filetype_associations.split(',').map(element => element.trim()); // disable submit button $('.edit-app-save-btn').prop('disabled', true); @@ -1763,130 +1768,14 @@ function sort_apps() { } } -/** - * Checks if the items being deployed contain a .git directory - * @param {Array|string} items - Items to check (can be path string or array of items) - * @returns {Promise} - True if .git directory is found - */ -async function hasGitDirectory(items) { - // Case 1: Single Puter path - if (typeof items === 'string' && (items.startsWith('/') || items.startsWith('~'))) { - const stat = await puter.fs.stat(items); - if (stat.is_dir) { - const files = await puter.fs.readdir(items); - return files.some(file => file.name === '.git' && file.is_dir); - } - return false; - } - - // Case 2: Array of Puter items - if (Array.isArray(items) && items[0]?.uid) { - return items.some(item => item.name === '.git' && item.is_dir); - } - - // Case 3: Local items (DataTransferItems) - if (Array.isArray(items)) { - for (let item of items) { - if (item.fullPath?.includes('/.git/') || - item.path?.includes('/.git/') || - item.filepath?.includes('/.git/')) { - return true; - } - } - } - - return false; -} - -/** - * Shows a warning dialog about .git directory deployment - * @returns {Promise} - True if the user wants to proceed with deployment - */ -async function showGitWarningDialog() { - try { - // Check if the user has chosen to skip the warning - const skipWarning = await puter.kv.get('skip-git-warning'); - - // Log retrieved value for debugging - console.log('Retrieved skip-git-warning:', skipWarning); - - // If the user opted to skip the warning, proceed without showing it - if (skipWarning === true) { - return true; - } - } catch (error) { - console.error('Error accessing KV store:', error); - // If KV store access fails, fall back to showing the dialog - } - - // Create the modal dialog - const modal = document.createElement('div'); - modal.innerHTML = ` -
-

Warning: Git Repository Detected

-

A .git directory was found in your deployment files. Deploying .git directories may:

-
    -
  • Expose sensitive information like commit history and configuration
  • -
  • Significantly increase deployment size
  • -
-
- - -
-
- - -
-
-
- `; - document.body.appendChild(modal); - - return new Promise((resolve) => { - // Handle "Continue Deployment" - document.getElementById('continue-deployment').addEventListener('click', async () => { - try { - const skipChecked = document.getElementById('skip-git-warning')?.checked; - if (skipChecked) { - console.log("Saving 'skip-git-warning' preference as true"); - await puter.kv.set('skip-git-warning', true); - } - } catch (error) { - console.error('Error saving user preference to KV store:', error); - } finally { - document.body.removeChild(modal); - resolve(true); // Continue deployment - } - }); - - // Handle "Cancel Deployment" - document.getElementById('cancel-deployment').addEventListener('click', () => { - document.body.removeChild(modal); - resolve(false); // Cancel deployment - }); - }); -} - window.deploy = async function (app, items) { - // Check for .git directory before proceeding - try { - if (await hasGitDirectory(items)) { - const shouldProceed = await showGitWarningDialog(); - if (!shouldProceed) { - reset_drop_area(); - return; - } - } - } catch (err) { - console.error('Error checking for .git directory:', err); - } let appdata_dir, current_app_dir; // disable deploy button $('.deploy-btn').addClass('disabled'); // change drop area text - $('.drop-area').html(deploying_spinner + '
Deploying (0%)
'); + $('.drop-area').html(deploying_spinner + '
Deploying (0%)

Cancel

'); if (typeof items === 'string' && (items.startsWith('/') || items.startsWith('~'))) { $('.drop-area').removeClass('drop-area-hover'); @@ -2257,7 +2146,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 = `

Ready to deploy 🚀

Cancel

`; + let drop_area_content = `

Ready to deploy 🚀

Cancel

`; $('.drop-area').html(drop_area_content); // deploy @@ -2699,9 +2588,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');