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

feat: implement of repo collection [OSPP 2023] #713

Merged

Conversation

andyhuang18
Copy link
Collaborator

@andyhuang18 andyhuang18 commented Aug 9, 2023

Brief Information

This pull request is in the type of (more info about types):

  • build
  • ci
  • docs
  • feat
  • fix
  • perf
  • refactor
  • test

Related issues (all available keywords):

Details

  • Currently, the Repo Collection button has been added to the github page. After clicking, the collection list will pop up. Click Delete in the list to delete the corresponding collection.

image

  • Similarly, a button has been added to the settings bar of the hypercrx-icon, but the design of the style has yet to be adjusted.
  • The next thing that needs to be implemented is to save the user's Repo Collection locally and complete the development of the main display board of the Repo Collection.

PS: There is a small problem at present is that I want this button to be closer to the Edit Pins, that is, to the right.

image

Things to be done:

  • adjust style of the dropdown opened throuth hypercrx-icon
  • save the user's Repo Collection locally
  • main display board of the Repo Collection
  • i18n
  • other more

Checklist

Others

I used the components of ant design to complete it, and welcome your valuable suggestions!

@andyhuang18
Copy link
Collaborator Author

andyhuang18 commented Aug 15, 2023

Report on work completed so far:

  1. The user's repo collection can be stored locally in the browser, and the next time the browser is opened, the user's custom repo collection data can be read. Since antd's menu needs to receive the return value of the getitem function as a menuitem, and the return value cannot be stored directly via chrome.storage.local.set due to nesting, I extracted the information required by the getitem function (label,key, icon, children), and converted it into a storable data structure for storage. Also, when reading the local data via chrome.storage.local.get, you need to pass the information mentioned above into the getitem function as parameters to get the value of the menu.
  2. Implemented reset default repo-collection function:SetAsDefault, user can initialize menu to default state by this button.
  3. A particular collection can be deleted, and in order to add new collections without duplicate key conflicts, the remaining collections need to be renumbered after deleting the collection. Similarly, the children of each renumbered collection should also be renumbered. UpdateCollection function is used to realize the renumbering.
  4. User can add the current repo to a specific collection by using the getRepoName function to get the name of the repository on the current page and add it to the item list of the collection.
  5. To make the code more understandable, I'll use an example in JSON form to briefly describe the item's information:
[
  {
    "label": "X-Lab",
    "key": "collection1",
    "icon": "GithubOutlined",
    "children": [
      { "label": "delete collection", "key": "delete1", "icon": "DeleteOutlined" },
      { "label": "add current Repo", "key": "add1", "icon": "FolderAddOutlined" },
      { "type": "divider" },
      { "label": "open-digger", "key": "1.1" },
      { "label": "open-perf", "key": "1.2" },
      { "label": "open-leaderboard", "key": "1.3" },
      { "label": "open-wonderland", "key": "1.4" }
    ]
  }
]
  • label is the name of the collection
  • key is the key of the unique collection option, in the first level, the key is the collection plus a numeric numbering arrangement
  • icon is the icon in front of the option
  • children is the information contained in the collection.
  • The meaning of the data in the second level is similar to that in the first level, where the first three items are the delete collection option for deletion, the add current repo option for adding a repo, and a separator containing only the type attribute. children is the information contained within the collection that is associated with the parent collection number.

@andyhuang18
Copy link
Collaborator Author

Simply recorded a demo video, the operations include adding collection, deleting collection, adding current repo to collection, resetting default values.

demo.for.repo-collection.2023.08.15.mp4

@wxharry wxharry changed the base branch from master to feat/repo-collection August 20, 2023 18:03
@wxharry
Copy link
Collaborator

wxharry commented Aug 22, 2023

Hi, I have changed the base branch for this PR. Since you and wj are working this feature together, we cannot merge your work one by one. So, I create a feature branch so that you can work closely together and develop in a relative fast pace.

For this PR, please implement Frame 1, 2, 3. It is okay to ignore styles and unrelated features for this PR.

Thanks!

@andyhuang18
Copy link
Collaborator Author

It is not completely finished yet and has encountered some status management problems. The following is the situation of the two interfaces.

image image

Time is tormenting me...

@andyhuang18
Copy link
Collaborator Author

At present, the button function of the repository page has been initially implemented, and you can check which collection the repository belongs to when you click it for the first time. After clicking edit, you can enter the checkbox list and add it to a new collection.

Clicking on the collection to pop up the modal in the repository interface has not yet been implemented, but it can capture the parameters that need to be transmitted.

In addition, click collection on the pop-up interface (it is blocked in the video), and the modal can pop up. The top of the modal is composed of tabs named after the collection. The left side displays the repository information contained in the collection.

The demo video is shown below:

demo.video.mp4

The problem currently encountered is that sometimes when managing the state of an object, the value of the object cannot be changed. (However, it is possible to increase a certain attribute of an object, but not to decrease it, which is confusing...)

@andyhuang18
Copy link
Collaborator Author

I have initially implemented the function of calling the modal from the button in the dropdown under the repository left yesterday.

The demo video is shown below:

demo.of.modal.from.dropdown.click.mov

@andyhuang18
Copy link
Collaborator Author

The demo video is shown below:

demo.for.collection.editor.mov

@andyhuang18
Copy link
Collaborator Author

demo.mp4

@andyhuang18 andyhuang18 marked this pull request as ready for review October 21, 2023 15:18
Copy link
Collaborator

@wxharry wxharry left a comment

Choose a reason for hiding this comment

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

Please do a chore on your code by removing unnessary comments and use english in comments. Thank you so much.

@andyhuang18
Copy link
Collaborator Author

andyhuang18 commented Oct 22, 2023

Hi~ @wxharry @tyn1998 This is the final version of my code! Please spare your time checking it! Thank you very much 😄
This is the button interface:

截屏2023-10-22 20 00 01

This is the part where repository can be added to the dropdown of the button:

截屏2023-10-22 20 06 58

This is the modal interface, the middle part is the chart:

截屏2023-10-22 20 10 01

This is the modalEditor interface, which can edit collection and repository:

截屏2023-10-22 20 12 17

Copy link
Member

@tyn1998 tyn1998 left a comment

Choose a reason for hiding this comment

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

Great job @andyhuang18 !

Your code LGTM, thank you for your contributions!

@tyn1998 tyn1998 merged commit e83ec15 into hypertrons:feat/repo-collection Oct 22, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OSPP 2023] Project 1: Implement the new "Repo Collections" feature (except for charts)
4 participants