Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

feat(directive forest): create copy to clipboard button for properties view #38

Merged
merged 1 commit into from
Feb 11, 2020

Conversation

AleksanderBodurri
Copy link
Contributor

@AleksanderBodurri AleksanderBodurri commented Feb 5, 2020

A small nice-to-have.

Limitation: Cannot copy nested properties.

Edit: Underestimated the scope of this feature. Putting it on hold to focus on main issues. Will tackle this one in my spare time.

@@ -103,5 +106,18 @@ export class DirectiveExplorerComponent implements OnInit {
});
return result;
}

copy(dataToCopy: object): void {
Copy link
Contributor

@mgechev mgechev Feb 5, 2020

Choose a reason for hiding this comment

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

We copy the entire descriptor this way, right? We don't want metadata in the users' clipboards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll post a demo

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we should transform the object to preserve only the values, not the metadata that we send from the backend. Here's what I copied from the zippy:

{"visible":{"type":6,"value":false,"editable":true,"expandable":false,"preview":"false"},"title":{"type":1,"value":"► Click to expand","editable":true,"expandable":false,"preview":"\"► Click to expand\""}}

Notice the properties type, preview, editable`, etc. these shouldn't be part of the payload that ends up in the user's clipboard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reread your comment a moment ago and realized what you meant, my apologies haha. I'm thinking I can somehow take advantage of the existing serializer functions in state-serializer.ts, maybe with an options argument on whether to include the meta-data or not. What do you think?

Copy link
Contributor Author

@AleksanderBodurri AleksanderBodurri Feb 6, 2020

Choose a reason for hiding this comment

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

After examining state-serializer.ts I don't think it would be clean to hijack the existing serialize functions. I have an idea of how to implement this but since this feature isn't on the main issues list, I'll put it on hold for now and give it a shot this weekend.

Copy link
Contributor

@mgechev mgechev Feb 6, 2020

Choose a reason for hiding this comment

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

A function which transforms the object:

{"visible":{"type":6,"value":false,"editable":true,"expandable":false,"preview":"false"},"title":{"type":1,"value":"► Click to expand","editable":true,"expandable":false,"preview":"\"► Click to expand\""}}

to:

{
  "visible": false,
  "title": "► Click to expand"
}

Should be fine. You can just strip few properties. With nested props, we can set as value the preview.

Copy link
Contributor

@mgechev mgechev left a comment

Choose a reason for hiding this comment

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

Nice feature! Left a single comment. Would you update the commit message so the commit type is lowercase?

@AleksanderBodurri AleksanderBodurri changed the title Feat(directive forest): create copy to clipboard button for properties view feat(directive forest): create copy to clipboard button for properties view Feb 5, 2020
document.execCommand('copy');
}

private _cleanPropData(treeData: Properties, restructuredTreeData = {}): object {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't have to be a private method. A utility function will work just fine and won't pollute the prototype.

@mgechev mgechev merged commit 41bf2ac into master Feb 11, 2020
@mgechev mgechev deleted the feat-copy-properties-to-clipboard branch February 11, 2020 05:17
AleksanderBodurri added a commit to AleksanderBodurri/angular-devtools that referenced this pull request Sep 16, 2021
AleksanderBodurri added a commit to AleksanderBodurri/angular-devtools that referenced this pull request Sep 27, 2021
AleksanderBodurri added a commit to AleksanderBodurri/angular-devtools that referenced this pull request Oct 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants