|
19 | 19 | class SummaryHook(HookBaseClass): |
20 | 20 | """Hook that defines the summary overlay content and display details.""" |
21 | 21 |
|
| 22 | + FALLBACK_SETTINGS = { |
| 23 | + "no_item_error": { |
| 24 | + "icon_path": ":/tk_multi_publish2/publish_failed.png", |
| 25 | + # Hardcoding line break so the message displays on 2 lines. |
| 26 | + # Usage of label's own word wrap displays the message below on 3 lines. |
| 27 | + # NOTE: Can't manually break line when using <p></p> |
| 28 | + "label_text": "Could not find any\nitems to publish.", |
| 29 | + "info_text": "For more details, <b><u>click here</u></b>.", |
| 30 | + "publish_again_text": "", |
| 31 | + }, |
| 32 | + "success": { |
| 33 | + "icon_path": ":/tk_multi_publish2/publish_complete.png", |
| 34 | + "label_text": "Publish\nComplete", |
| 35 | + "info_text": "For more details, <b><u>click here</u></b>.", |
| 36 | + "publish_again_text": "To publish again, <b><u>click here</u></b>.", |
| 37 | + }, |
| 38 | + "fail": { |
| 39 | + "icon_path": ":/tk_multi_publish2/publish_failed.png", |
| 40 | + "label_text": "Publish\nFailed!", |
| 41 | + "info_text": "For more details, <b><u>click here</u></b>.", |
| 42 | + "publish_again_text": "", |
| 43 | + }, |
| 44 | + "loading": { |
| 45 | + "icon_path": ":/tk_multi_publish2/overlay_loading.png", |
| 46 | + "label_text": "Loading and processing", |
| 47 | + "info_text": "Hold tight while we analyze your data", |
| 48 | + "publish_again_text": "", |
| 49 | + }, |
| 50 | + } |
| 51 | + """Fallback settings to use for `.show_using_settings`, uses v2.10.7 values.""" |
| 52 | + |
22 | 53 | @property |
23 | 54 | def settings(self) -> dict[str, Any]: |
24 | 55 | """Return the settings that are available for this hook.""" |
25 | 56 | return self.parent.get_setting("summary").get("settings") or {} |
26 | 57 |
|
27 | | - def no_items_error(self, summary_overlay) -> dict[str, Any]: |
| 58 | + def show_using_settings(self, key, summary_overlay) -> dict[str, Any]: |
28 | 59 | """Return UI values for the no items collected summary state.""" |
| 60 | + settings = self.settings.get(key, {}) |
| 61 | + fallback = self.FALLBACK_SETTINGS.get(key, {}) |
29 | 62 | return summary_overlay.show_summary( |
30 | | - ":/tk_multi_publish2/publish_failed.png", |
31 | | - # Hardcoding line break so the message displays on 2 lines. |
32 | | - # Usage of label's own word wrap displays the message below on 3 lines. |
33 | | - # NOTE: Can't manually break line when using <p></p> |
34 | | - "Could not find any\nitems to publish.", |
35 | | - "For more details, <b><u>click here</u></b>.", |
| 63 | + settings.get("icon_path", fallback["icon_path"]), |
| 64 | + settings.get("label_text", fallback["label_text"]), |
| 65 | + settings.get("info_text", fallback["info_text"]), |
| 66 | + publish_again_text=settings.get( |
| 67 | + "publish_again_text", fallback["publish_again_text"] |
| 68 | + ), |
36 | 69 | ) |
37 | 70 |
|
| 71 | + def no_items_error(self, summary_overlay) -> dict[str, Any]: |
| 72 | + """Return UI values for the no items collected summary state.""" |
| 73 | + return self.show_using_settings("no_item_error", summary_overlay) |
| 74 | + |
38 | 75 | def success(self, summary_overlay) -> dict[str, Any]: |
39 | 76 | """Return UI values for the publish success summary state.""" |
40 | | - return summary_overlay.show_summary( |
41 | | - ":/tk_multi_publish2/publish_complete.png", |
42 | | - "Publish\nComplete", |
43 | | - "For more details, <b><u>click here</u></b>.", |
44 | | - publish_again_text="To publish again, <b><u>click here</u></b>.", |
45 | | - ) |
| 77 | + return self.show_using_settings("success", summary_overlay) |
46 | 78 |
|
47 | 79 | def fail(self, summary_overlay) -> dict[str, Any]: |
48 | 80 | """Return UI values for the publish fail summary state.""" |
49 | | - return summary_overlay.show_summary( |
50 | | - ":/tk_multi_publish2/publish_failed.png", |
51 | | - "Publish\nFailed!", |
52 | | - "For more details, <b><u>click here</u></b>.", |
53 | | - ) |
| 81 | + return self.show_using_settings("fail", summary_overlay) |
54 | 82 |
|
55 | 83 | def loading(self, summary_overlay) -> dict[str, Any]: |
56 | 84 | """Return UI values for the loading summary state.""" |
57 | | - return summary_overlay.show_summary( |
58 | | - ":/tk_multi_publish2/overlay_loading.png", |
59 | | - "Loading and processing", |
60 | | - "Hold tight while we analyze your data", |
61 | | - ) |
| 85 | + return self.show_using_settings("loading", summary_overlay) |
0 commit comments