Idea hub, loading indicator to show "Creating new draft"
See original GitHub issueFeature Description
This is in reference to the comment on this issue: https://github.com/google/site-kit-wp/issues/3357#issuecomment-841365269
Objective: To show a loading indicator when the user clicks the “Start a draft” button on the idea hub widget.
Proposed solution:
- User clicks on the “Start a draft” button
- An overlay appears on this idea row - (Grey area in the screenshot below)
- Overlay shows a standard loading spinner or an illustration with these copies:
“Creating draft post for you”, then the copy changes to "Draft post created",
- As a nice to have, the number on the “Drafts” tab does a subtle animation to show that it increased.

Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- When creating an Idea Hub draft post via the widget, the current state of the progress should be indicated:
- While the API request is happening, it should say “Creating draft” (in italic) instead of the three icons on the right - essentially the text should display in the same spot where it for ideas with a draft post has the “View draft” link.
- Once the API request is completed, the idea should not immediately disappear from the current tab; instead the text above should change to “Draft created” for 2 seconds. After those 2 seconds, the whole idea item should disappear (since anyway its new place now is in the “Drafts” tab).
Implementation Brief
- Using
assets/js/modules/idea-hub/datastore/draft-ideas.js,- Add a new action which removes an idea from the list of
newIdeasandsavedIdeasstate variables. - Update
reducerCallbackto remove the code wherenewIdeasandsavedIdeasare updated.
- Add a new action which removes an idea from the list of
- Using
assets/js/modules/idea-hub/datastore/constants.js,- Add 3 constants,
ACTIVITY_IS_PROCESSING,ACTIVITY_CREATING_DRAFT,ACTIVITY_DRAFT_CREATED, each having the same values.
- Add 3 constants,
- Using
assets/js/modules/idea-hub/datastore/idea-state.js,- Add
activitiesto the initial state with an empty object as default value. - Add the
setActivityaction which has 2 parameters:key: string which will be the idea namevalue: string which will store the current activity of the idea, i.e whether a draft is being created or has been created.
- The
setActivitywill add thekeyandvalueto theactivitiesobject. - Add the
removeActivityaction which as a single parameter:key: string, which is the idea name.
removeActivitywill remove the item with the specified key from theactivitiesobject.- Add the
getActivityselector which will return the activity of an idea based on thekeyfrom theactivitiesobject. - The above implementation should be inspired by the
core/uidata store.
- Add
- Using
assets/js/modules/idea-hub/components/dashboard/DashboardIdeasWidget/Idea.js,- Update the
handleCreatefunction to dispatch thesetActivityaction, with the idea name askeyand the value set toACTIVITY_CREATING_DRAFT. This should be done beforecreateIdeaDraftPostis called. - After
createIdeaDraftPosthas been called,- call
setActivitywith the value set toACTIVITY_DRAFT_CREATEDand idea name askey. - After another 2 seconds, dispatch the
removeActivityaction and then the newly created action created as per the first bullets point of the IB should be called, to remove the idea from the list.
- call
- Get the activity of the idea via the
getActivityselector passing the idea name askey. Based on the value returned by the selector,- Update the conditions to display the buttons in the
googlesitekit-idea-hub__idea--actionscontainer ifgetActivityisACTIVITY_CREATING_DRAFT. If it’s the case, then the buttons are not rendered and the text as per the AC should be rendered, in italic and right aligned, similar to the “View Draft” text. - A small spinner should be prepended to the text when a draft is being created. The
CircularProgresscomponent, imported from@material-ui/corecan be used. The size of theCircularProgressshould be10, with a margin right of8pxfrom the text. - Update the conditions to display the buttons in the
googlesitekit-idea-hub__idea--actionscontainer ifgetActivityisACTIVITY_DRAFT_CREATED. If it’s the case, then the buttons are not rendered and the text as per the AC should be rendered when a draft has been created, in italic and right aligned, similar to the “View Draft” text. - Remove the
isProcessingstate variable and instead use thegetActivitystate variable and set the value toACTIVITY_IS_PROCESSINGwhereisProcessingwas originall set totrue. Where it was set tofalse, useremoveActivity. - Update the
disabledlogic for buttons to check for whengetActivityisACTIVITY_IS_PROCESSING.
- Update the conditions to display the buttons in the
- Update the
Test Coverage
- Tests to be added for the new actions and selectors.
Visual Regression Changes
- N/A
QA Brief
- See screenshot in AC. Click on button to start a draft for a few ideas
- Verify that animation happens as per AC
Changelog entry
- Add loading indicator to the Idea Hub widget when a new draft is being created
Issue Analytics
- State:
- Created 2 years ago
- Comments:24 (7 by maintainers)
Top Results From Across the Web
Create an automated indicator
Analytics Hub for a specific indicator · View ... Create a latest score visualization for a score widget ... View solution training progress....
Read more >Loading | Application Loading Indicator Overlay | ion-loading
The ion-loading overlay indicates activity while blocking user interaction. The loading indicator appears on top of the app's content, and can be dismissed....
Read more >Quickstart for Projects - GitHub Docs
Adding draft issues to your project ... For more information about creating an organization, see "Creating a new ... Type your idea, then...
Read more >Changelog | ArcGIS Hub
Stay up-to-date with new features, changes, and fixes for ArcGIS Hub. ... Loading indicator and error message for download side panel added.
Read more >23 Pro Tips for Running a Successful Business - HubSpot Blog
Revenue, gross profit, and cash flow impact the present and future of every company. But to create sustained value, businesses need to make...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@danielgent could you please create a follow-up PR to adjust styles for the loading text to display it without line breaks?
QA Update: ⚠️
@danielgent In the AC it doesn’t mention the loading icon which appears to the right hand side of the
Creating drafttext. The icon does shift the text a little further over to the left so doesn’t align with theDraft createdtext when that appears… Not sure if this icon should be there?https://user-images.githubusercontent.com/73545194/125090645-dc12be00-e0cf-11eb-9efc-68f8e8ef3995.mp4