| @@ -97,9 +97,11 @@ | |||||
| </a> | </a> | ||||
| {{end}} | {{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"}} | {{svg "octicon-file-submodule" 16}} {{.i18n.Tr "datasets"}} | ||||
| </a> | </a> | ||||
| {{end}} | |||||
| {{if .Permission.CanRead $.UnitTypeIssues}} | {{if .Permission.CanRead $.UnitTypeIssues}} | ||||
| <a class="{{if .PageIsIssueList}}active{{end}} item" href="{{.RepoLink}}/issues"> | <a class="{{if .PageIsIssueList}}active{{end}} item" href="{{.RepoLink}}/issues"> | ||||
| @@ -1070,6 +1070,12 @@ func CreateRepository(ctx DBContext, doer, u *User, repo *Repository) (err error | |||||
| Type: tp, | Type: tp, | ||||
| Config: &PullRequestsConfig{AllowMerge: true, AllowRebase: true, AllowRebaseMerge: true, AllowSquash: true}, | 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 { | } else { | ||||
| units = append(units, RepoUnit{ | units = append(units, RepoUnit{ | ||||
| RepoID: repo.ID, | RepoID: repo.ID, | ||||
| @@ -114,7 +114,7 @@ func (cfg *PullRequestsConfig) IsMergeStyleAllowed(mergeStyle MergeStyle) bool { | |||||
| } | } | ||||
| type DatasetConfig struct { | type DatasetConfig struct { | ||||
| EnableTest bool | |||||
| EnableDataset bool | |||||
| } | } | ||||
| // FromDB fills up a IssuesConfig from serialized format. | // FromDB fills up a IssuesConfig from serialized format. | ||||
| @@ -120,6 +120,7 @@ type RepoSettingForm struct { | |||||
| EnablePrune bool | EnablePrune bool | ||||
| // Advanced settings | // Advanced settings | ||||
| EnableDataset bool | |||||
| EnableWiki bool | EnableWiki bool | ||||
| EnableExternalWiki bool | EnableExternalWiki bool | ||||
| ExternalWikiURL string | ExternalWikiURL string | ||||
| @@ -60,11 +60,11 @@ func DatasetIndex(ctx *context.Context) { | |||||
| var dataset *models.Dataset | var dataset *models.Dataset | ||||
| if len(datasets) > 0 { //TODO check list is single item | if len(datasets) > 0 { //TODO check list is single item | ||||
| dataset = datasets[len(datasets)-1] | 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 | // TODO permission | ||||
| @@ -211,6 +211,18 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { | |||||
| // as an error on the UI for this action | // as an error on the UI for this action | ||||
| ctx.Data["Err_RepoName"] = nil | 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 form.EnableWiki && form.EnableExternalWiki && !models.UnitTypeExternalWiki.UnitGlobalDisabled() { | ||||
| if !validation.IsValidExternalURL(form.ExternalWikiURL) { | if !validation.IsValidExternalURL(form.ExternalWikiURL) { | ||||
| ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error")) | ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error")) | ||||
| @@ -141,6 +141,15 @@ | |||||
| {{.CsrfTokenHtml}} | {{.CsrfTokenHtml}} | ||||
| <input type="hidden" name="action" value="advanced"> | <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)}} | {{$isWikiEnabled := or (.Repository.UnitEnabled $.UnitTypeWiki) (.Repository.UnitEnabled $.UnitTypeExternalWiki)}} | ||||
| <div class="inline field"> | <div class="inline field"> | ||||
| <label>{{.i18n.Tr "repo.wiki"}}</label> | <label>{{.i18n.Tr "repo.wiki"}}</label> | ||||