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

Why is this admin nav repeating vertically? #3087

Closed
jaredbeck opened this issue Jan 8, 2016 · 15 comments
Closed

Why is this admin nav repeating vertically? #3087

jaredbeck opened this issue Jan 8, 2016 · 15 comments

Comments

@jaredbeck
Copy link
Contributor

screen-shot-2016-01-06-at-6 23 56-pm

In the following chat on gitter, Brice asked me to create this issue. I don't have any more information.

jaredbeck
Jan 06 18:24
Why is this admin nav repeating vertically?
Using refinerycms-pages 3.0.0
Is it drawn by refinerycms-core-3.0.0/app/views/refinery/admin/_menu.html.erb?

gabyshev
Jan 07 07:28
@jaredbeck I faced the same issue when I was editing my locale files. Check them carefully and try to restart server.

bricesanchez
Jan 07 08:19
@jaredbeck and @gabyshev it happens in dev env only, please fill an issue for reference

@anitagraham
Copy link
Contributor

I get this too, and I've assumed it's a result of rebuilding the side-nav after a dev crash/restart.

@parndt
Copy link
Member

parndt commented Feb 15, 2016

I think it's when you edit something in an extension and so the code reloads and something isn't clearing its cache properly!

@michael-misshore
Copy link

I also would like to confirm the reported behavior. If I get some free time, I can look into submitting a pull request to fix this.

@bricesanchez
Copy link
Member

@michael-misshore ❤️

@randallreedjr
Copy link

I am also seeing this, but it didn't start for me until I activated the config.plugin_priority setting in initializers/refinery/core.rb.

@bricesanchez bricesanchez added this to the 3.0.3 milestone Mar 24, 2016
@bricesanchez
Copy link
Member

Any news @michael-misshore ?

@michael-misshore
Copy link

@bricesanchez Unfortunately, I haven't been able to get to this particular issue. The last time I took a look at this, I had a tough time replicating it. Hopefully, I'll be able to take some time to investigate and ultimately get this corrected.

@anitagraham
Copy link
Contributor

@bricesanchez I get this all the time. It seems to be associated with restarting the server while continuing to use the same web page.

@parndt
Copy link
Member

parndt commented Apr 14, 2016

I still believe that it's when you change some code in vendor/extensions/ or maybe a decorator and code isn't reloading.

@Dreamjer
Copy link

Hi,
I see the plugins in users duplicated too :
plugins_duplicate
As you can see the settings plugin seems to be the only one not concerned.

@sintro
Copy link

sintro commented Jul 25, 2016

I almost sure, that the problem is caused by the automatic reloading of changed code mechanism of Rails + this line https://github.com/refinery/refinerycms/blob/master/core/lib/refinery/plugin.rb#L22
I can confirm, that this bug is almost always (if not always) happens when I change code in custom extension and refresh the page (without the development server restart). I assume, that code reloading mechanism repeat all the initialization processes of the engine, and so ::Refinery::Plugins.registered.unshift called again, while already created in previous iterations @registered_plugins (that is the array, which will be unshifted in this method and exactly the source of all this buttons in menu). What I can suggest is to check for duplication before https://github.com/refinery/refinerycms/blob/master/core/lib/refinery/plugin.rb#L22. It is a kind of treatment of symptoms, but it should not hurt the code effectiveness a lot because in production all this steps will be run once when the application is starting (i think).
Probably, it is more correct way to fix this is to do some more low-level code modifications, which will take into account the features of autoloading mechanisms of rails, but I know almost nothing about it.

@parndt
Copy link
Member

parndt commented Jul 25, 2016

Do you think that it'd work to modify the line to add a uniq:

::Refinery::Plugins.registered.unshift(plugin).uniq

@sintro
Copy link

sintro commented Jul 25, 2016

Something like, but not exactly this way. First, this line is modifying the ::Refinery::Plugins instance variable, while Arrays uniq just return new object, so we need the **uniq!** method here. The problem is all the objects will be actually unique (just checked this), and uniq! will remove nothing. So we need to override uniq! method to make it work with array of plugins (to make it check some plugins identifier, like name or class_name)

@parndt
Copy link
Member

parndt commented Jul 25, 2016

Ah thanks, of course. So what about:

::Refinery::Plugins.registered.unshift(plugin).uniq!(&:name)
irb(main):002:0> foo = [
  OpenStruct.new(name: "one"), 
  OpenStruct.new(name: "two"), 
  OpenStruct.new(name: "one")
]
=> [#<OpenStruct name="one">, #<OpenStruct name="two">, #<OpenStruct name="one">]
irb(main):004:0> foo.uniq!(&:name)
=> [#<OpenStruct name="one">, #<OpenStruct name="two">]

@sintro
Copy link

sintro commented Jul 26, 2016

Bingo! Now everything looks fine.
Made PR #3234
You can check it by starting dev server, load the admin menu, then make any change in some extensions .rb file, reload the page -> now the admin menu list should not have duplicates like before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants