Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/server/slack/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *Slack) notifyApprovalEvent(ctx context.Context, e *ent.Event) {
return
}

if d = a.Edges.Deployment; d != nil {
if d = a.Edges.Deployment; d == nil {
s.log.Error("The eager loading of deployment has failed.")
return
}
Expand Down
27 changes: 13 additions & 14 deletions ui/src/apis/approval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { _fetch } from "./_base"
import { UserData, mapDataToUser } from "./user"
import { DeploymentData, mapDataToDeployment } from "./deployment"
import {
Repo,
User,
Deployment,
Approval,
Expand Down Expand Up @@ -93,8 +92,8 @@ export const searchApprovals = async (statuses: ApprovalStatus[], from?: Date, t
return approvals
}

export const listApprovals = async (id: string, number: number): Promise<Approval[]> => {
const res = await _fetch(`${instance}/api/v1/repos/${id}/deployments/${number}/approvals`, {
export const listApprovals = async (namespace: string, name: string, number: number): Promise<Approval[]> => {
const res = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments/${number}/approvals`, {
credentials: "same-origin",
headers,
})
Expand All @@ -109,11 +108,11 @@ export const listApprovals = async (id: string, number: number): Promise<Approva
return approvals
}

export const createApproval = async (repo: Repo, deployment: Deployment, approver: User): Promise<Approval> => {
export const createApproval = async (namespace: string, name: string, number: number, userId: string): Promise<Approval> => {
const body = {
user_id: approver.id
user_id: userId
}
const res = await _fetch(`${instance}/api/v1/repos/${repo.id}/deployments/${deployment.number}/approvals`, {
const res = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments/${number}/approvals`, {
credentials: "same-origin",
headers,
method: "POST",
Expand All @@ -131,8 +130,8 @@ export const createApproval = async (repo: Repo, deployment: Deployment, approve
return approval
}

export const deleteApproval = async (repo: Repo, approval: Approval): Promise<void> => {
const res = await _fetch(`${instance}/api/v1/repos/${repo.id}/approvals/${approval.id}`, {
export const deleteApproval = async (namespace: string, name: string, id: number): Promise<void> => {
const res = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/approvals/${id}`, {
credentials: "same-origin",
headers,
method: "DELETE",
Expand All @@ -144,8 +143,8 @@ export const deleteApproval = async (repo: Repo, approval: Approval): Promise<vo
}
}

export const getMyApproval = async (id: string, number: number): Promise<Approval> => {
const res = await _fetch(`${instance}/api/v1/repos/${id}/deployments/${number}/approval`, {
export const getMyApproval = async (namespace: string, name: string, number: number): Promise<Approval> => {
const res = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments/${number}/approval`, {
credentials: "same-origin",
headers,
})
Expand All @@ -159,11 +158,11 @@ export const getMyApproval = async (id: string, number: number): Promise<Approva
return approval
}

export const setApprovalApproved = async (id: string, number: number): Promise<Approval> => {
export const setApprovalApproved = async (namespace: string, name: string, number: number): Promise<Approval> => {
const body = {
status: ApprovalStatus.Approved.toString(),
}
const res = await _fetch(`${instance}/api/v1/repos/${id}/deployments/${number}/approval`, {
const res = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments/${number}/approval`, {
credentials: "same-origin",
headers,
method: "PATCH",
Expand All @@ -179,11 +178,11 @@ export const setApprovalApproved = async (id: string, number: number): Promise<A
return approval
}

export const setApprovalDeclined = async (id: string, number: number): Promise<Approval> => {
export const setApprovalDeclined = async (namespace: string, name: string, number: number): Promise<Approval> => {
const body = {
status: ApprovalStatus.Declined.toString(),
}
const res = await _fetch(`${instance}/api/v1/repos/${id}/deployments/${number}/approval`, {
const res = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments/${number}/approval`, {
credentials: "same-origin",
headers,
method: "PATCH",
Expand Down
12 changes: 6 additions & 6 deletions ui/src/apis/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const mapDataToBranch = (data: BranchData): Branch => {
}
}

export const listBranches = async (repoId: string, page = 1, perPage = 30): Promise<Branch[]> => {
const branches: Branch[] = await _fetch(`${instance}/api/v1/repos/${repoId}/branches?page=${page}&per_page=${perPage}`, {
export const listBranches = async (namespace: string, name: string, page = 1, perPage = 30): Promise<Branch[]> => {
const branches: Branch[] = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/branches?page=${page}&per_page=${perPage}`, {
headers,
credentials: "same-origin",
})
Expand All @@ -27,8 +27,8 @@ export const listBranches = async (repoId: string, page = 1, perPage = 30): Prom
return branches
}

export const getBranch = async (repoId: string, name: string): Promise<Branch> => {
const response = await _fetch(`${instance}/api/v1/repos/${repoId}/branches/${name}`, {
export const getBranch = async (namespace: string, name: string, branch: string): Promise<Branch> => {
const response = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/branches/${branch}`, {
headers,
credentials: "same-origin",
})
Expand All @@ -37,9 +37,9 @@ export const getBranch = async (repoId: string, name: string): Promise<Branch> =
throw new HttpNotFoundError(message)
}

const branch:Branch = await response
const ret:Branch = await response
.json()
.then((b: BranchData) => mapDataToBranch(b))

return branch
return ret
}
12 changes: 6 additions & 6 deletions ui/src/apis/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ const mapStatusState = (state: string) => {
return StatusState.Pending
}

export const listCommits = async (repoId: string, branch: string, page = 1, perPage = 30): Promise<Commit[]> => {
const commits: Commit[] = await _fetch(`${instance}/api/v1/repos/${repoId}/commits?branch=${branch}&page=${page}&per_page=${perPage}`, {
export const listCommits = async (namespace: string, name: string, branch: string, page = 1, perPage = 30): Promise<Commit[]> => {
const commits: Commit[] = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/commits?branch=${branch}&page=${page}&per_page=${perPage}`, {
headers,
credentials: "same-origin",
})
Expand All @@ -74,8 +74,8 @@ export const listCommits = async (repoId: string, branch: string, page = 1, perP
return commits
}

export const getCommit = async (repoId: string, sha: string): Promise<Commit> => {
const response = await _fetch(`${instance}/api/v1/repos/${repoId}/commits/${sha}`, {
export const getCommit = async (namespace: string, name: string, sha: string): Promise<Commit> => {
const response = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/commits/${sha}`, {
headers,
credentials: "same-origin",
})
Expand All @@ -91,8 +91,8 @@ export const getCommit = async (repoId: string, sha: string): Promise<Commit> =>
return commit
}

export const listStatuses = async (repoId: string, sha: string): Promise<{state: StatusState, statuses: Status[]}> => {
const response = await _fetch(`${instance}/api/v1/repos/${repoId}/commits/${sha}/statuses`, {
export const listStatuses = async (namespace: string, name: string, sha: string): Promise<{state: StatusState, statuses: Status[]}> => {
const response = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/commits/${sha}/statuses`, {
headers,
credentials: "same-origin",
})
Expand Down
4 changes: 2 additions & 2 deletions ui/src/apis/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const mapDataToConfig = (data: ConfigData): Config => {
}
}

export const getConfig = async (repoId: string): Promise<Config> => {
const response = await _fetch(`${instance}/api/v1/repos/${repoId}/config`, {
export const getConfig = async (namespace: string, name: string): Promise<Config> => {
const response = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/config`, {
headers,
credentials: "same-origin",
})
Expand Down
24 changes: 12 additions & 12 deletions ui/src/apis/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ export const searchDeployments = async (statuses: DeploymentStatusEnum[], owned:
return deployments
}

export const listDeployments = async (repoId: string, env: string, status: string, page: number, perPage: number): Promise<Deployment[]> => {
const deployments: Deployment[] = await _fetch(`${instance}/api/v1/repos/${repoId}/deployments?env=${env}&status=${status}&page=${page}&per_page=${perPage}`, {
export const listDeployments = async (namespace: string, name: string, env: string, status: string, page: number, perPage: number): Promise<Deployment[]> => {
const deployments: Deployment[] = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments?env=${env}&status=${status}&page=${page}&per_page=${perPage}`, {
headers,
credentials: 'same-origin',
})
Expand All @@ -180,8 +180,8 @@ export const listDeployments = async (repoId: string, env: string, status: strin
return deployments
}

export const getDeployment = async (id: string, number: number): Promise<Deployment> => {
const deployment = await _fetch(`${instance}/api/v1/repos/${id}/deployments/${number}`, {
export const getDeployment = async (namespace: string, name: string, number: number): Promise<Deployment> => {
const deployment = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments/${number}`, {
headers,
credentials: 'same-origin',
})
Expand All @@ -191,13 +191,13 @@ export const getDeployment = async (id: string, number: number): Promise<Deploym
return deployment
}

export const createDeployment = async (repoId: string, type: DeploymentType = DeploymentType.Commit, ref: string, env: string): Promise<Deployment> => {
export const createDeployment = async (namespace: string, name: string, type: DeploymentType = DeploymentType.Commit, ref: string, env: string): Promise<Deployment> => {
const body = JSON.stringify({
type,
ref,
env
})
const response = await _fetch(`${instance}/api/v1/repos/${repoId}/deployments`, {
const response = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments`, {
headers,
credentials: 'same-origin',
method: "POST",
Expand All @@ -220,11 +220,11 @@ export const createDeployment = async (repoId: string, type: DeploymentType = De
return deployment
}

export const updateDeploymentStatusCreated = async (id: string, number: number): Promise<Deployment> => {
export const updateDeploymentStatusCreated = async (namespace: string, name: string, number: number): Promise<Deployment> => {
const body = JSON.stringify({
status: "created"
})
const response = await _fetch(`${instance}/api/v1/repos/${id}/deployments/${number}`, {
const response = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments/${number}`, {
headers,
credentials: 'same-origin',
method: "PATCH",
Expand All @@ -244,8 +244,8 @@ export const updateDeploymentStatusCreated = async (id: string, number: number):
return deployment
}

export const rollbackDeployment = async (repoId: string, number: number): Promise<Deployment> => {
const response = await _fetch(`${instance}/api/v1/repos/${repoId}/deployments/${number}/rollback`, {
export const rollbackDeployment = async (namespace: string, name: string, number: number): Promise<Deployment> => {
const response = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments/${number}/rollback`, {
headers,
credentials: 'same-origin',
method: "POST",
Expand All @@ -267,8 +267,8 @@ export const rollbackDeployment = async (repoId: string, number: number): Promis
return deployment
}

export const listDeploymentChanges = async (repoId: string, number: number, page = 1, perPage = 30): Promise<Commit[]> => {
const res = await _fetch(`${instance}/api/v1/repos/${repoId}/deployments/${number}/changes?page=${page}&per_page=${perPage}`, {
export const listDeploymentChanges = async (namespace: string, name: string, number: number, page = 1, perPage = 30): Promise<Commit[]> => {
const res = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/deployments/${number}/changes?page=${page}&per_page=${perPage}`, {
headers,
credentials: 'same-origin',
})
Expand Down
4 changes: 2 additions & 2 deletions ui/src/apis/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sync } from "./sync"
import {
listRepos,
searchRepo,
getRepo,
updateRepo,
activateRepo,
deactivateRepo,
Expand Down Expand Up @@ -44,7 +44,7 @@ import { subscribeEvents } from "./events"
export {
sync,
listRepos,
searchRepo,
getRepo,
updateRepo,
activateRepo,
deactivateRepo,
Expand Down
14 changes: 7 additions & 7 deletions ui/src/apis/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StatusCodes } from "http-status-codes"
import { instance, headers } from "./setting"
import { _fetch } from "./_base"
import { UserData, mapDataToUser } from "./user"
import { Repo, Lock, User, HttpForbiddenError, HttpUnprocessableEntityError } from "../models"
import { Lock, User, HttpForbiddenError, HttpUnprocessableEntityError } from "../models"

interface LockData {
id: number
Expand All @@ -29,8 +29,8 @@ const mapDataToLock = (data: LockData): Lock => {
}
}

export const listLocks = async (repo: Repo): Promise<Lock[]> => {
const locks = await _fetch(`${instance}/api/v1/repos/${repo.id}/locks`, {
export const listLocks = async (namespace: string, name: string): Promise<Lock[]> => {
const locks = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/locks`, {
headers,
credentials: 'same-origin',
})
Expand All @@ -40,8 +40,8 @@ export const listLocks = async (repo: Repo): Promise<Lock[]> => {
return locks
}

export const lock = async (repo: Repo, env: string): Promise<Lock> => {
const res = await _fetch(`${instance}/api/v1/repos/${repo.id}/locks`, {
export const lock = async (namespace: string, name: string, env: string): Promise<Lock> => {
const res = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/locks`, {
headers,
credentials: 'same-origin',
method: "POST",
Expand All @@ -62,8 +62,8 @@ export const lock = async (repo: Repo, env: string): Promise<Lock> => {
return lock
}

export const unlock = async (repo: Repo, lock: Lock): Promise<void> => {
const res = await _fetch(`${instance}/api/v1/repos/${repo.id}/locks/${lock.id}`, {
export const unlock = async (namespace: string, name: string, id: number): Promise<void> => {
const res = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/locks/${id}`, {
headers,
credentials: 'same-origin',
method: "DELETE",
Expand Down
6 changes: 3 additions & 3 deletions ui/src/apis/perm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { instance, headers } from './setting'
import { _fetch } from "./_base"
import { mapDataToUser, UserData } from "./user"
import { mapDataToRepo, RepoData } from "./repo"
import { Repo, Perm } from '../models'
import { Perm } from '../models'

interface PermData{
repo_perm: string
Expand All @@ -26,8 +26,8 @@ const mapDataToPerm = (data: PermData): Perm => {
}
}

export const listPerms = async (repo: Repo, q: string, page = 1, perPage = 30): Promise<Perm[]> => {
const perms: Perm[] = await _fetch(`${instance}/api/v1/repos/${repo.id}/perms?q=${q}&page=${page}&per_page=${perPage}`, {
export const listPerms = async (namespace: string, name: string, q: string, page = 1, perPage = 30): Promise<Perm[]> => {
const perms: Perm[] = await _fetch(`${instance}/api/v1/repos/${namespace}/${name}/perms?q=${q}&page=${page}&per_page=${perPage}`, {
headers,
credentials: "same-origin"
})
Expand Down
Loading