-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Workspace]Fix error toasts in sample data page #8842
[Workspace]Fix error toasts in sample data page #8842
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8842 +/- ##
==========================================
+ Coverage 60.84% 60.85% +0.01%
==========================================
Files 3808 3808
Lines 91193 91199 +6
Branches 14408 14409 +1
==========================================
+ Hits 55485 55503 +18
+ Misses 32165 32153 -12
Partials 3543 3543
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -41,11 +41,16 @@ export async function listSampleDataSets(dataSourceId) { | |||
return await getServices().http.get(sampleDataUrl, { query }); | |||
} | |||
|
|||
const isWorkspaceEnabled = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking if it is workspaceEnabled or permissionControlEnabled.
@@ -144,6 +148,59 @@ export class WorkspaceUiSettingsClientWrapper { | |||
return wrapperOptions.client.update(type, id, attributes, options); | |||
}; | |||
|
|||
const deleteUiSettingsWithWorkspace = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const deleteUiSettingsWithWorkspace = async ( | |
const deleteWithDefaultIndexPatternCheck = async ( |
export async function installSampleDataSet(id, sampleDataDefaultIndex, dataSourceId) { | ||
const query = buildQuery(dataSourceId); | ||
await getServices().http.post(`${sampleDataUrl}/${id}`, { query }); | ||
|
||
if (getServices().uiSettings.isDefault('defaultIndex')) { | ||
if (!isWorkspaceEnabled() && getServices().uiSettings.isDefault('defaultIndex')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a unit test to cover this condition check?
src/plugins/workspace/server/saved_objects/workspace_ui_settings_client_wrapper.ts
Outdated
Show resolved
Hide resolved
src/plugins/home/server/services/sample_data/routes/uninstall.ts
Outdated
Show resolved
Hide resolved
src/plugins/workspace/server/saved_objects/workspace_ui_settings_client_wrapper.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Lin Wang <[email protected]>
Signed-off-by: Lin Wang <[email protected]>
Signed-off-by: Lin Wang <[email protected]>
02ddf54
to
c1b9545
Compare
Signed-off-by: Lin Wang <[email protected]>
* Set default index pattern when workspace disabled Signed-off-by: Lin Wang <[email protected]> * Move saved objects first to avoid partial deleted Signed-off-by: Lin Wang <[email protected]> * Skip ui setting update for non workspace admin Signed-off-by: Lin Wang <[email protected]> * Add UT for sample_data_client Signed-off-by: Lin Wang <[email protected]> * Changeset file for PR #8842 created/updated --------- Signed-off-by: Lin Wang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit af429b6) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Set default index pattern when workspace disabled * Move saved objects first to avoid partial deleted * Skip ui setting update for non workspace admin * Add UT for sample_data_client * Changeset file for PR #8842 created/updated --------- (cherry picked from commit af429b6) Signed-off-by: Lin Wang <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
) * Set default index pattern when workspace disabled Signed-off-by: Lin Wang <[email protected]> * Move saved objects first to avoid partial deleted Signed-off-by: Lin Wang <[email protected]> * Skip ui setting update for non workspace admin Signed-off-by: Lin Wang <[email protected]> * Add UT for sample_data_client Signed-off-by: Lin Wang <[email protected]> * Changeset file for PR opensearch-project#8842 created/updated --------- Signed-off-by: Lin Wang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Signed-off-by: Federico Silva <[email protected]>
Description
This PR addresses the issue of error toasts appearing on the sample data page when installing or uninstalling sample data. The root cause was that the user did not have permission to update UI settings at the workspace level. The changes in this PR include:
Screenshot
No UI Changes
Testing the changes
yarn osd bootstrap --single-version loose
.config/opensearch_dashboards.yml
:yarn start --no-base-path
.Changelog
Check List
yarn test:jest
yarn test:jest_integration