Skip to content

Commit

Permalink
Merge pull request #218 from davseve/internal/ED-11261-one-click-clou…
Browse files Browse the repository at this point in the history
…d-release

Add default values to bump and get previous release
  • Loading branch information
davseve authored Aug 16, 2023
2 parents 823d565 + f7e7808 commit 9759cc3
Show file tree
Hide file tree
Showing 29 changed files with 1,271 additions and 307 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/bump-channel-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ inputs:
description: 'The postfix that will be added to the package version -rc / -test / empty.'
OVERRIDE_PACKAGE_VERSION:
required: false
description: 'Override the package version with a custom value for one click release process.'
default: false
description: 'Should override the PACKAGE_VERSION value with a custom value for the one click release process.'

runs:
using: "composite"
Expand All @@ -34,8 +35,9 @@ runs:
echo "ELEMENTOR_CHANNEL_PACKAGE_VERSION=${ELEMENTOR_CHANNEL_PACKAGE_VERSION}"
echo "NEW_CHANNEL_VERSION=${NEW_CHANNEL_VERSION}"
# Override PACKAGE_VERSION value is used in the one click release workflow to set the release and file names
# So that they contain ther postfix and bump version number.
# An overriden PACKAGE_VERSION value is used in the one click release workflow to set the release and file names
# So that they contain their postfix and bump version number.
# Should be unified with the code in get-new-package-version.
if [[ ${{ inputs.OVERRIDE_PACKAGE_VERSION }} == "true" ]]; then
echo "PACKAGE_VERSION=${ELEMENTOR_CHANNEL_PACKAGE_VERSION}${{inputs.POSTFIX}}" >> $GITHUB_ENV
fi
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/env-vars-configure/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inputs:
description: 'The ref to get the version from.'
POSTFIX:
required: false
description: 'The postfix that will be added to the package version -rc / -test / empty.'
description: 'The postfix that will be added to the package version -rc / -test / "" (empty string).'

runs:
using: "composite"
Expand All @@ -27,7 +27,7 @@ runs:
run: |
# This command retrieves the latest tag that matches the specified channel and package version,
# and extracts the version number from the tag name using awk. E.g. retrieves the number 7 from `3.11.0-cloud7`.
# If inputs.POSTFIX == '-test', than get the latest prerelease version E.g, `3.11.0-cloud7-test`
# If inputs.POSTFIX == '-test', then get the latest prerelease version E.g, `3.11.0-cloud7-test`
if [[ "${{ inputs.POSTFIX }}" == "-test" ]]; then
CURRENT_CHANNEL_VERSION=$(git ls-remote --tags | grep "\-test" | grep -v "refs/tags/v" | grep "${{ inputs.CHANNEL }}" | grep "${{ env.CLEAN_PACKAGE_VERSION }}" | tail -n1 | awk -F'${{ inputs.CHANNEL }}' '{print $2}' | awk -F'${{ inputs.POSTFIX }}' '{print $1}' || echo 0)
else
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/get-new-package-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
description: 'The channel to get the version to (ga, cloud, beta).'
POSTFIX:
required: false
description: 'The postfix that will be added to the package version -rc / -test / empty.'
description: 'The postfix that will be added to the package version -rc / -test / "" (empty string).'

runs:
using: "composite"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/get-previous-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ inputs:
description: "The channel to get the version to (ga, cloud, beta)."
POSTFIX:
required: false
description: "The postfix that will be added to the package version -rc / -test / empty."
default: ""
description: "The postfix that will be added to the package version -rc / -test / "" (empty string)."

runs:
using: "composite"
Expand Down
4 changes: 2 additions & 2 deletions assets/dev/js/editor/elements/views/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ const ContainerView = BaseElementView.extend( {
setTimeout( () => {
this.nestingLevel = this.getNestingLevel();
this.$el[ 0 ].dataset.nestingLevel = this.nestingLevel;

// Add the EmptyView to the end of the Grid Container on initial page load if there are already some widgets.
if ( this.isGridContainer() ) {
this.reInitEmptyView();
Expand Down Expand Up @@ -540,10 +539,11 @@ const ContainerView = BaseElementView.extend( {

handleGridEmptyView() {
const currentContainer = this.getCorrectContainerElement();
const emptyViewItem = currentContainer.find( '> .elementor-empty-view' );

this.moveElementToLastChild(
currentContainer,
currentContainer.find( '> .elementor-empty-view' ),
emptyViewItem,
);
},

Expand Down
2 changes: 1 addition & 1 deletion assets/dev/js/editor/regions/panel/edit-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ EditModeItemView = Marionette.ItemView.extend( {
},

onEditModeChanged( activeMode ) {
const ctrlLabel = environment.mac ? '⌘' : 'Ctrl';
const ctrlLabel = environment.mac ? '\u2318' : 'Ctrl';

let text = 'preview' === activeMode ? __( 'Show Panel', 'elementor' ) : __( 'Hide Panel', 'elementor' );
text += ` (${ ctrlLabel } + P)`;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import Base from '../base';

const directionNext = 'next',
directionPrevious = 'previous';

export default class NestedTitleKeyboardHandler extends Base {
getDefaultSettings() {
return {
selectors: {
itemTitle: '.e-n-tab-title',
$itemContainer: '.e-n-tabs-content > .e-con',
},
ariaAttributes: {
titleStateAttribute: 'aria-selected',
activeTitleSelector: '[aria-selected="true"]',
},
datasets: {
titleIndex: 'data-tab-index',
},
keyDirection: {
ArrowLeft: elementorFrontendConfig.is_rtl ? directionNext : directionPrevious,
ArrowUp: directionPrevious,
ArrowRight: elementorFrontendConfig.is_rtl ? directionPrevious : directionNext,
ArrowDown: directionNext,
},
};
}

getDefaultElements() {
const selectors = this.getSettings( 'selectors' );

return {
$itemTitles: this.findElement( selectors.itemTitle ),
$itemContainers: this.findElement( selectors.$itemContainer ),
};
}

/**
* @param {HTMLElement} itemTitleElement
*
* @return {string}
*/
getTitleIndex( itemTitleElement ) {
const { titleIndex: indexAttribute } = this.getSettings( 'datasets' );
return itemTitleElement.getAttribute( indexAttribute );
}

/**
* @param {string|number} titleIndex
*
* @return {string}
*/
getTitleFilterSelector( titleIndex ) {
const { titleIndex: indexAttribute } = this.getSettings( 'datasets' );
return `[${ indexAttribute }="${ titleIndex }"]`;
}

bindEvents() {
this.elements.$itemTitles.on( this.getTitleEvents() );
this.elements.$itemContainers.children().on( 'keydown', this.handleContentElementEscapeEvent.bind( this ) );
}

unbindEvents() {
this.elements.$itemTitles.off();
this.elements.$itemContainers.children().off();
}

handleTitleKeyboardNavigation( event ) {
const directionKeys = [ 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End' ],
activationKeys = [ 'Enter', 'Space' ];

if ( directionKeys.includes( event.key ) ) {
event.preventDefault();

const currentTitleIndex = parseInt( this.getTitleIndex( event.currentTarget ) ) || 1,
numberOfTitles = this.elements.$itemTitles.length,
titleIndexUpdated = this.getTitleIndexFocusUpdated( event, currentTitleIndex, numberOfTitles );

this.changeTitleFocus( currentTitleIndex, titleIndexUpdated );
} else if ( activationKeys.includes( event.key ) ) {
event.preventDefault();

const titleIndex = this.getTitleIndex( event.currentTarget );

elementorFrontend.elements.$window.trigger( 'elementor/nested-elements/activate-by-keyboard', titleIndex );
}
}

getTitleEvents() {
return {
keydown: this.handleTitleKeyboardNavigation.bind( this ),
};
}

getTitleIndexFocusUpdated( event, currentTitleIndex, numberOfTitles ) {
let titleIndexUpdated = 0;

switch ( event.key ) {
case 'Home':
titleIndexUpdated = 1;
break;
case 'End':
titleIndexUpdated = numberOfTitles;
break;
default:
const direction = this.getSettings( 'keyDirection' )[ event.key ],
directionValue = directionNext === direction ? 1 : -1,
isEndReached = numberOfTitles < currentTitleIndex + directionValue,
isStartReached = 0 === currentTitleIndex + directionValue;

if ( isEndReached ) {
titleIndexUpdated = 1;
} else if ( isStartReached ) {
titleIndexUpdated = numberOfTitles;
} else {
titleIndexUpdated = currentTitleIndex + directionValue;
}
}

return titleIndexUpdated;
}

changeTitleFocus( currentTitleIndex, titleIndexUpdated ) {
const $currentTitle = this.elements.$itemTitles.filter( this.getTitleFilterSelector( currentTitleIndex ) ),
$newTitle = this.elements.$itemTitles.filter( this.getTitleFilterSelector( titleIndexUpdated ) );

$currentTitle.attr( 'tabindex', '-1' );
$newTitle.attr( 'tabindex', '0' );
$newTitle.trigger( 'focus' );
}

handleContentElementEscapeEvent( event ) {
if ( 'Escape' !== event.key ) {
return;
}

const activeTitleFilter = this.getSettings( 'ariaAttributes' ).activeTitleSelector,
$activeTitle = this.elements.$itemTitles.filter( activeTitleFilter );

$activeTitle.trigger( 'focus' );
}
}
60 changes: 58 additions & 2 deletions assets/dev/js/frontend/handlers/container/grid-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ export default class GridContainer extends elementorModules.frontend.handlers.Ba
this.removeExistingOverlay();
this.createOverlayContainer();
this.createOverlayItems();

// Re-init empty view element after container layout change
const selectors = this.getSettings( 'selectors' );
this.elements.emptyView = this.findElement( selectors.emptyView )[ 0 ];
this.elements.emptyView.style.display = this.shouldRemoveEmptyView() ? 'none' : 'block';
}

shouldDrawOutline() {
Expand Down Expand Up @@ -93,8 +98,7 @@ export default class GridContainer extends elementorModules.frontend.handlers.Ba
createOverlayItems() {
const { gridOutline } = this.elements,
{ classes: { outlineItem } } = this.getDefaultSettings(),
{ rows, columns } = this.getDeviceGridDimensions(),
numberOfItems = rows.length * columns.length;
numberOfItems = this.getMaxOutlineElementsNumber();

for ( let i = 0; i < numberOfItems; i++ ) {
const gridOutlineItem = document.createElement( 'div' );
Expand Down Expand Up @@ -273,4 +277,56 @@ export default class GridContainer extends elementorModules.frontend.handlers.Ba

return ! numberPattern.test( gridRows?.size );
}

shouldRemoveEmptyView() {
const childrenLength = this.elements.outlineParentContainer.querySelectorAll( ':scope > .elementor-element' ).length;

if ( 0 === childrenLength ) {
return false;
}

const maxElements = this.getMaxElementsNumber();

return maxElements <= childrenLength && this.isFullFilled( childrenLength );
}

isFullFilled( numberOfElements ) {
const gridDimensions = this.getDeviceGridDimensions(),
{ grid_auto_flow: gridAutoFlow } = this.getElementSettings();

const flowTypeField = 'row' === gridAutoFlow ? 'columns' : 'rows';

return 0 === numberOfElements % gridDimensions[ flowTypeField ].length;
}

getMaxOutlineElementsNumber() {
const childrenLength = this.elements.outlineParentContainer.querySelectorAll( ':scope > .elementor-element' ).length,
gridDimensions = this.getDeviceGridDimensions(),
maxElementsBySettings = this.getMaxElementsNumber(),
{ grid_auto_flow: gridAutoFlow } = this.getElementSettings();

const flowTypeField = 'row' === gridAutoFlow ? 'columns' : 'rows';
const maxElementsByItems = Math.ceil( childrenLength / gridDimensions[ flowTypeField ].length ) * gridDimensions[ flowTypeField ].length;

return maxElementsBySettings > maxElementsByItems ? maxElementsBySettings : maxElementsByItems;
}

getMaxElementsNumber() {
const elementSettings = this.getElementSettings(),
device = elementor.channels.deviceMode.request( 'currentMode' ),
{ grid_auto_flow: gridAutoFlow } = this.getElementSettings(),
gridDimensions = this.getDeviceGridDimensions();

if ( 'row' === gridAutoFlow ) {
const rows = elementorFrontend.utils.controls.getResponsiveControlValue( elementSettings, 'grid_rows_grid', 'size', device );
const rowsLength = isNaN( rows ) ? rows.split( ' ' ).length : rows;

return gridDimensions.columns.length * rowsLength;
}

const columns = elementorFrontend.utils.controls.getResponsiveControlValue( elementSettings, 'grid_columns_grid', 'size', device );
const columnsLength = isNaN( columns ) ? rows.split( ' ' ).length : columns;

return gridDimensions.rows.length * columnsLength;
}
}
2 changes: 2 additions & 0 deletions assets/dev/js/frontend/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CarouselBase from './handlers/base-carousel';
import NestedTabs from 'elementor/modules/nested-tabs/assets/js/frontend/handlers/nested-tabs';
import NestedTabsHtml from 'elementor/modules/nested-tabs-html/assets/js/frontend/handlers/nested-tabs-html';
import NestedAccordion from 'elementor/modules/nested-accordion/assets/js/frontend/handlers/nested-accordion';
import NestedTitleKeyboardHandler from './handlers/accessibility/nested-title-keyboard-handler';

elementorModules.frontend = {
Document,
Expand All @@ -22,5 +23,6 @@ elementorModules.frontend = {
NestedTabs,
NestedTabsHtml,
NestedAccordion,
NestedTitleKeyboardHandler,
},
};
Loading

0 comments on commit 9759cc3

Please sign in to comment.