From 9cf216179a239b8e41f979ad2595555e1bad81fc Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Thu, 28 Apr 2022 08:49:37 -0700 Subject: [PATCH] feat: refresh sessions list view in desktop (#1069) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 🎸 add a refresh button to sessions list view in desktop --- addons/core/translations/actions/en-us.yaml | 3 +- .../addon/components/rose/button/index.js | 5 +++ .../components/rose/loading-button/index.hbs | 18 ++++++++ .../components/rose/loading-button/index.js | 20 +++++++++ .../rose/loading-button/index.stories.mdx | 43 +++++++++++++++++++ .../addon/styles/rose/components/_index.scss | 1 + .../rose/components/_loading-button.scss | 10 +++++ .../rose/components/toolbar/_toolbar.scss | 4 +- .../styles/rose/variables/color/_sass.scss | 2 +- .../app/components/rose/loading-button.js | 1 + .../components/rose/loading-button-test.js | 20 +++++++++ .../routes/scopes/scope/projects/sessions.js | 10 +++++ .../scopes/scope/projects/sessions/index.hbs | 3 ++ 13 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 addons/rose/addon/components/rose/button/index.js create mode 100644 addons/rose/addon/components/rose/loading-button/index.hbs create mode 100644 addons/rose/addon/components/rose/loading-button/index.js create mode 100644 addons/rose/addon/components/rose/loading-button/index.stories.mdx create mode 100644 addons/rose/addon/styles/rose/components/_loading-button.scss create mode 100644 addons/rose/app/components/rose/loading-button.js create mode 100644 addons/rose/tests/integration/components/rose/loading-button-test.js diff --git a/addons/core/translations/actions/en-us.yaml b/addons/core/translations/actions/en-us.yaml index 9c97d54af..2bdd086cd 100644 --- a/addons/core/translations/actions/en-us.yaml +++ b/addons/core/translations/actions/en-us.yaml @@ -36,4 +36,5 @@ toggle-secret: Toggle secret visibility minimize: Minimize fullscreen: Fullscreen clear-all-filters: Clear all filters -learn-more: Learn more \ No newline at end of file +learn-more: Learn more +refresh: Refresh \ No newline at end of file diff --git a/addons/rose/addon/components/rose/button/index.js b/addons/rose/addon/components/rose/button/index.js new file mode 100644 index 000000000..fa54cee1d --- /dev/null +++ b/addons/rose/addon/components/rose/button/index.js @@ -0,0 +1,5 @@ +import Component from '@glimmer/component'; + +export default class RoseButtonComponent extends Component { + // =attributes +} diff --git a/addons/rose/addon/components/rose/loading-button/index.hbs b/addons/rose/addon/components/rose/loading-button/index.hbs new file mode 100644 index 000000000..b5be619a5 --- /dev/null +++ b/addons/rose/addon/components/rose/loading-button/index.hbs @@ -0,0 +1,18 @@ + + {{yield}} + \ No newline at end of file diff --git a/addons/rose/addon/components/rose/loading-button/index.js b/addons/rose/addon/components/rose/loading-button/index.js new file mode 100644 index 000000000..d27678155 --- /dev/null +++ b/addons/rose/addon/components/rose/loading-button/index.js @@ -0,0 +1,20 @@ +import button from '../button/index'; + +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; + +export default class LoadingButton extends button { + // =actions + @tracked isLoading = false; + + @action + async toggleRefresh() { + this.isLoading = true; + try { + await this.args.onClick(); + } catch (e) { + console.error('Error while loading data', e); + } + this.isLoading = false; + } +} diff --git a/addons/rose/addon/components/rose/loading-button/index.stories.mdx b/addons/rose/addon/components/rose/loading-button/index.stories.mdx new file mode 100644 index 000000000..bd791219c --- /dev/null +++ b/addons/rose/addon/components/rose/loading-button/index.stories.mdx @@ -0,0 +1,43 @@ +import { Meta, Story, Preview } from '@storybook/addon-docs/blocks'; +import { hbs } from 'ember-cli-htmlbars'; +import { action } from '@storybook/addon-actions'; +import { text, boolean, select } from '@storybook/addon-knobs'; + + + +# LoadingButton + +A simple LoadingButton component with two states - loading and reloading that renders an HTML `