Skip to content

Commit 266ed1f

Browse files
committed
Try some things
1 parent 39d8d9d commit 266ed1f

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

templates/user/settings/keys_ssh.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
{{.i18n.Tr "settings.manage_ssh_keys"}}
33
<div class="ui right">
44
{{if not .DisableSSH }}
5-
<div id="add-ssh-button" class="ui blue tiny show-panel swap button" data-show-button="#cancel-ssh-button" data-panel="#add-ssh-key-panel">
5+
<div id="add-ssh-button" class="ui blue tiny show-panel button" data-toggle-button="#cancel-ssh-button" data-panel="#add-ssh-key-panel">
66
{{.i18n.Tr "settings.add_key"}}
77
</div>
88
{{else}}
99
<div class="ui blue tiny button disabled">{{.i18n.Tr "settings.ssh_disabled"}}</div>
1010
{{end}}
11-
<button id="cancel-ssh-button" class="ui red tiny hide-panel swap button" data-show-button="#add-ssh-button" data-panel="#add-ssh-key-panel" style="display: none;">
11+
<button id="cancel-ssh-button" class="ui red tiny hide-panel button" data-toggle-button="#add-ssh-button" data-panel="#add-ssh-key-panel" style="display: none;">
1212
{{.i18n.Tr "cancel"}}
1313
</button>
1414
</div>

web_src/js/features/common-global.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,30 @@ export function initGlobalLinkActions() {
283283
});
284284
}
285285

286+
function handlePanelButtonToggle($btn) {
287+
const toggleButton = $btn.data('toggle-button');
288+
if (!toggleButton) return;
289+
$(toggleButton).show();
290+
$btn.hide();
291+
}
292+
286293
export function initGlobalButtons() {
287294
$('.show-panel.button').on('click', function () {
288-
$($(this).data('panel')).show();
295+
if ($($(this).data('panel')).is(":visible")) {
296+
$($(this).data('panel')).hide();
297+
} else {
298+
$($(this).data('panel')).show();
299+
}
300+
handlePanelButtonToggle($(this));
289301
});
290302

291303
$('.hide-panel.button').on('click', function () {
292-
$($(this).data('panel')).hide();
304+
if ($($(this).data('panel')).is(":visible")) {
305+
$($(this).data('panel')).hide();
306+
} else {
307+
$($(this).data('panel')).show();
308+
}
309+
handlePanelButtonToggle($(this));
293310
});
294311

295312
$('.swap.button').on('click', function () {

0 commit comments

Comments
 (0)