Skip to content

Commit

Permalink
Fix wizard checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mreid-tt committed Oct 22, 2023
1 parent 13d8fda commit 8434e09
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 34 deletions.
114 changes: 80 additions & 34 deletions spk/owncloud/src/wizard_templates/install_uifile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,31 @@ page_append ()
fi
}

RESTORE_BACKUP_FILE="wizard_owncloud_restore"
BACKUP_FILE_PATH="wizard_backup_file"
ERROR_TEXT="{{{OWNCLOUD_BACKUP_FILE_VALIDATION_ERROR_TEXT}}}"

checkBackupFile()
{
CHECK_BACKUP_FILE=$(/bin/cat<<EOF
{
var backupFileCheck = arguments[0];
var step = arguments[2];
var fileRestore = step.getComponent("${RESTORE_BACKUP_FILE}");
if (fileRestore.checked) {
if (backupFileCheck === "") {
return "${ERROR_TEXT}";
} else {
return true;
}
} else {
return true;
}
}
EOF
)
echo "$CHECK_BACKUP_FILE" | quote_json
}

getBackupFile()
{
Expand All @@ -33,62 +57,85 @@ getBackupFile()
var filePath = step.getComponent("${BACKUP_FILE_PATH}");
if (backupFile) {
filePath.setDisabled(false);
return true;
} else {
filePath.setDisabled(true);
return true;
}
return true;
}
EOF
)
echo "$BACKUP_FILE" | quote_json
}

jsFunction=$(/bin/cat<<EOF
function findStepByTitle(wizardDialog, title) {
for (var i = wizardDialog.customuiIds.length - 1 ; i >= 0 ; i--) {
var step = wizardDialog.getStep(wizardDialog.customuiIds[i]);
if (title === step.headline) {
return step;
}
}
return null;
}
function isRestoreChecked(wizardDialog) {
var restoreStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_INSTALL_RESTORE_STEP_TITLE}}}");
if (!restoreStep) {
return false;
} else {
return restoreStep.items.items[1].checked;
}
}
function findStepByTitle(wizardDialog, title) {
for (var i = wizardDialog.customuiIds.length - 1 ; i >= 0 ; i--) {
var step = wizardDialog.getStep(wizardDialog.customuiIds[i]);
if (title === step.headline) {
return step;
}
}
return null;
}
function isRestoreChecked(wizardDialog) {
var restoreStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_INSTALL_RESTORE_STEP_TITLE}}}");
if (!restoreStep) {
return false;
} else {
return restoreStep.getComponent("${RESTORE_BACKUP_FILE}").checked;
}
}
EOF
)

getActiveate()
{
ACTIVAETE=$(/bin/cat<<EOF
{
${jsFunction}
var currentStep = arguments[0];
var wizardDialog = currentStep.owner;
var restoreStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_INSTALL_RESTORE_STEP_TITLE}}}");
var adminStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_ADMIN_CONFIGURATION_STEP_TITLE}}}");
var domainStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_TRUSTED_DOMAINS_STEP_TITLE}}}");
var checked = isRestoreChecked(wizardDialog);
adminStep.items.items[0].setVisible(!checked);
adminStep.items.items[1].setVisible(!checked);
domainStep.items.items[0].setVisible(!checked);
${jsFunction}
var currentStep = arguments[0];
var wizardDialog = currentStep.owner;
var restoreStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_INSTALL_RESTORE_STEP_TITLE}}}");
var adminStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_ADMIN_CONFIGURATION_STEP_TITLE}}}");
var domainStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_TRUSTED_DOMAINS_STEP_TITLE}}}");
var checked = isRestoreChecked(wizardDialog);
if (checked) {
wizardDialog.goBack(restoreStep.itemId);
wizardDialog.goNext("applyStep");
}
}
EOF
)
echo "$ACTIVAETE" | quote_json
}

getDeActiveate()
{
DEACTIVAETE=$(/bin/cat<<EOF
{
${jsFunction}
var currentStep = arguments[0];
var wizardDialog = currentStep.owner;
var restoreStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_INSTALL_RESTORE_STEP_TITLE}}}");
var adminStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_ADMIN_CONFIGURATION_STEP_TITLE}}}");
var domainStep = findStepByTitle(wizardDialog, "{{{OWNCLOUD_TRUSTED_DOMAINS_STEP_TITLE}}}");
var checked = isRestoreChecked(wizardDialog);
if (checked) {
currentStep.nextId = "applyStep";
} else {
currentStep.nextId = adminStep.itemId;
}
}
EOF
)
echo "$ACTIVAETE" | quote_json
echo "$DEACTIVAETE" | quote_json
}

PAGE_ADMIN_CONFIG=$(/bin/cat<<EOF
{
"step_title": "{{{OWNCLOUD_INSTALL_RESTORE_STEP_TITLE}}}",
"invalid_next_disabled_v2": true,
"deactivate_v2": "$(getDeActiveate)",
"items": [{
"type": "singleselect",
"desc": "{{{OWNCLOUD_INSTALL_RESTORE_DESCRIPTION}}}",
Expand All @@ -97,7 +144,7 @@ PAGE_ADMIN_CONFIG=$(/bin/cat<<EOF
"desc": "{{{OWNCLOUD_INSTALL_LABEL}}}",
"defaultValue": true
}, {
"key": "wizard_owncloud_restore",
"key": "${RESTORE_BACKUP_FILE}",
"desc": "{{{OWNCLOUD_RESTORE_LABEL}}}",
"defaultValue": false,
"validator": {
Expand All @@ -113,7 +160,7 @@ PAGE_ADMIN_CONFIG=$(/bin/cat<<EOF
"disabled": true,
"emptyText": "${SYNOPKG_PKGDEST_VOL}/${SYNOPKG_PKGNAME}/backup",
"validator": {
"allowBlank": true
"fn": "$(checkBackupFile)"
}
}]
}, {
Expand All @@ -135,7 +182,7 @@ PAGE_ADMIN_CONFIG=$(/bin/cat<<EOF
}, {
"step_title": "{{{OWNCLOUD_ADMIN_CONFIGURATION_STEP_TITLE}}}",
"invalid_next_disabled_v2": true,
"activeate": "$(getActiveate)",
"activate_v2": "$(getActiveate)",
"items": [{
"type": "textfield",
"desc": "{{{OWNCLOUD_ADMIN_USER_NAME_DESCRIPTION}}}",
Expand All @@ -161,7 +208,6 @@ PAGE_ADMIN_CONFIG=$(/bin/cat<<EOF
}]
}, {
"step_title": "{{{OWNCLOUD_TRUSTED_DOMAINS_STEP_TITLE}}}",
"activeate": "$(getActiveate)",
"items": [{
"type": "textfield",
"desc": "{{{OWNCLOUD_TRUSTED_DOMAINS_DESCRIPTION}}}",
Expand Down
1 change: 1 addition & 0 deletions spk/owncloud/src/wizard_templates/install_uifile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ OWNCLOUD_INSTALL_LABEL: "Install new deployment"
OWNCLOUD_RESTORE_LABEL: "Restore from archive"
OWNCLOUD_BACKUP_FILE_LOCATION_DESCRIPTION: "Please provide the complete path to the archive you wish to restore."
OWNCLOUD_BACKUP_FILE_LOCATION_LABEL: "Backup file location"
OWNCLOUD_BACKUP_FILE_VALIDATION_ERROR_TEXT: "An empty file path is not allowed when restore is enabled."
OWNCLOUD_DATA_DIRECTORY_DESCRIPTION: "ownCloud data directory"
OWNCLOUD_DATA_DIRECTORY_LABEL: "Share name"
OWNCLOUD_DATA_DIRECTORY_VALIDATION_ERROR_TEXT: "Subdirectories are not supported."
Expand Down
1 change: 1 addition & 0 deletions spk/owncloud/src/wizard_templates/install_uifile_fre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ OWNCLOUD_INSTALL_LABEL: "Installer un nouveau déploiement"
OWNCLOUD_RESTORE_LABEL: "Restaurer à partir d'une archive"
OWNCLOUD_BACKUP_FILE_LOCATION_DESCRIPTION: "Veuillez fournir le chemin complet de l'archive que vous souhaitez restaurer."
OWNCLOUD_BACKUP_FILE_LOCATION_LABEL: "Emplacement du fichier de sauvegarde"
OWNCLOUD_BACKUP_FILE_VALIDATION_ERROR_TEXT: "Un chemin de fichier vide n'est pas autorisé lorsque la restauration est activée."
OWNCLOUD_DATA_DIRECTORY_DESCRIPTION: "Répertoire de données ownCloud"
OWNCLOUD_DATA_DIRECTORY_LABEL: "Partager le nom"
OWNCLOUD_DATA_DIRECTORY_VALIDATION_ERROR_TEXT: "Les sous-répertoires ne sont pas pris en charge."
Expand Down

0 comments on commit 8434e09

Please sign in to comment.