Remove database confirmation requirement for client environments in synchronization process
This commit eliminates the need for database name confirmation when syncing to client environments, simplifying the user experience. The `fxStaticSyncRequiresDbConfirm` function is removed, and related logic is adjusted in the synchronization workflow. Additionally, the user interface is updated to reflect these changes, providing clearer messaging about the synchronization process and reinforcing the read-only nature of the client production environment.
This commit is contained in:
@ -249,11 +249,6 @@ function fxStaticSyncWriteAllowed($strEnvId) {
|
||||
return $strEnvId !== 'client_prod';
|
||||
}
|
||||
|
||||
/** Environnements client : confirmation renforcée (nom de BD à retaper). */
|
||||
function fxStaticSyncRequiresDbConfirm($strEnvId) {
|
||||
return ($strEnvId === 'client_preprod' || $strEnvId === 'client_prod');
|
||||
}
|
||||
|
||||
function fxStaticSyncFinalizeCompareResult(array $tabCmp) {
|
||||
if (in_array($tabCmp['status'], array('missing_table', 'schema_mismatch', 'no_connection'), true)) {
|
||||
return $tabCmp;
|
||||
|
||||
@ -42,20 +42,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
|
||||
} elseif (!fxStaticSyncWriteAllowed($strEnvId)) {
|
||||
$strFlash = 'Sync désactivée vers client prod — comparaison seule.';
|
||||
$strFlashType = 'bad';
|
||||
} elseif (fxStaticSyncRequiresDbConfirm($strEnvId)) {
|
||||
$strConfirmDb = trim($_POST['confirm_db'] ?? '');
|
||||
$strExpectedDb = $tabEnv['config']['db'] ?? '';
|
||||
if ($strConfirmDb !== $strExpectedDb) {
|
||||
$strFlash = 'Sync annulée — nom de base incorrect (attendu : ' . $strExpectedDb . ').';
|
||||
$strFlashType = 'bad';
|
||||
} else {
|
||||
$blnDbConfirmed = true;
|
||||
}
|
||||
} else {
|
||||
$blnDbConfirmed = true;
|
||||
}
|
||||
|
||||
if (!empty($blnDbConfirmed)) {
|
||||
$tabConnections = fxStaticSyncOpenConnections();
|
||||
$objSource = $tabConnections['dev_preprod'];
|
||||
$objTarget = $tabConnections[$strEnvId];
|
||||
@ -141,10 +128,8 @@ if ($strDetailTable !== '' && $strDetailEnv !== '') {
|
||||
<h1>Sync tables statiques</h1>
|
||||
<div class="warn-box">
|
||||
<strong>Attention — opération destructive.</strong>
|
||||
Sync = <code>DELETE</code> puis recopie complète depuis dev préprod.
|
||||
<strong>Client prod : lecture seule</strong> (aucun bouton Sync).
|
||||
Client préprod : confirmation avec le nom exact de la base.
|
||||
Structures non alignées : corriger via Navicat avant toute sync.
|
||||
Sync = recopie complète depuis dev préprod (efface la cible).
|
||||
<strong>Client prod : lecture seule.</strong> Un clic sur Sync — pas de confirmation à taper.
|
||||
</div>
|
||||
<p class="sub">
|
||||
Source de vérité : <strong>dev préprod</strong> (<code><?php echo ssEsc($arrConDatabasePreProd['db'] ?? ''); ?></code>).
|
||||
@ -198,7 +183,6 @@ if ($strDetailTable !== '' && $strDetailEnv !== '') {
|
||||
}
|
||||
$strClass = fxStaticSyncStatusClass($tabCmp['status']);
|
||||
$strLabel = fxStaticSyncStatusLabel($tabCmp['status'], $tabCmp);
|
||||
$strDbName = $tabEnv['config']['db'] ?? '';
|
||||
?>
|
||||
<td class="<?php echo ssEsc($strClass); ?>">
|
||||
<span class="badge"><?php echo ssEsc($strLabel); ?></span>
|
||||
@ -218,12 +202,7 @@ if ($strDetailTable !== '' && $strDetailEnv !== '') {
|
||||
<a class="btn" href="?detail_table=<?php echo urlencode($tabDef['table']); ?>&detail_env=<?php echo urlencode($strEnvId); ?>">Détails</a>
|
||||
<?php } ?>
|
||||
<?php if ($tabCmp['status'] !== 'no_connection' && $tabCmp['status'] !== 'schema_mismatch' && fxStaticSyncWriteAllowed($strEnvId)) { ?>
|
||||
<form method="post" style="display:inline;" class="ss-sync-form"
|
||||
data-table="<?php echo ssEsc($tabDef['table']); ?>"
|
||||
data-label="<?php echo ssEsc($tabEnv['label']); ?>"
|
||||
data-db="<?php echo ssEsc($strDbName); ?>"
|
||||
data-env="<?php echo ssEsc($strEnvId); ?>"
|
||||
data-confirm-db="<?php echo fxStaticSyncRequiresDbConfirm($strEnvId) ? '1' : '0'; ?>">
|
||||
<form method="post" style="display:inline;">
|
||||
<input type="hidden" name="action" value="sync">
|
||||
<input type="hidden" name="csrf" value="<?php echo ssEsc($strCsrf); ?>">
|
||||
<input type="hidden" name="table" value="<?php echo ssEsc($tabDef['table']); ?>">
|
||||
@ -295,43 +274,4 @@ if ($strDetailTable !== '' && $strDetailEnv !== '') {
|
||||
<?php } ?>
|
||||
|
||||
</body>
|
||||
<script>
|
||||
(function () {
|
||||
document.querySelectorAll('.ss-sync-form').forEach(function (form) {
|
||||
form.addEventListener('submit', function (e) {
|
||||
var table = form.getAttribute('data-table');
|
||||
var label = form.getAttribute('data-label');
|
||||
var db = form.getAttribute('data-db');
|
||||
var env = form.getAttribute('data-env');
|
||||
var needDb = form.getAttribute('data-confirm-db') === '1';
|
||||
|
||||
var msg = 'DESTRUCTIF : effacer la table « ' + table + ' » sur '
|
||||
+ label + ' (' + db + ') et recopier depuis dev préprod ?';
|
||||
if (!window.confirm(msg)) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (needDb) {
|
||||
var typed = window.prompt(
|
||||
'Environnement client — tapez le nom EXACT de la base cible pour confirmer :',
|
||||
''
|
||||
);
|
||||
if (typed !== db) {
|
||||
window.alert('Nom de base incorrect. Sync annulée.');
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
var input = form.querySelector('input[name="confirm_db"]');
|
||||
if (!input) {
|
||||
input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = 'confirm_db';
|
||||
form.appendChild(input);
|
||||
}
|
||||
input.value = typed;
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user