Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Exit Button #6763

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion settings.json.docker
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@
"right": [
["importexport", "timeslider", "savedrevision"],
["settings", "embed"],
["showusers"]
["showusers","exit"]
],
"timeslider": [
["timeslider_export", "timeslider_returnToPad"]
Expand Down
2 changes: 1 addition & 1 deletion settings.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@
"right": [
["importexport", "timeslider", "savedrevision"],
["settings", "embed"],
["showusers"]
["showusers"],["exit"]
],
"timeslider": [
["timeslider_export", "timeslider_returnToPad"]
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"pad.toolbar.settings.title": "Settings",
"pad.toolbar.embed.title": "Share and Embed this pad",
"pad.toolbar.showusers.title": "Show the users on this pad",
"pad.toolbar.help.title": "Exit to Home",

"pad.colorpicker.save": "Save",
"pad.colorpicker.cancel": "Cancel",
Expand Down
2 changes: 1 addition & 1 deletion src/node/utils/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ exports.toolbar = {
right: [
['importexport', 'timeslider', 'savedrevision'],
['settings', 'embed'],
['showusers'],
['showusers','exit'],
],
timeslider: [
['timeslider_export', 'timeslider_settings', 'timeslider_returnToPad'],
Expand Down
5 changes: 5 additions & 0 deletions src/node/utils/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ module.exports = {
localizationId: 'timeslider.toolbar.returnbutton',
class: 'buttontext',
},
exit:{
command: 'exit',
localizationId: 'pad.toolbar.exit.title',
class: 'buttonicon buttonicon-exit',
},
},

registerButton(buttonName: string, buttonInfo: any) {
Expand Down
1 change: 1 addition & 0 deletions src/static/css/pad.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@import url("pad/gritter.css");
@import url("pad/loadingbox.css");
@import url("pad/form.css");
@import url("pad/exit-button.css");

html {
font-size: 15px;
Expand Down
8 changes: 8 additions & 0 deletions src/static/css/pad/exit-button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.buttonicon-exit:before {
content: "\2715";
margin-right: 5px;
}

#exit-button {
cursor: pointer;
}
7 changes: 7 additions & 0 deletions src/static/js/pad_editbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ exports.padeditbar = new class {
$('.exportlink').first().trigger('focus');
}
});
this.registerCommand('exit', () => {
console.log('Exit button clicked');
window.location.href = '/';
});

this.registerCommand('showusers', () => {
this.toggleDropDown('users');
Expand Down Expand Up @@ -478,5 +482,8 @@ exports.padeditbar = new class {
.substring(0, document.location.href.lastIndexOf('/'));
}
});



}
}();
4 changes: 4 additions & 0 deletions src/static/js/pad_editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,7 @@ exports.focusOnLine = (ace) => {
}
// End of setSelection / set Y position of editor
};

// toolbar.registerCommand('exit', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be left out

// window.location.href = '/';
// });
4 changes: 3 additions & 1 deletion src/tests/frontend-new/helper/padHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export const setUserName = async (page: Page, userName: string) => {
await page.click("input[data-l10n-id='pad.userlist.entername']");
await page.keyboard.type(userName);
}

export const exitPad = async (page: Page) => {
await page.locator("button[data-l10n-id='pad.toolbar.exit.title']").click();
}

export const showChat = async (page: Page) => {
const chatIcon = page.locator("#chaticon")
Expand Down
8 changes: 8 additions & 0 deletions src/tests/frontend/helper/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ helper.toggleUserList = async () => {
await helper.waitForPromise(() => !isVisible);
};

helper.exitButton = () => helper.padChrome$("button[data-l10n-id='pad.toolbar.exit.title']");

helper.exitPad = async () => {
const button = helper.exitButton();
button.trigger('click');
await helper.waitForPromise(() => window.location.pathname === '/');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test would be good for that :)

};

/**
* Gets the user name input field
*
Expand Down