Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: added include_deleted to getWorkspaceByOwnerAndName#2164

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Kira-Pilot merged 10 commits intomainfromadd-includes-deleted/kira-pilot
Jun 8, 2022

Conversation

Kira-Pilot
Copy link
Member

relates to#1955

I'm working on#1955: a ticket that will show deleted workspaces in our UI.
@f0ssel made some helpful changes togetWorkspaces in#2095 to help support the aforementioned UI change.
However,@BrunoQuaresma recently updated the Workspace page so that it no longer uses thegetWorkspace route, instead favoringgetWorkspaceByOwnerAndName.

This PR attempts to add aninclude_deleted param togetWorkspaceByOwnerAndName so I can continue work on#1955. I've never touched Go before so please let me know what I've broken 🧹

P.S. It would be great to generate a type for this addition but idk how to do that.

@Kira-PilotKira-Pilot requested review froma teamJune 8, 2022 13:14
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

Nice! Just a couple of things:

  1. I think we don't need to actually check if theinclude_deleted parameter is a valid boolean; just checking if it is equal to the stringtrue should be enough here. I know this is taken from existing code though, so I'm willing to defer to others on this.
  2. Would it be possible to add a unit test for this new behaviour inworkspace_test.go? I'm up for pairing on this with you if you'd like!

Kira-Pilot reacted with thumbs up emoji
workspace, err = api.Database.GetWorkspaceByOwnerIDAndName(r.Context(), database.GetWorkspaceByOwnerIDAndNameParams{
OwnerID: owner.ID,
Name: workspaceName,
Deleted: includeDeleted,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this works as intended. The param here in the SQL matches fordeleted = $includeDeleted.

So if you set this to true, the workspace will not show if the workspace is deleted. We will need to update the SQL too, or just always return deleted workspaces by default.

Copy link
Member

Choose a reason for hiding this comment

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

See how it's handled here:

ifworkspace.Deleted&&!showDeleted {
httpapi.Write(rw,http.StatusGone, httpapi.Response{
Message:fmt.Sprintf("Workspace %q was deleted, you can view this workspace by specifying '?deleted=true' and trying again.",workspace.ID.String()),
})
return
}

I think thedeleted query param is kinda annoying as you have to know the state of the workspace to query it.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@Emyrk Hmm, testing it in the UI seems to work.

  1. ifinclude_deleted is false, then we never enter this code block (becauseerrors.Is(err, sql.ErrNoRows) is false
  2. otherwise we enter this code block and try to query for a deleted workspace

In either case, if we get nothing back, we then go into thehttpapi.Forbidden(rw) block below. I agree editing the SQL would also work. I just didn't know what other ramifications that would have.

Let me know if I'm misunderstanding your comment!

@Kira-Pilot
Copy link
MemberAuthor

@johnstcn
Thanks! Would love to pair on that test; maybe a little later today if you have time?

Copy link
Contributor

@presleyppresleyp left a comment

Choose a reason for hiding this comment

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

Not sure why this tagged the frontend for review but I'm approving to unblock you on that front!

Kira-Pilot reacted with hooray emoji
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

Just some drive-by code style suggestions, looks good to me!

Kira-Pilot reacted with heart emoji
Kira-Pilotand others added5 commitsJune 8, 2022 10:25
defining vars in the scope of conditionalCo-authored-by: Mathias Fredriksson <mafredri@gmail.com>
avoid newlineCo-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks Kira!

@@ -83,6 +83,7 @@
"workspaceapp",
"workspaceapps",
"workspacebuilds",
"workspacename",
Copy link
Member

Choose a reason for hiding this comment

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

👍

@Kira-PilotKira-Pilot merged commit3bc122b intomainJun 8, 2022
@Kira-PilotKira-Pilot deleted the add-includes-deleted/kira-pilot branchJune 8, 2022 18:04
kylecarbs pushed a commit that referenced this pull requestJun 10, 2022
* feat: added include_deletedrelates to#1955* Update coderd/workspaces.godefining vars in the scope of conditionalCo-authored-by: Mathias Fredriksson <mafredri@gmail.com>* Update coderd/workspaces.goavoid newlineCo-authored-by: Mathias Fredriksson <mafredri@gmail.com>* Update coderd/workspaces.goCo-authored-by: Mathias Fredriksson <mafredri@gmail.com>* PR feedback* wrote test, added type* Update coderd/workspaces_test.goshortening test nameCo-authored-by: Cian Johnston <cian@coder.com>* taking out api.ts change for now* casingCo-authored-by: Mathias Fredriksson <mafredri@gmail.com>Co-authored-by: Cian Johnston <cian@coder.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@EmyrkEmyrkEmyrk left review comments

@mafredrimafredrimafredri approved these changes

@presleyppresleyppresleyp approved these changes

Assignees

@Kira-PilotKira-Pilot

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@Kira-Pilot@mafredri@presleyp@johnstcn@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp