Browse Source

improve repo/datasets

master
yan 5 years ago
parent
commit
e17cbf25e0
7 changed files with 37 additions and 7 deletions
  1. +3
    -1
      custom/templates/repo/header.tmpl
  2. +6
    -0
      models/repo.go
  3. +1
    -1
      models/repo_unit.go
  4. +1
    -0
      modules/auth/repo_form.go
  5. +5
    -5
      routers/repo/dataset.go
  6. +12
    -0
      routers/repo/setting.go
  7. +9
    -0
      templates/repo/settings/options.tmpl

+ 3
- 1
custom/templates/repo/header.tmpl View File

@@ -97,9 +97,11 @@
</a>
{{end}}

<a class="{{if.PageIsDataset}}active{{end}} item" href="{{.RepoLink}}/datasets">
{{if .Permission.CanRead $.UnitTypeDatasets}}
<a class="{{if .PageIsDataset}}active{{end}} item" href="{{.RepoLink}}/datasets">
{{svg "octicon-file-submodule" 16}} {{.i18n.Tr "datasets"}}
</a>
{{end}}

{{if .Permission.CanRead $.UnitTypeIssues}}
<a class="{{if .PageIsIssueList}}active{{end}} item" href="{{.RepoLink}}/issues">


+ 6
- 0
models/repo.go View File

@@ -1070,6 +1070,12 @@ func CreateRepository(ctx DBContext, doer, u *User, repo *Repository) (err error
Type: tp,
Config: &PullRequestsConfig{AllowMerge: true, AllowRebase: true, AllowRebaseMerge: true, AllowSquash: true},
})
} else if tp == UnitTypeDatasets {
units = append(units, RepoUnit{
RepoID: repo.ID,
Type: tp,
Config: &DatasetConfig{EnableDataset: true},
})
} else {
units = append(units, RepoUnit{
RepoID: repo.ID,


+ 1
- 1
models/repo_unit.go View File

@@ -114,7 +114,7 @@ func (cfg *PullRequestsConfig) IsMergeStyleAllowed(mergeStyle MergeStyle) bool {
}

type DatasetConfig struct {
EnableTest bool
EnableDataset bool
}

// FromDB fills up a IssuesConfig from serialized format.


+ 1
- 0
modules/auth/repo_form.go View File

@@ -120,6 +120,7 @@ type RepoSettingForm struct {
EnablePrune bool

// Advanced settings
EnableDataset bool
EnableWiki bool
EnableExternalWiki bool
ExternalWikiURL string


+ 5
- 5
routers/repo/dataset.go View File

@@ -60,11 +60,11 @@ func DatasetIndex(ctx *context.Context) {
var dataset *models.Dataset
if len(datasets) > 0 { //TODO check list is single item
dataset = datasets[len(datasets)-1]
}
err = models.GetDatasetAttachments(dataset)
if err != nil {
ctx.ServerError("GetDatasetAttachments", err)
return
err = models.GetDatasetAttachments(dataset)
if err != nil {
ctx.ServerError("GetDatasetAttachments", err)
return
}
}

// TODO permission


+ 12
- 0
routers/repo/setting.go View File

@@ -211,6 +211,18 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
// as an error on the UI for this action
ctx.Data["Err_RepoName"] = nil

if form.EnableDataset && !models.UnitTypeDatasets.UnitGlobalDisabled() {
units = append(units, models.RepoUnit{
RepoID: repo.ID,
Type: models.UnitTypeDatasets,
Config: &models.DatasetConfig{
EnableDataset: form.EnableDataset,
},
})
} else if !models.UnitTypeDatasets.UnitGlobalDisabled() {
deleteUnitTypes = append(deleteUnitTypes, models.UnitTypeDatasets)
}

if form.EnableWiki && form.EnableExternalWiki && !models.UnitTypeExternalWiki.UnitGlobalDisabled() {
if !validation.IsValidExternalURL(form.ExternalWikiURL) {
ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error"))


+ 9
- 0
templates/repo/settings/options.tmpl View File

@@ -141,6 +141,15 @@
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="advanced">

{{$isDatasetEnabled := .Repository.UnitEnabled $.UnitTypeDatasets }}
<div class="inline field">
<label>{{.i18n.Tr "repo.dataset"}}</label>
<div class="ui checkbox">
<input class="enable-system" name="enable_dataset" type="checkbox" {{if $isDatasetEnabled}}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.dataset_desc"}}</label>
</div>
</div>

{{$isWikiEnabled := or (.Repository.UnitEnabled $.UnitTypeWiki) (.Repository.UnitEnabled $.UnitTypeExternalWiki)}}
<div class="inline field">
<label>{{.i18n.Tr "repo.wiki"}}</label>


Loading…
Cancel
Save