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

IBX-976: Disabled transition for side menu after reload page #1893

Conversation

lucasOsti
Copy link
Contributor

Question Answer
Tickets https://issues.ibexa.co/browse/IBX-976
Bug fix? no
New feature? no
BC breaks? no
Tests pass? no
Doc needed? no
License GPL-2.0

Checklist:

  • Coding standards ($ composer fix-cs)
  • Ready for Code Review

@lucasOsti lucasOsti force-pushed the IBX-976-Disabled-transition-after-reload-side-menu branch from 999dcd6 to 05c7619 Compare September 9, 2021 13:31
@lucasOsti lucasOsti force-pushed the IBX-976-Disabled-transition-after-reload-side-menu branch from 05c7619 to d51a558 Compare September 9, 2021 16:02
const expiryDaysInMiliseconds = expiryDays * 24 * 60 * 60 * 1000;

date.setTime(date.getTime() + expiryDaysInMiliseconds);
doc.cookie = `${name}=${value};expires=${date.toUTCString()};path=${path}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to use max-age instead of expires?

doc.cookie = `${name}=${value};expires=${date.toUTCString()};path=${path}`;
};
const getCookie = (name) => {
let cookieName = name + '=';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let cookieName = name + '=';
const cookieName = name + '=';

};
const getCookie = (name) => {
let cookieName = name + '=';
let decodedCookie = decodeURIComponent(doc.cookie);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let decodedCookie = decodeURIComponent(doc.cookie);
const decodedCookie = decodeURIComponent(doc.cookie);

const getCookie = (name) => {
let cookieName = name + '=';
let decodedCookie = decodeURIComponent(doc.cookie);
let cookiesArray = decodedCookie.split(';');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let cookiesArray = decodedCookie.split(';');
const cookiesArray = decodedCookie.split(';');

let cookieValue = null;

cookiesArray.forEach((cookie) => {
cookie = cookie.trim();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is a lot of assignment for cookie which is function param, I don't think this is best practice.

@@ -1,6 +1,11 @@
{% extends '@ezdesign/ui/menu/main_base.html.twig' %}

{% block root %}
{% set resizerWidth = 10 %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should snake not camelCase in twig.

@lucasOsti lucasOsti force-pushed the IBX-976-Disabled-transition-after-reload-side-menu branch from b3ae836 to a57a240 Compare September 10, 2021 09:21
const decodedCookie = decodeURIComponent(doc.cookie);
const cookiesArray = decodedCookie.split(';');

for (index in cookiesArray) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for ... of would be better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe even change it all to .find

const cookieValue = cookiesArray.find((cookie) => {
  const cookieString = cookie.trim();
  
  return cookieString.indexOf(cookieName) === 0;
});

return cookieValue ? cookieValue.split('=')[1] : '';

or sth like this

const decodedCookie = decodeURIComponent(doc.cookie);
const cookiesArray = decodedCookie.split(';');

for (index in cookiesArray) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe even change it all to .find

const cookieValue = cookiesArray.find((cookie) => {
  const cookieString = cookie.trim();
  
  return cookieString.indexOf(cookieName) === 0;
});

return cookieValue ? cookieValue.split('=')[1] : '';

or sth like this

}
}

return '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that no value should be represented by null.

doc.cookie = `${name}=${value};max-age=${maxAge};path=${path}`;
};
const getCookie = (name) => {
const cookieName = name + '=';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: this is actually not a cookie name, but cookie name with equal sign.
Personally, because it is very short and straightforward, I would prefer to remove this and just add `${name}=` inside cookieString.indexOf.

@@ -1,4 +1,4 @@
(function(global, doc, eZ, localStorage) {
(function (global, doc, eZ, localStorage) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(function (global, doc, eZ, localStorage) {
(function(global, doc, eZ, localStorage) {

{% set second_level_manual_resize_min_width = 80 %}
{% set second_level_menu_width = app.request.cookies.get('second_menu_width') %}
{% set second_menu_width_style = '' %}
{% set second_menu_list_widt_style = '' %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Suggested change
{% set second_menu_list_widt_style = '' %}
{% set second_menu_list_width_style = '' %}

@sonarcloud
Copy link

sonarcloud bot commented Sep 10, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
2.1% 2.1% Duplication

@dew326 dew326 merged commit 8e67df8 into ezsystems:master Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants