Skip to content

Commit 4e5e7df

Browse files
authored
Merge pull request #1041 from micedre/export-menu-fix
Fix menu when gitlab is enabled
2 parents dbcb469 + 67f8a64 commit 4e5e7df

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ app.locals.authProviders = {
199199
allowEmailRegister: config.allowEmailRegister
200200
}
201201

202+
// Export/Import menu items
203+
app.locals.enableDropBoxSave = config.isDropboxEnable
204+
app.locals.enableGitHubGist = config.isGitHubEnable
205+
app.locals.enableGitlabSnippets = config.isGitlabSnippetsEnable
206+
202207
app.use(require('./lib/web/baseRouter'))
203208
app.use(require('./lib/web/statusRouter'))
204209
app.use(require('./lib/web/auth'))

lib/config/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ if (config.gitlab && config.gitlab.version !== 'v4' && config.gitlab.version !==
110110
logger.warn('config.js contains wrong version (' + config.gitlab.version + ') for gitlab api; it should be \'v3\' or \'v4\'. Defaulting to v4')
111111
config.gitlab.version = 'v4'
112112
}
113+
// If gitlab scope is api, enable snippets Export/import
114+
config.isGitlabSnippetsEnable = (!config.gitlab.scope || config.gitlab.scope === 'api')
113115

114116
// Only update i18n files in development setups
115117
config.updateI18nFiles = (env === Environment.development)

public/views/codimd/header.ejs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@
3232
</li>
3333
<li role="presentation"><a role="menuitem" class="ui-extra-slide" tabindex="-1" href="#" target="_blank" rel="noopener"><i class="fa fa-tv fa-fw"></i> <%= __('Slide Mode') %></a>
3434
</li>
35-
<% if((typeof github !== 'undefined' && github) || (typeof dropbox !== 'undefined' && dropbox) || (typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api'))) { %>
35+
<% if(enableGitHubGist || enableDropBoxSave || enableGitlabSnippets) { %>
3636
<li class="divider"></li>
3737
<li class="dropdown-header"><%= __('Export') %></li>
3838
<li role="presentation"><a role="menuitem" class="ui-save-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
3939
</li>
40-
<% if(typeof github !== 'undefined' && github) { %>
40+
<% if(enableGitHubGist) { %>
4141
<li role="presentation"><a role="menuitem" class="ui-save-gist" tabindex="-1" href="#" target="_blank" rel="noopener"><i class="fa fa-github fa-fw"></i> Gist</a>
4242
</li>
4343
<% } %>
44-
<% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %>
44+
<% if(enableGitlabSnippets) { %>
4545
<li role="presentation"><a role="menuitem" class="ui-save-snippet" href="#"><i class="fa fa-gitlab fa-fw"></i> Snippet</a>
4646
</li>
4747
<% } %>
@@ -52,7 +52,7 @@
5252
</li>
5353
<li role="presentation"><a role="menuitem" class="ui-import-gist" href="#" data-toggle="modal" data-target="#gistImportModal"><i class="fa fa-github fa-fw"></i> Gist</a>
5454
</li>
55-
<% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %>
55+
<% if(enableGitlabSnippets) { %>
5656
<li role="presentation"><a role="menuitem" class="ui-import-snippet" href="#"><i class="fa fa-gitlab fa-fw"></i> Snippet</a>
5757
</li>
5858
<% } %>
@@ -134,16 +134,16 @@
134134
</li>
135135
<li role="presentation"><a role="menuitem" class="ui-extra-slide" tabindex="-1" href="#" target="_blank" rel="noopener"><i class="fa fa-tv fa-fw"></i> <%= __('Slide Mode') %></a>
136136
</li>
137-
<% if((typeof github !== 'undefined' && github) || (typeof dropbox !== 'undefined' && dropbox) || (typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api'))) { %>
137+
<% if(enableGitHubGist || enableDropBoxSave || enableGitlabSnippets) { %>
138138
<li class="divider"></li>
139139
<li class="dropdown-header"><%= __('Export') %></li>
140140
<li role="presentation"><a role="menuitem" class="ui-save-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
141141
</li>
142-
<% if(typeof github !== 'undefined' && github) { %>
142+
<% if(enableGitHubGist) { %>
143143
<li role="presentation"><a role="menuitem" class="ui-save-gist" tabindex="-1" href="#" target="_blank" rel="noopener"><i class="fa fa-github fa-fw"></i> Gist</a>
144144
</li>
145145
<% } %>
146-
<% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %>
146+
<% if(enableGitlabSnippets) { %>
147147
<li role="presentation"><a role="menuitem" class="ui-save-snippet" href="#"><i class="fa fa-gitlab fa-fw"></i> Snippet</a>
148148
</li>
149149
<% } %>
@@ -154,7 +154,7 @@
154154
</li>
155155
<li role="presentation"><a role="menuitem" class="ui-import-gist" href="#" data-toggle="modal" data-target="#gistImportModal"><i class="fa fa-github fa-fw"></i> Gist</a>
156156
</li>
157-
<% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %>
157+
<% if(enableGitlabSnippets) { %>
158158
<li role="presentation"><a role="menuitem" class="ui-import-snippet" href="#"><i class="fa fa-gitlab fa-fw"></i> Snippet</a>
159159
</li>
160160
<% } %>

0 commit comments

Comments
 (0)