Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Add Permissions Error Toasts and Input Validation Errors #196

Conversation

davidcui1225
Copy link
Contributor

Issue #, if available:
N/A
Description of changes:
Added permissions error checks for all API calls to return Permissions Error toasts if the user doesn't have proper permissions. Also added input validation errors on Create/Edit to inform the user if they have fields that are invalid.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

kibana-reports/public/components/app.tsx Outdated Show resolved Hide resolved
@@ -183,7 +183,8 @@ describe('<Main /> panel', () => {
await act(() => promise);
});

test('test error toasts posted', async () => {
// skipping test for now after multiple error toasts created, need to refine mock values and test
Copy link
Member

Choose a reason for hiding this comment

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

Add a TODO here

Copy link
Member

Choose a reason for hiding this comment

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

It's just one test case, why not do it in this PR

Copy link
Member

Choose a reason for hiding this comment

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

Will you add test in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add in another PR

Comment on lines +184 to +201
<div class="euiToast euiToast--danger" id="permissionsMissingErrorToast">
<p class="euiScreenReaderOnly">A new notification appears</p>
<div class="euiToastHeader euiToastHeader--withBody" aria-label="Notification" data-test-subj="euiToastHeader">
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" class="euiIcon euiIcon--medium euiToastHeader__icon" focusable="false" role="img" aria-hidden="true">
<path fill-rule="evenodd" d="M7.59 10.059L7.35 5.18h1.3L8.4 10.06h-.81zm.394 1.901a.61.61 0 01-.448-.186.606.606 0 01-.186-.444c0-.174.062-.323.186-.446a.614.614 0 01.448-.184c.169 0 .315.06.44.182.124.122.186.27.186.448a.6.6 0 01-.189.446.607.607 0 01-.437.184zM2 14a1 1 0 01-.878-1.479l6-11a1 1 0 011.756 0l6 11A1 1 0 0114 14H2zm0-1h12L8 2 2 13z"></path>
</svg>
<span class="euiToastHeader__title">Error generating report.</span>
</div>
<button type="button" class="euiToast__closeButton" aria-label="Dismiss toast" data-test-subj="toastCloseButton">
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" class="euiIcon euiIcon--medium euiIcon-isLoaded" focusable="false" role="img" aria-hidden="true">
<path d="M7.293 8L3.146 3.854a.5.5 0 11.708-.708L8 7.293l4.146-4.147a.5.5 0 01.708.708L8.707 8l4.147 4.146a.5.5 0 01-.708.708L8 8.707l-4.146 4.147a.5.5 0 01-.708-.708L7.293 8z"></path>
</svg>
</button>
<div class="euiText euiText--small euiToastBody">
<p>Insufficient permissions. Reach out to your Kibana administrator.</p>
</div>
</div>
`
Copy link
Member

Choose a reason for hiding this comment

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

Np: define these html code snippet as html files or constants, then import them here when using.

Copy link
Member

@zhongnansu zhongnansu left a comment

Choose a reason for hiding this comment

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

Please add test case back or plan another PR to do that soon

@davidcui1225 davidcui1225 merged commit 210cda2 into opendistro-for-elasticsearch:dev Nov 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants