add: project unit list

This commit is contained in:
vilet.yy 2021-03-17 13:50:26 +08:00
parent a14459da50
commit 8f98a83379
4 changed files with 48 additions and 3 deletions

View File

@ -1,4 +1,8 @@
class Projects::ProjectUnitsController < Projects::BaseController
def index
@project_units = @project.project_units
end
def create
if current_user.admin? || @project.owner?(current_user)
ActiveRecord::Base.transaction do

View File

@ -261,8 +261,46 @@ attachments |array|附件
Remember — a happy kitten is an authenticated kitten!
</aside>
## 更改项目导航
更改项目导航信息
## 项目模块信息
项目模块信息
> 示例:
```shell
curl -X GET \
http://localhost:3000/api/yystopf/ceshi/project_units.json
```
```javascript
await octokit.request('GET /api/yystopf/ceshi/project_units')
```
### HTTP 请求
`GET /api/yystopf/ceshi/project_units`
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|type |string|模块名称 |
> 返回的JSON示例:
```json
[
{
"type": "code"
},
{
"type": "pulls"
},
{
"type": "issues"
}
]
```
## 更改项目模块展示
更改项目模块展示
> 示例:

View File

@ -0,0 +1,3 @@
json.array! @project_units do |unit|
json.type unit.unit_type
end

View File

@ -529,7 +529,7 @@ Rails.application.routes.draw do
scope module: :projects do
resources :teams, only: [:index, :create, :destroy]
resources :project_units, only: [:create]
resources :project_units, only: [:index, :create]
scope do
get(
'/blob/*id/diff',