How to display links in storybook next to title? - storybook

I'm trying to show 'copy' links when user hovers on heading:
In storybook ducumentation sometimes it works:
https://storybook.js.org/docs/react/writing-docs/mdx#documentation-only-mdx
And sometimes not:
https://storybook.js.org/addons/#storybook/addon-links
How do I enable them? What I've tried - I've copied code from storybook's github - I thought that top links somehow get mapped later to the headings, but no luck so far
- [Basic example](#basic-example)
- [MDX-Flavored CSF](#mdx-flavored-csf)
## Basic example
## MDX-Flavored CSF
do I need any addons to handle that?

The problem is that headings ids are not generated by remark-slug package here -- in HeaderMdx it doesn't go into if condition because no id was provided and function returns regular <Header> instead of <HeaderWithOcticonAhchor>
Based on this thread this was broken after 6.4.19 and fix was pushed into 7.0.0
So solutions are:
downgrade, though its not obvious to me how to do that yet
upgrade to 7.0.0 (which is in alpha18 as of now)
postinstall patching of latest 6.5.0

Related

Django 1.8 migration did not take affect

Using Django 1.8 with a SQLite database.
I made a change in models.py that consisted of eliminating two out of four elements from a field choice and editing one of the remaining two:
Original value:
OPTION_INSPECTOR = (
('John Smith', 'John Smith'),
('Taylor', 'Taylor'),
('Hale', 'Hale'),
('James', 'James'),
)
New value:
OPTION_INSPECTOR = (
('John Smith', 'John Smith'),
('Greg Taylor', 'Greg Taylor'),
)
I then ran:
python manage.py makemigrations my_app
I saw nothing unusual, only the changes that I made, if I recall correctly. I do not have the actual output.
Then I ran:
python manage.py migrate my_app
Again, I don't remember anything unusual. But, the model hasn't changed the choices within the dropdown menu on the Admin site. Can anyone suggest a way to make this change successfully?
Thanks!
I am continually changing my app based on feedback from researchers. I have had a lot of issues like what you are describing. I have found that there are a lot of changes I can make to the models before the app total breaks and I have to go back and "remake" it with a fresh model.py file, but eventually, that is what I have had to do. In the meantime (before I remake the app), I make the changes to the model.py, then I run the makemigrations and then migrate. I look and see what the errors are and I make the changes to fix them directly in the database (in my case, MySQL). Typically, I have to do this to add or alter fields. Then, I rerun the make migrations and the migrate, and I get warnings about duplicate fields, but the app keeps working. Like I said though, eventually, I have to remake the app with a fresh model.py file to get rid of all the warnings.

Uncaught error: There are multiple templates named 'velvet'. Each template needs a unique name. (..)

I have recently deployed my meteor app ( www[.]webmill[.]eu ) which was working just fine locally. I dealt with MIME type errors but am stuck with this one:
Error: There are multiple templates named 'velvet'. Each template needs a unique name. 1b1a247fc034d5089f331ec9540138ff6afd5f39.js:75:306
I checked but I don't have any duplicates and I can't find any info on how to solve this apart from a similar issue that existed with a meteor package, accounts-ui-bootstrap-3.
On desktop, I only get the initial full background image without being able to navigate anywhere on the page. Also I can put anything in my url like so : webmill.eu/nowaythisisarealurl and it will still display the same thing. It works as intended on displays under 1070 px width.
meteor packages I'm using:
meteor-platform
mizzao:bootstrap-3
pfafman:font-awesome-4
Any suggestions/help will be much appreciated!
You have two templates named velvet. I cloned your repo and ran this:
grep -r -i 'name="velvet"' *
Result:
app/client/image.html:<template name="velvet">
app/client/index.html:<template name="velvet">
Change the name of one of the templates.

Auto-renaming of new Archetypes objects (Plone 4) stopped to work

I have a Plone 4 site which stopped to rename new Archetypes objects; after creation (as something like /temp/portaltype.2015-04-23.1234567890) and saving the first changes, including giving it a title, it should be renamed to something nicer (/temp/an-object-with-a-meaningful-name), but this doesn't happen anymore.
Perhaps the problem arose when I applied some changes to update Plone from 4.3.3 to 4.3.4 (to make one step at a time); but I have inherited a long versions.cfg which is solely sorted by package names and doesn't include any hints why certain versions were chosen ...
I'm able to go back two months and have a version which does the renaming, but without more knowledge about what to look for, it will be a very time-consuming process of re-applying every single change, rebuilding, starting and testing; but there have not been any changes to my schema definitions. I have a temp browser which is involved in delivering the primary edit form. but this doesn't seem to be the case for the saving action.
Sadly I don't fully understand yet the mechanisms of the base_edit action which should - as far as I understand - call Archetypes.BaseObject.processForm and implicitly ._renameAfterCreation, so I'd be grateful for some pointers how to debug this. Thank you!
Update:
I have a few triggers in my product's configure.zcml, e.g.:
<subscriber
for=".content.portaltype.PortalType
Products.Archetypes.interfaces.IObjectInitializedEvent"
handler=".events.onInitPortalType"/>
… with, in events.py:
def onInitPortalType(self, event):
"""
Called after first edit of new objects?
"""
print '/// onInitPortalType(%(self)r, %(event)r)' % locals()
setInitialOwner(self, event)
setStateToPrivate(self, event)
However, the event doesn't seem to be triggered, since I couldn't find the output in an instance fg session.
Update 2:
I noticed that zope.event had been pinned to a quite old version (3.5.2), so I'm trying to update to 4.3.4 more seriously now (following this how-to). This got me zope.event v4.0.3, but I have a version conflict now:
There is a version conflict.
We already have: zc.recipe.egg 1.3.2.
While:
Installing.
Getting section test.
Initializing section test.
Installing recipe zc.recipe.testrunner.
There seems to be a requirement for zc.recipe.egg < 2dev somewhere, but I can't find it.
Nothing significant changed between Plone 4.3.3 and 4.3.4 on Archetypes. Products.Archetypes changed from 1.9.7 to 1.9.8 and Products.ATContentTypes remains on the same version.
Pointers could be:
There's a _at_rename_after_creation flag, which is True by default. This can be changed on the content type class.
Is your type still activated in portal_factorytool? (Afaik this should have no impact on renaming after creation - but who knows :-))
Any Products.Archetypes.interfaces.IObjectInitializedEvent subscriber?
Issue I had once was, that the tmp id portaltype.2015-04-23.1234567890 had the wrong format and AT did no recognise it as tmp id and therefore it did not rename it after creation. The method AT uses to check if the id is autogenerated --> https://github.com/plone/Products.CMFPlone/blob/4.3.4/Products/CMFPlone/utils.py#L111 AFAIK the problem was, that the meta_type and portal_type was not the same anymore.

ExtJS 4.2: Ext.grid.feature.Summary error on store initialization

I am testing ExtJS 4.2 (4.2.1) with my existing code, and it mostly works, except for one serious problem: when my page loads, I get a JS error:
Ext.fly(div).down(me.getNodeContainerSelector(), true) is null
It happens in:
ext-all-debug.js l.105020 - createRowElement of Ext.view.Table
called from ext-all-debug.js l.112748 - onStoreUpdate of Ext.grid.feature.Summary)
The call stack is too long to put here, but it happens after a 'sort' event is fired on the grid, which is empty at this point (it is populated later). The sort happens as the grid constructor calls initState(), trying to apply a saved state (the grid is stateful).
I tried to remove the saved state data, which helped the process go one step further: the grid was drawn but then it started loading and got stuck again in onStoreUpdate(), in the same manner.
What am I doing wrong here ?
Had the same issue after upgrading to 4.2.1 from 4.1.2a. Changed how I defined features and plugins on the grid. Now using ptype and ftype. Seemed to solve it.

How do I trigger portal_quickinstaller.reinstallProducts form outside the Plone Site?

We're running a Zope server with an eventually large-ish number of Plone (4) sites. Every now and then, an extension product update comes along and requires a re-install to pick up changes in the profile settings, e.g. new content types.
Manually, this would mean clicking through to every Plone site's portal_quickinstaller, tick the products, press update. This is not very feasible if we're talking about dozens of sites, so I'm trying to automate this. Essentially so far, I have the following living as a Script(Python) in the Zope root:
a = context.restrictedTraverse('/')
p = a['Plone']
print p.getSiteManager()
qi = p.restrictedTraverse('portal_quickinstaller')
print qi
qi.reinstallProducts('LinguaPlone')
(Simplified; in reality I have a longer list instead of the single Plone instance, and I might want to reinstall a longer list of products.)
This fails with the following:
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 613, in uninstallProducts
Module Products.CMFQuickInstallerTool.InstalledProduct, line 272, in uninstall
Module Products.CMFQuickInstallerTool.InstalledProduct, line 351, in _cascadeRemove
AttributeError: 'BaseGlobalComponents' object has no attribute 'objectItems'
From my debugging attempts so far, the BaseGlobalComponents is the Zope SiteManager returned by the zope.component.getSiteManager. How do I convince quickinstaller to pick up the right one, i.e. the one from the Plone Site it's living in?
Alternatively, how would I go about automating re-installing products in a way that will remain vaguely feasible for larger installations? (ETA: I'm aware this is not the kind of thing you do automatically with a cronjob, but updates of inhouse-developed products can't be avoided, I'm afraid.)
Here's how to change the active local site manager. You won't be able to do this in Restricted Python, so you'll need to turn your Python script into an External Method or browser view.
from zope.app.component.hooks import setHooks, setSite
setHooks()
setSite(site)
The setHooks call only needs to be done once. In Zope 2.12 these calls should be imported instead from zope.site.hooks and in Zope 2.13 from zope.component.hooks.
Keep in mind that calling reinstallProducts is not appropriate for all add-on products, and not recommended unless you've carefully checked what reinstalling does and are sure it won't cause problems. Some products provide upgrade steps that run actions more selectively.
Disclaimer: are you sure you want to do this? Automatically reinstalling and upgrading products to the latest version, blindly and without any testing on a staging instance, is asking for trouble.
Anyway, you can do such a thing using XML-RPC and a little tweaking. This is how you install a product on a live running instance using XML-RPC:
>>> import xmlrpclib
>>> proxy = xmlrpclib.ServerProxy(
"http://admin:passwd#localhost:8080/Plone/portal_quickinstaller"
)
>>> proxy.getProductVersion('Marshall')
'2.0'
>>> proxy.isProductInstalled('Marshall')
'False'
>>> proxy.installProduct('Marshall')
'Registry installed sucessfully.\n'
>>> proxy.isProductInstalled('Marshall')
'True'
To reinstall you need subclass Products.CMFQuickInstallerTool.QuickInstallerTool.py and provide you custom QuickInstallerTool with a method that has the keyword argument "reinstall" set as 'True' by default; something like:
442c442
< swallowExceptions=None, reinstall=False,
---
> swallowExceptions=None, reinstall=True,
452,457c452,457
< if self.isProductInstalled(p):
< prod = self._getOb(p)
< msg = ('This product is already installed, '
< 'please uninstall before reinstalling it.')
< prod.log(msg)
< return msg
---
> #if self.isProductInstalled(p):
> # prod = self._getOb(p)
> # msg = ('This product is already installed, '
> # 'please uninstall before reinstalling it.')
> # prod.log(msg)
> # return msg
Even better: provide your own method for gathering information about versions and reinstalling a product, compatible with the XML-RPC protocol (as you cannot pass keyword arguments).
There might be cleaner ways of doing this via XML-RPC, but portal_quickinstaller is not meant to be used in this way and there may be caveats. Use with caution.
I have got this python script in the Zope root of an instance with 7 Plone Sites. Looks pretty much the same as what you have. It might be that it only works on this Plone 2.5 site (yes, old), but I think it should work on 3.x and 4.x as well. Maybe an an innocent looking difference (that I am overlooking) causes the error in your script; maybe the restrictedTraverses that you do trip it up. (Script edited for clarity.)
SITES = ['site-1', 'site-2']
for site in SITES:
print "Reinstalling LinguaPlone in %s." % site
portal = context[site]
qi = portal.portal_quickinstaller
qi.reinstallProducts(['LinguaPlone'])
First don't do a reinstall it can break your website in many cases.
Next you have to consider that add-ons may provide an upgrade step (usually they will). Use the quickinstaller api to achieve this in PythonScript. It is good but it can also be achieved with a script on the file system. Check the examples here: http://svn.plone.org/svn/plone/plone.org/Products.PloneOrg/trunk/scripts/
Another solution can be to use the Selenium IDE to record the quickinstaller stuff in one site and make a copy paste the results of that tests to run it on another website (very weird isn't it ?)

Resources