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

Structure of Label functions #23

Closed
lipkau opened this issue Apr 7, 2017 · 9 comments
Closed

Structure of Label functions #23

lipkau opened this issue Apr 7, 2017 · 9 comments

Comments

@lipkau
Copy link
Member

lipkau commented Apr 7, 2017

I personally find it confusing (or at least not aligned to best practices), that New-WikiLabel attaches a label to a page.
I would have believed that this functions creates a new label on confluence which I can use later on on pages.

I would propose to refactor the function so that:

# Gets all pages with label "important"
Get-WikiPage -Label "important"

# Adds a label to a page
$page | Add-WikiLabel -Label "label1","label2"

# Remove a label from a page
$page | Remove-WikiLabel -label "label1","label2"

this would deprecate New-WikiLabel

@lipkau
Copy link
Member Author

lipkau commented Apr 7, 2017

this continues #15

@lipkau
Copy link
Member Author

lipkau commented Apr 7, 2017

Optional (I think it's worth it):

# Removes all labels that are set and adds the new ones
$page | Set-WikiLabel -Label "theOnlyLabel"

@brianbunke
Copy link
Collaborator

We also discussed the following in chat:

# Default cmdlet behavior removes all labels from piped content
$page | Remove-WikiLabel

@lipkau
Copy link
Member Author

lipkau commented Apr 7, 2017

but then again.... wouldn't that be kinda dangerous?
you forget to give a param and everything is gone?

maybe -all?

@brianbunke
Copy link
Collaborator

My opinion is that there should be default behavior, and that example is the most intuitive option. (Since this issue was opened with regards to the module being more intuitive 😛 )

As the author of many things that could be used destructively, my personal opinion is that I can't spend too much time worrying about people who use Remove-Anything without verifying their Get- results or utilizing -WhatIf and/or -Confirm.

@lipkau
Copy link
Member Author

lipkau commented Apr 7, 2017

agreed 👍

@lipkau
Copy link
Member Author

lipkau commented Apr 14, 2017

@brianbunke
I am kinda annoyed by Get-WikiLabel.

Situation

# returns all labels of each page in space PESTER
Get-WIkiPage -SpaceKey "PESTER" | Get-WikiLabel

I don't like that the snippet above returns a list of labels, but doesn't have any reference to what page was searched for the labels.
This is due to the refactoring of Invoke-WikiMethod. The casting to the object Label happens, when there is no (clean) way to pass the Page reference.

Suggestion

I would prefer for the Get-WikiPage to already expand (call the API) the labels of the page and add a property Labels (of type Label) to the Page object.

# captures all pages in space PESTER
$pages = Get-WikiPage -SpaceKey PESTER

# prints all labels in space PESTER
$pages | Select Labels -unique 

@lipkau
Copy link
Member Author

lipkau commented Apr 15, 2017

I decided for a different approach than described above:

# returns all labels used in space PESTER
Get-WikiPage -SpaceKey PESTER | Get-WikiPageLabel | Select Labels -Unique

The output of Get-WikiPageLabel returns:

[ConfluencePS.ContentLabelSet]@{
  Page = [ConfluencePS.Page]
  Labels = [ConfluencePS.Label[]]
}

lipkau added a commit to lipkau/ConfluencePS that referenced this issue Apr 15, 2017
lipkau added a commit to lipkau/ConfluencePS that referenced this issue Apr 15, 2017
* renamed function
* created custom object type for the set "Page+Labels"

implements AtlassianPS#23
@lipkau
Copy link
Member Author

lipkau commented Apr 15, 2017

Renaming of existing function

currently the function to get the labels of a page is called Get-WikiPageLabel.

I am renaming this function, as once attachments/blogs are implemented, this function should be reused

lipkau added a commit to lipkau/ConfluencePS that referenced this issue Apr 16, 2017
lipkau added a commit to lipkau/ConfluencePS that referenced this issue Apr 16, 2017
lipkau added a commit to lipkau/ConfluencePS that referenced this issue Apr 16, 2017
lipkau added a commit to lipkau/ConfluencePS that referenced this issue Apr 16, 2017
* better handling of pipe input
* more tests for ContentLableSet objects
* Get-WikiLabel takes array of pages as input
* all functions return ContentLableSet

implements AtlassianPS#23
@lipkau lipkau closed this as completed Apr 16, 2017
@lipkau lipkau self-assigned this Apr 18, 2017
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

2 participants