|
28 | 28 | <input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required> |
29 | 29 | </div> |
30 | 30 | </div> |
31 | | - <div class="field"> |
32 | | - <div class="ui top attached header"> |
33 | | - <div class="ui compact small menu small-menu-items repo-editor-menu"> |
34 | | - <a class="active item" data-tab="write">{{svg "octicon-code"}} {{if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.new_file"}}{{else}}{{ctx.Locale.Tr "repo.editor.edit_file"}}{{end}}</a> |
35 | | - <a class="item" data-tab="preview" data-preview-url="{{.Repository.Link}}/markup" data-preview-context-ref="{{.RepoLink}}/src/{{.RefTypeNameSubURL}}">{{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}}</a> |
36 | | - {{if not .IsNewFile}} |
37 | | - <a class="item" data-tab="diff" hx-params="context,content" hx-vals='{"context":"{{.BranchLink}}"}' hx-include="#edit_area" hx-swap="innerHTML" hx-target=".tab[data-tab='diff']" hx-indicator=".tab[data-tab='diff']" hx-post="{{.RepoLink}}/_preview/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">{{svg "octicon-diff"}} {{ctx.Locale.Tr "repo.editor.preview_changes"}}</a> |
38 | | - {{end}} |
| 31 | + {{if .IsFileText}} |
| 32 | + <div class="field"> |
| 33 | + <div class="ui top attached header"> |
| 34 | + <div class="ui compact small menu small-menu-items repo-editor-menu"> |
| 35 | + <a class="active item" data-tab="write">{{svg "octicon-code"}} {{if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.new_file"}}{{else}}{{ctx.Locale.Tr "repo.editor.edit_file"}}{{end}}</a> |
| 36 | + <a class="item" data-tab="preview" data-preview-url="{{.Repository.Link}}/markup" data-preview-context-ref="{{.RepoLink}}/src/{{.RefTypeNameSubURL}}">{{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}}</a> |
| 37 | + {{if not .IsNewFile}} |
| 38 | + <a class="item" data-tab="diff" hx-params="context,content" hx-vals='{"context":"{{.BranchLink}}"}' hx-include="#edit_area" hx-swap="innerHTML" hx-target=".tab[data-tab='diff']" hx-indicator=".tab[data-tab='diff']" hx-post="{{.RepoLink}}/_preview/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">{{svg "octicon-diff"}} {{ctx.Locale.Tr "repo.editor.preview_changes"}}</a> |
| 39 | + {{end}} |
| 40 | + </div> |
39 | 41 | </div> |
40 | | - </div> |
41 | | - <div class="ui bottom attached segment tw-p-0"> |
42 | | - <div class="ui active tab tw-rounded-b" data-tab="write"> |
43 | | - <textarea id="edit_area" name="content" class="tw-hidden" data-id="repo-{{.Repository.Name}}-{{.TreePath}}" |
44 | | - data-previewable-extensions="{{.PreviewableExtensions}}" |
45 | | - data-line-wrap-extensions="{{.LineWrapExtensions}}">{{.FileContent}}</textarea> |
46 | | - <div class="editor-loading is-loading"></div> |
| 42 | + <div class="ui bottom attached segment tw-p-0"> |
| 43 | + <div class="ui active tab tw-rounded-b" data-tab="write"> |
| 44 | + <textarea id="edit_area" name="content" class="tw-hidden" data-id="repo-{{.Repository.Name}}-{{.TreePath}}" |
| 45 | + data-previewable-extensions="{{.PreviewableExtensions}}" |
| 46 | + data-line-wrap-extensions="{{.LineWrapExtensions}}">{{.FileContent}}</textarea> |
| 47 | + <div class="editor-loading is-loading"></div> |
| 48 | + </div> |
| 49 | + <div class="ui tab tw-px-4 tw-py-3" data-tab="preview"> |
| 50 | + {{ctx.Locale.Tr "loading"}} |
| 51 | + </div> |
| 52 | + <div class="ui tab" data-tab="diff"> |
| 53 | + <div class="tw-p-16"></div> |
| 54 | + </div> |
47 | 55 | </div> |
48 | | - <div class="ui tab tw-px-4 tw-py-3" data-tab="preview"> |
49 | | - {{ctx.Locale.Tr "loading"}} |
| 56 | + </div> |
| 57 | + {{else if .IsFileTooLarge}} |
| 58 | + <div class="field"> |
| 59 | + <div class="ui segment tw-text-center"> |
| 60 | + <h4 class="tw-font-semibold tw-mb-2">{{ctx.Locale.Tr "repo.editor.file_too_large_not_editable"}}</h4> |
| 61 | + <p>{{ctx.Locale.Tr "repo.editor.file_not_editable_hint"}}</p> |
50 | 62 | </div> |
51 | | - <div class="ui tab" data-tab="diff"> |
52 | | - <div class="tw-p-16"></div> |
| 63 | + </div> |
| 64 | + {{else}} |
| 65 | + <div class="field"> |
| 66 | + <div class="ui segment tw-text-center"> |
| 67 | + <h4 class="tw-font-semibold tw-mb-2">{{ctx.Locale.Tr "repo.editor.binary_file_not_editable"}}</h4> |
| 68 | + <p>{{ctx.Locale.Tr "repo.editor.file_not_editable_hint"}}</p> |
53 | 69 | </div> |
54 | 70 | </div> |
55 | | - </div> |
| 71 | + {{end}} |
56 | 72 | {{template "repo/editor/commit_form" .}} |
57 | 73 | </form> |
58 | 74 | </div> |
|
0 commit comments