-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
action-logger addon don't show Array<File> options #1945
Comments
Anything passed into the addons should be JSON serializable. I don't believe files work but there might be workarounds. |
That's not exactly the truth, otherwise @bustEXZ how exactly does the action panel output look in your case? |
If i install @storybook/addon-actions@3.3.0-alpha.2 he stop work, and dont create new Tab "ACTION LOGGER" in panel (but witout errors). If i update all for 3.3.0-alpha.2 all don't work and try to redirect me to this page https://storybook.js.org/basics/faq/#why-is-there-no-addons-channel. Cant resolve this error and check |
@shilman do you know what happens here? |
I'm fixing the bug @Hypnosphi reported in a comment on the pull request at the moment. Also found some other cases which didn't work like logging functions. @bustEXZ you have a simplified code snippet which would reproduce your case? |
@rhalff Add custom option to |
@bustEXZ @Hypnosphi sorry i missed this mention. Try clearing out your node_modules, it's probably an NPM version issue. |
I think the problem is that those properties are non-enumerable:
Maybe we should use UPD: Oh, looks like it won't help.
|
I came to the same conclusion and currently using: export default function getPropertiesList(value) {
const keys = Object.getOwnPropertyNames(value);
// eslint-disable-next-line no-restricted-syntax
for (const name in value) {
if (keys.indexOf(name) === -1) {
keys.push(name);
}
}
return keys;
} It's not perfect though, while console.log only shows the properties: I'm not sure how chrome / firefox determine what to log, if I knew I could perhaps mimic that behavior. |
Maybe like this? function getPropertiesList(value) {
const keys = Object.getOwnPropertyNames(value);
const objKeys = Object.getOwnPropertyNames(Array.prototype);
for (const name in value) {
if (keys.indexOf(name) === -1 && objKeys.indexOf(name) === -1) {
keys.push(name);
}
}
return keys;
}
var file = new File([""], "filename.txt", {type: "text/plain", lastModified: new Date()})
file.custom = 'Hello';
console.log(getPropertiesList(file));
// ["custom", "name", "lastModified", "lastModifiedDate", "webkitRelativePath", "size", "type"] |
Why |
Static methods. Its just example. We cant use File, because method delete our properties. |
I'm now trying this: export default function getPropertiesList(value) {
const keys = Object.getOwnPropertyNames(value);
// eslint-disable-next-line no-restricted-syntax
for (const name in value) {
if (keys.indexOf(name) === -1 && !(typeof value[name] === 'function' && !value.hasOwnProperty(name))) {
keys.push(name);
}
}
return keys;
} Which ignores any functions not being an own property. |
@rhalff @bustEXZ What's wrong with the approach from #2401? Looks like it logs exactly what's needed (see live example) |
Looks great! Thanks |
@Hypnosphi I've created a new pull request (#2438) which also incorporates your changes and fixes the bug reported in your comment. I refactored the code a bit and have added tests. |
Merged and released about a month ago |
Deps: "@storybook/addon-actions": "^3.2.12"
I send in callbacks 2 arrays with type File (acceptedFiles, rejectedFiles).
But logger dont see options (because its File object) and shows them empty.
What can i do, to fix this? (I dont need to convert File type to Object)
Thanks!
The text was updated successfully, but these errors were encountered: