-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #951 from ga-devfront/feat/continue-version-choice
[NEW UI] finish front version choice
- Loading branch information
Showing
44 changed files
with
562 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,5 @@ | ||
#!/bin/bash | ||
|
||
if [[ $CHANNEL == "local" ]]; then | ||
if [[ "${FROM:0:1}" == 1 ]] && [[ "${VERSION:0:1}" == 1 ]]; then | ||
if [[ "${FROM:2:1}" == "${VERSION:2:1}" ]]; then | ||
UPDATE_THEME=0 | ||
else | ||
UPDATE_THEME=1 | ||
fi | ||
else | ||
if [[ "${FROM:0:1}" == "${VERSION:0:1}" ]]; then | ||
UPDATE_THEME=0 | ||
else | ||
UPDATE_THEME=1 | ||
fi | ||
fi | ||
|
||
docker exec -u www-data prestashop_autoupgrade mkdir admin-dev/autoupgrade/download | ||
docker exec -u www-data prestashop_autoupgrade curl -L $ARCHIVE_URL -o admin-dev/autoupgrade/download/prestashop.zip | ||
docker exec -u www-data prestashop_autoupgrade curl -L $XML_URL -o modules/autoupgrade/download/prestashop.xml | ||
|
||
FILE_COUNT=$(docker exec -u www-data prestashop_autoupgrade ls admin-dev/autoupgrade/backup/ | wc -l) | ||
if [[ "$FILE_COUNT" == 0 ]]; then | ||
docker exec -u www-data prestashop_autoupgrade php modules/autoupgrade/bin/console backup:create admin-dev | ||
fi | ||
|
||
echo "{\"channel\":\"local\",\"archive_prestashop\":\"prestashop.zip\",\"archive_num\":\"${VERSION}\", \"archive_xml\":\"prestashop.xml\", \"PS_AUTOUP_CHANGE_DEFAULT_THEME\":${UPDATE_THEME}" > modules/autoupgrade/config.json | ||
docker exec -u www-data prestashop_autoupgrade php modules/autoupgrade/bin/console update:start --action="CompareReleases" --config-file-path="modules/autoupgrade/config.json" admin-dev | ||
docker exec -u www-data prestashop_autoupgrade php modules/autoupgrade/bin/console update:start --config-file-path="modules/autoupgrade/config.json" admin-dev | ||
fi | ||
|
||
docker exec -u www-data prestashop_autoupgrade php modules/autoupgrade/bin/console backup:create admin-dev | ||
docker exec -u www-data prestashop_autoupgrade php modules/autoupgrade/bin/console update:start --action="CompareReleases" admin-dev | ||
docker exec -u www-data prestashop_autoupgrade php modules/autoupgrade/bin/console update:start admin-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,178 @@ | ||
import UpdatePage from './UpdatePage'; | ||
import api from '../api/RequestHandler'; | ||
import Hydration from '../utils/Hydration'; | ||
|
||
export default class UpdatePageVersionChoice extends UpdatePage { | ||
protected stepCode = 'version-choice'; | ||
private radioLoadingClass = 'radio--show-requirements-loader'; | ||
|
||
constructor() { | ||
super(); | ||
} | ||
|
||
public mount() { | ||
public mount = () => { | ||
this.initStepper(); | ||
if (!this.form) return; | ||
|
||
this.form.addEventListener('change', this.saveForm.bind(this)); | ||
this.form.addEventListener('submit', this.handleSubmit); | ||
|
||
this.onlineCardParent?.addEventListener(Hydration.hydrationEventName, this.handleHydrate); | ||
this.localCardParent?.addEventListener(Hydration.hydrationEventName, this.handleHydrate); | ||
|
||
this.toggleNextButton(); | ||
this.addListenerToCheckRequirementsAgainButtons(); | ||
}; | ||
|
||
public beforeDestroy = () => { | ||
if (!this.form) return; | ||
this.form.removeEventListener('change', this.saveForm); | ||
this.form.removeEventListener('submit', this.handleSubmit); | ||
this.onlineCardParent?.removeEventListener(Hydration.hydrationEventName, this.toggleNextButton); | ||
this.localCardParent?.removeEventListener(Hydration.hydrationEventName, this.toggleNextButton); | ||
this.checkRequirementsAgainButtons?.forEach((element) => { | ||
element.removeEventListener('click', this.saveForm); | ||
}); | ||
}; | ||
|
||
private sendForm = (routeToSend: string) => { | ||
const formData = new FormData(this.form!); | ||
api.post(routeToSend, formData); | ||
}; | ||
|
||
private addListenerToCheckRequirementsAgainButtons = () => { | ||
if (this.checkRequirementsAgainButtons?.length) { | ||
this.checkRequirementsAgainButtons.forEach((element) => { | ||
element.addEventListener('click', this.saveForm); | ||
}); | ||
} | ||
}; | ||
|
||
private handleHydrate = () => { | ||
this.toggleNextButton(); | ||
this.addListenerToCheckRequirementsAgainButtons(); | ||
}; | ||
|
||
private toggleNextButton = () => { | ||
if (this.currentChannelRequirementsAreOk) { | ||
this.submitButton?.removeAttribute('disabled'); | ||
} else { | ||
this.submitButton?.setAttribute('disabled', 'true'); | ||
} | ||
}; | ||
|
||
private saveForm = () => { | ||
const routeToSave = this.form!.dataset.routeToSave; | ||
|
||
if (!routeToSave) { | ||
throw new Error('No route to save form provided. Impossible to save form.'); | ||
} | ||
|
||
let currentInputCheck = null; | ||
|
||
if (this.onlineInputIsChecked) { | ||
currentInputCheck = this.onlineInputElement!; | ||
} | ||
|
||
if (this.localInputIsCheckAndFullFilled) { | ||
currentInputCheck = this.localInputElement!; | ||
} | ||
|
||
if (currentInputCheck) { | ||
currentInputCheck.removeAttribute('data-requirements-are-ok'); | ||
this.toggleNextButton(); | ||
currentInputCheck.classList.add(this.radioLoadingClass); | ||
this.sendForm(routeToSave); | ||
} | ||
}; | ||
|
||
private handleSubmit = (event: Event) => { | ||
event.preventDefault(); | ||
const routeToSubmit = this.form!.dataset.routeToSubmit; | ||
|
||
if (!routeToSubmit) { | ||
throw new Error('No route to submit form provided. Impossible to submit form.'); | ||
} | ||
|
||
this.sendForm(routeToSubmit); | ||
}; | ||
|
||
// global form | ||
private get form(): HTMLFormElement | null { | ||
return document.forms.namedItem('version_choice'); | ||
} | ||
|
||
private get submitButton(): HTMLButtonElement | undefined { | ||
return this.form | ||
? (Array.from(this.form.elements).find( | ||
(element) => element instanceof HTMLButtonElement && element.type === 'submit' | ||
) as HTMLButtonElement | undefined) | ||
: undefined; | ||
} | ||
|
||
private get currentChannelRequirementsAreOk(): boolean { | ||
if (this.onlineInputIsChecked) { | ||
return this.onlineInputElement!.dataset.requirementsAreOk === '1'; | ||
} | ||
if (this.localInputIsCheckAndFullFilled) { | ||
return this.localInputElement!.dataset.requirementsAreOk === '1'; | ||
} | ||
return false; | ||
} | ||
|
||
private get checkRequirementsAgainButtons(): HTMLButtonElement[] | undefined { | ||
return this.form | ||
? (Array.from(this.form.elements).filter( | ||
(element): element is HTMLButtonElement => | ||
element instanceof HTMLButtonElement && | ||
element.dataset.action === 'check-requirements-again' | ||
) as HTMLButtonElement[]) | ||
: undefined; | ||
} | ||
|
||
// online option | ||
private get onlineCardParent(): HTMLDivElement | undefined { | ||
return document.getElementById('radio_card_online') as HTMLDivElement | undefined; | ||
} | ||
|
||
private get onlineInputElement(): HTMLInputElement | undefined { | ||
return this.form?.elements.namedItem('online') as HTMLInputElement | undefined; | ||
} | ||
|
||
private get onlineInputIsChecked(): boolean { | ||
return (this.onlineInputElement && this.onlineInputElement.checked) || false; | ||
} | ||
|
||
// local option | ||
private get localCardParent(): HTMLDivElement | undefined { | ||
return document.getElementById('radio_card_archive') as HTMLDivElement | undefined; | ||
} | ||
|
||
private get localInputElement(): HTMLInputElement | undefined { | ||
return this.form?.elements.namedItem('local') as HTMLInputElement | undefined; | ||
} | ||
|
||
private get localInputIsChecked(): boolean { | ||
return this.localInputElement?.checked || false; | ||
} | ||
|
||
private get archiveZipSelectElement(): HTMLSelectElement | undefined { | ||
return this.form?.elements.namedItem('archive_zip') as HTMLSelectElement | undefined; | ||
} | ||
|
||
private get archiveZipIsFilled(): boolean { | ||
return !!this.archiveZipSelectElement?.value; | ||
} | ||
|
||
private get archiveXmlSelectElement(): HTMLSelectElement | undefined { | ||
return this.form!.elements.namedItem('archive_xml') as HTMLSelectElement | undefined; | ||
} | ||
|
||
private get archiveXmlIsFilled(): boolean { | ||
return (this.archiveXmlSelectElement && !!this.archiveXmlSelectElement.value) || false; | ||
} | ||
|
||
private get localInputIsCheckAndFullFilled(): boolean { | ||
return this.localInputIsChecked && this.archiveZipIsFilled && this.archiveXmlIsFilled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.