forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
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 PrestaShop#37580 from boherm/merge-9.0.x-into-develop
Merge `9.0.x` into `develop`
- Loading branch information
Showing
217 changed files
with
11,364 additions
and
7,680 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
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
47 changes: 47 additions & 0 deletions
47
.github/workflows/verify_autoupgrade_label_and_approvals.yml
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Verify 'Needs autoupgrade PR' label and approvals | ||
|
||
on: | ||
pull_request_review: | ||
types: [ submitted ] | ||
|
||
jobs: | ||
check_label_and_appoval: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Check if comment already exist | ||
id: check_comment | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
PR_NUMBER=$(jq --raw-output .pull_request.number < $GITHUB_EVENT_PATH) | ||
COMMENTS=$(gh api repos/${{ github.repository }}/issues/$PR_NUMBER/comments --jq '.[].body') | ||
if echo "$COMMENTS" | grep -q "This means that the changes made in your PR must also be reported in the Autoupgrade module"; then | ||
echo "comment_exists=true" >> $GITHUB_ENV | ||
fi | ||
- name: Verify approvals and label | ||
id: check_approvals_and_labels | ||
if: ${{ !env.comment_exists }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
LABELS: Needs autoupgrade PR | ||
run: | | ||
PR_NUMBER=$(jq --raw-output .pull_request.number < $GITHUB_EVENT_PATH) | ||
APPROVAL_COUNT=$(gh api repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews \ | ||
--jq '[.[] | select(.state == "APPROVED")] | length') | ||
LABEL_PRESENT=$(gh api repos/${{ github.repository }}/issues/$PR_NUMBER/labels \ | ||
--jq '[.[] | select(.name == "${{ env.LABELS }}")] | length') | ||
echo $APPROVAL_COUNT > ./approvals | ||
echo $LABEL_PRESENT > ./label | ||
- name: Upload | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: approval_count | ||
path: | | ||
approvals | ||
label |
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
107 changes: 107 additions & 0 deletions
107
admin-dev/themes/new-theme/js/pages/alias/components/aliases-collection-manager.ts
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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <[email protected]> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
import AliasFormMap from '@pages/alias/form/alias-form.map'; | ||
|
||
const {$} = window; | ||
|
||
/** | ||
* This component is used in alias form page to manage the behavior of the aliases collection. | ||
*/ | ||
export default class AliasesCollectionManager { | ||
$collection: JQuery; | ||
|
||
idxAlias: number; | ||
|
||
constructor() { | ||
// Get dom element of the collection | ||
this.$collection = $(AliasFormMap.aliasesCollection); | ||
this.idxAlias = this.$collection.children(AliasFormMap.aliasItem).length; | ||
// Initialize listeners | ||
this.initListeners(); | ||
// If we have no alias, we add one | ||
if (this.$collection.children().length === 0) { | ||
this.onAddAlias(null, false); | ||
} | ||
} | ||
|
||
// Initialize listeners to manage the collection properly. | ||
private initListeners(): void { | ||
this.$collection.parent().on('click', AliasFormMap.addAliasButton, (e: Event) => this.onAddAlias(e)); | ||
this.$collection.on('click', AliasFormMap.deleteAliasButton, (e: Event) => this.onDeleteAlias(e)); | ||
this.$collection.on('keydown', AliasFormMap.aliasItemInput, (e: Event) => this.onKeyDownAlias(e as KeyboardEvent)); | ||
} | ||
|
||
// On click in add alias button | ||
private onAddAlias(e: Event|null = null, needFocus: boolean = true): void { | ||
if (e) { | ||
e.preventDefault(); | ||
} | ||
// +1 idx | ||
this.idxAlias += 1; | ||
// Retrieve the prototype and format it | ||
let prototype = this.$collection.data('prototype'); | ||
prototype = prototype.replace(/__name__/g, this.idxAlias); | ||
// Then, add it at the bottom of the collection | ||
this.$collection.append(prototype); | ||
// We set active to true on the added alias | ||
this.$collection.children().last().find('[name$="[active]"][value=1]').prop('checked', true); | ||
// We set focus on last added input if needed | ||
if (needFocus) { | ||
this.$collection.children().last().find(AliasFormMap.aliasItemInput).focus(); | ||
} | ||
// Check if we need to display delete buttons or not | ||
this.refreshDeleteAliasButtons(); | ||
} | ||
|
||
// On click on delete alias button | ||
private onDeleteAlias(e: Event): void { | ||
e.preventDefault(); | ||
// Remove the alias element related to this button | ||
const $item = $(e.target as HTMLElement); | ||
$item.parents(AliasFormMap.aliasItem).remove(); | ||
// Check if we need to display delete buttons or not | ||
this.refreshDeleteAliasButtons(); | ||
} | ||
|
||
// On key down in alias item input => if it's a comma (and the value is already set), add a new alias and focus on new input | ||
private onKeyDownAlias(e: KeyboardEvent): void { | ||
if (e.key === ',') { | ||
e.preventDefault(); | ||
if (this.$collection.children().last().find('input').val() !== '') { | ||
this.onAddAlias(e); | ||
} | ||
} | ||
} | ||
|
||
// Check if we need to display delete buttons or not (if there is only one alias, we hide the delete buttons) | ||
private refreshDeleteAliasButtons(): void { | ||
if (this.$collection.children().length === 1) { | ||
this.$collection.children().find(AliasFormMap.deleteAliasButton).addClass('d-none'); | ||
} else { | ||
this.$collection.children().find(AliasFormMap.deleteAliasButton).removeClass('d-none'); | ||
} | ||
} | ||
}; |
32 changes: 32 additions & 0 deletions
32
admin-dev/themes/new-theme/js/pages/alias/form/alias-form.map.ts
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to [email protected] so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <[email protected]> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
export default { | ||
aliasesCollection: '.js-aliases-collection', | ||
addAliasButton: '.js-btn-add-alias', | ||
deleteAliasButton: '.js-btn-delete-alias', | ||
aliasItem: '.alias-item', | ||
aliasItemInput: '.form-control[name$="[alias]"]', | ||
}; |
Oops, something went wrong.