Skip to content

Commit

Permalink
Show toast on successfull save (#3576)
Browse files Browse the repository at this point in the history
* Show toast on successfull save

We need to make a list of places where this could benefit the user experience.

* Helper method

* Rename
  • Loading branch information
bramkragten authored Sep 3, 2019
1 parent f00ad84 commit a9c9d4c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/panels/config/users/ha-user-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
SYSTEM_GROUP_ID_USER,
SYSTEM_GROUP_ID_ADMIN,
} from "../../../data/user";
import { showSaveSuccessToast } from "../../../util/toast-saved-success";

declare global {
interface HASSDomEvents {
Expand Down Expand Up @@ -150,6 +151,7 @@ class HaUserEditor extends LitElement {
await updateUser(this.hass!, this.user!.id, {
group_ids: [newGroup],
});
showSaveSuccessToast(this, this.hass!);
fireEvent(this, "reload-users");
} catch (err) {
alert(`Group update failed: ${err.message}`);
Expand Down
3 changes: 2 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@
"common": {
"loading": "Loading",
"cancel": "Cancel",
"save": "Save"
"save": "Save",
"successfully_saved": "Successfully saved"
},
"components": {
"entity": {
Expand Down
7 changes: 7 additions & 0 deletions src/util/toast-saved-success.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { showToast } from "./toast";
import { HomeAssistant } from "../types";

export const showSaveSuccessToast = (el: HTMLElement, hass: HomeAssistant) =>
showToast(el, {
message: hass!.localize("ui.common.successfully_saved"),
});

0 comments on commit a9c9d4c

Please sign in to comment.