Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/greenhouse fix #256

Merged
merged 14 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
579 changes: 311 additions & 268 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@eightshift/frontend-libs": "^7.0.0",
"@eightshift/frontend-libs": "^7.1.0",
"autosize": "^5.0.1",
"choices.js": "^10.1.0",
"dropzone": "^6.0.0-beta.1"
Expand Down
9 changes: 8 additions & 1 deletion src/AdminMenus/FormGlobalSettingsAdminSubMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;
use EightshiftForms\Helpers\Helper;
use EightshiftForms\Settings\GlobalSettings\SettingsGlobalInterface;
use EightshiftForms\Settings\Settings\SettingsAll;
use EightshiftForms\Settings\Settings\SettingsGeneral;
use EightshiftFormsVendor\EightshiftLibs\AdminMenus\AbstractAdminSubMenu;

Expand Down Expand Up @@ -173,13 +174,19 @@ protected function processAttributes($attr): array
{
$type = isset($_GET['type']) ? \sanitize_text_field(\wp_unslash($_GET['type'])) : SettingsGeneral::SETTINGS_TYPE_KEY; // phpcs:ignore WordPress.Security.NonceVerification.Recommended

$settingsSidebarOutput = [];
foreach ($this->settingsGlobal->getSettingsSidebar($type) as $item) {
$sidebarType = $item['type'] ?? SettingsAll::SETTINGS_SIEDBAR_TYPE_GENERAL;
$settingsSidebarOutput[$sidebarType][] = $item;
}

return [
// translators: %s replaces form title name.
'adminSettingsPageTitle' => \esc_html__('Settings', 'eightshift-forms'),
'adminSettingsSubTitle' => \esc_html__('These settings apply to all forms.', 'eightshift-forms'),
'adminSettingsBackLink' => Helper::getListingPageUrl(),
'adminSettingsLink' => Helper::getSettingsGlobalPageUrl(''),
'adminSettingsSidebar' => $this->settingsGlobal->getSettingsSidebar($type),
'adminSettingsSidebar' => $settingsSidebarOutput,
'adminSettingsForm' => $this->settingsGlobal->getSettingsForm($type),
'adminSettingsType' => $type,
'adminSettingsIsGlobal' => true,
Expand Down
9 changes: 8 additions & 1 deletion src/AdminMenus/FormSettingsAdminSubMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;
use EightshiftForms\Helpers\Helper;
use EightshiftForms\Settings\Settings\SettingsAll;
use EightshiftForms\Settings\Settings\SettingsAllInterface;
use EightshiftForms\Settings\Settings\SettingsGeneral;
use EightshiftFormsVendor\EightshiftLibs\AdminMenus\AbstractAdminSubMenu;
Expand Down Expand Up @@ -186,13 +187,19 @@ protected function processAttributes($attr): array
$formTitle = \esc_html__('No form title', 'eightshift-forms');
}

$settingsSidebarOutput = [];
foreach ($this->settingsAll->getSettingsSidebar($formId, $type) as $item) {
$sidebarType = $item['type'] ?? SettingsAll::SETTINGS_SIEDBAR_TYPE_GENERAL;
$settingsSidebarOutput[$sidebarType][] = $item;
}

return [
// translators: %s replaces the form name.
'adminSettingsPageTitle' => \sprintf(\esc_html__('Form settings: %s', 'eightshift-forms'), $formTitle),
'adminSettingsBackLink' => Helper::getListingPageUrl(),
'adminSettingsFormEditLink' => Helper::getFormEditPageUrl($formId),
'adminSettingsLink' => Helper::getSettingsPageUrl($formId, ''),
'adminSettingsSidebar' => $this->settingsAll->getSettingsSidebar($formId, $type),
'adminSettingsSidebar' => $settingsSidebarOutput,
'adminSettingsForm' => $this->settingsAll->getSettingsForm($formId, $type),
'adminSettingsType' => $type,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,26 @@

&__sidebar {
background-color: var(--global-colors-es-white);
height: 100vh;
overflow-x: hidden;

> * {
margin-bottom: var(--global-es-spacing-horizontal);
border-top: 1px solid var(--global-colors-es-ebb);

&:first-child {
border-top: 0;
}
}
}

&__sidebar-label {
padding: 1rem 1.1rem 0.5rem;
font-size: 1.1rem;
font-weight: bold;
line-height: 1.2;
}

&__main {
border-left: 1px solid var(--global-colors-es-ebb);

Expand Down Expand Up @@ -87,7 +101,7 @@
}

&:hover,
&:focus, {
&:focus {
color: var(--global-colors-es-matisse);
background-color: var(--global-colors-es-matisse-05);
}
Expand Down
38 changes: 14 additions & 24 deletions src/Blocks/components/admin-settings/admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

echo Components::outputCssVariablesGlobal(); // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped

$componentName = $manifest['componentName'] ?? '';
$componentClass = $manifest['componentClass'] ?? '';
$sectionClass = $manifestSection['componentClass'] ?? '';

Expand Down Expand Up @@ -47,30 +48,19 @@
</a>
</div>

<div class="<?php echo esc_attr("{$sectionClass}__section"); ?>">
<div class="<?php echo esc_attr("{$sectionClass}__content"); ?>">
<ul class="<?php echo esc_attr("{$sectionClass}__menu"); ?>">
<?php foreach ($adminSettingsSidebar as $item) { ?>
<?php
$label = $item['label'] ?? '';
$value = $item['value'] ?? '';
$icon = $item['icon'] ?? '';
?>
<li class="<?php echo esc_attr("{$sectionClass}__menu-item"); ?>">
<a
href="<?php echo esc_url("{$adminSettingsLink}&type={$value}"); ?>"
class="<?php echo esc_attr("{$sectionClass}__menu-link " . Components::selector($value === $adminSettingsType, $sectionClass, 'menu-link', 'active')); ?>"
>
<span class="<?php echo esc_attr("{$sectionClass}__menu-link-wrap"); ?>">
<?php echo $icon; // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped ?>
<?php echo esc_html($label); ?>
</span>
</a>
</li>
<?php } ?>
</ul>
</div>
</div>
<?php
echo Components::renderPartial( // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped
'component',
$componentName,
'sidebar-section',
[
'items' => $adminSettingsSidebar,
'sectionClass' => $sectionClass,
'adminSettingsLink' => $adminSettingsLink,
'adminSettingsType' => $adminSettingsType,
]
);
?>
</div>
<div class="<?php echo esc_attr("{$sectionClass}__main"); ?>">
<div class="<?php echo esc_attr("{$sectionClass}__section"); ?>">
Expand Down
75 changes: 75 additions & 0 deletions src/Blocks/components/admin-settings/partials/sidebar-section.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

/**
* Template for admin settings page - sidebar section partial.
*
* @package EightshiftForms\Blocks.
*/

use EightshiftForms\Settings\Settings\SettingsAll;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$items = $attributes['items'] ?? [];

$output = [];

if (!$items) {
return $output;
}

$sectionClass = $attributes['sectionClass'] ?? '';
$adminSettingsLink = $attributes['adminSettingsLink'] ?? '';
$adminSettingsType = $attributes['adminSettingsType'] ?? '';

// Provide order we want on output.
$sortOrder = SettingsAll::SIDEBAR_SORT_ORDER;
uksort($items, function ($key1, $key2) use ($sortOrder) {
return array_search($key1, $sortOrder, true) <=> array_search($key2, $sortOrder, true);
});

foreach ($items as $key => $innerItems) {
switch ($key) {
case SettingsAll::SETTINGS_SIEDBAR_TYPE_INTEGRATION:
$sidebarTitle = __('Integrations', 'eightshift-forms');
break;
case SettingsAll::SETTINGS_SIEDBAR_TYPE_TROUBLESHOOTING:
$sidebarTitle = __('Troubleshooting', 'eightshift-forms');
break;
case SettingsAll::SETTINGS_SIEDBAR_TYPE_DEVELOP:
$sidebarTitle = __('Develop Mode', 'eightshift-forms');
break;
default:
$sidebarTitle = __('General', 'eightshift-forms');
break;
}
?>

<div class="<?php echo esc_attr("{$sectionClass}__section"); ?>">
<div class="<?php echo esc_attr("{$sectionClass}__content"); ?>">
<div class="<?php echo esc_attr("{$sectionClass}__sidebar-label"); ?>">
<?php echo esc_html($sidebarTitle); ?>
</div>
<ul class="<?php echo esc_attr("{$sectionClass}__menu"); ?>">
<?php foreach ($innerItems as $item) { ?>
<?php
$label = $item['label'] ?? '';
$value = $item['value'] ?? '';
$icon = $item['icon'] ?? '';
?>
<li class="<?php echo esc_attr("{$sectionClass}__menu-item"); ?>">
<a
href="<?php echo esc_url("{$adminSettingsLink}&type={$value}"); ?>"
class="<?php echo esc_attr("{$sectionClass}__menu-link " . Components::selector($value === $adminSettingsType, $sectionClass, 'menu-link', 'active')); ?>"
>
<span class="<?php echo esc_attr("{$sectionClass}__menu-link-wrap"); ?>">
<?php echo $icon; // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped ?>
<?php echo esc_html($label); ?>
</span>
</a>
</li>
<?php } ?>
</ul>
</div>
</div>

<?php }
5 changes: 5 additions & 0 deletions src/Blocks/components/form/assets-admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import domReady from '@wordpress/dom-ready';
import manifest from './../manifest.json';

domReady(() => {
if (typeof esFormsLocalization === 'undefined') {
throw 'Your project is missing the global "esFormsLocalization" variable called from the enqueue script.';
}

const {
componentJsClass,
componentCacheJsClass,
Expand All @@ -17,6 +21,7 @@ domReady(() => {
formSelector: selector,
formSubmitRestApiUrl: esFormsLocalization.formSettingsSubmitRestApiUrl,
formIsAdmin: true,
customFormParams: esFormsLocalization.customFormParams,
});

form.init();
Expand Down
Loading