Skip to content

Commit

Permalink
Add changelog and fix minor issues
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
  • Loading branch information
abbyhu2000 committed Dec 2, 2022
1 parent b38646f commit 488beb5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [MD] Tweak multiple data source design doc [#2724](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2724)
- Corrected README and help command of osd-plugin-helpers ([#2810](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2810))
- Add `current-usage.md` and more details to `README.md` of `charts` plugin ([#2695](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2695))
- [Doc] Add readme for global query persistence ([#3001](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3001))

### 🛠 Maintenance

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Global query parameters

Current there are five plugins that have implemented global data persistence ability in Opensearch Dashboards, and they are visualize, discover, timeline, dashboards, and vis-builder. Global query parameters include globally pinned filters, time range and time refresh intervals. These parameters are not only persisted across the action of refresh, but also persisted among all the plugins that have global data persistence ability.
As of 12/1/2022, there are five plugins that have implemented global data persistence ability in OpenSearch Dashboards, and they are visualize, discover, Timeline, dashboards, and vis-builder. Global query parameters include globally pinned filters, time range and time refresh intervals. These parameters are not only persisted across the action of refresh, but also persisted among all the plugins that have global data persistence ability.

For example, we set a specific time range and time refresh interval when trying to a new visualization. When we navigate to the dashboard page, we can see the previous time range and time refresh interval that are set within the visualization app are still there. However, when we create a filter, it will only be persisted within that specific plugin since it is not a global filter. We can make a filter become a global filter by selecting
`Pin across all apps`. Only global filters are persisted across all other globally persistent plugins within the application.

# Steps to add global data persistence ability to a plugin

1. Call [`createOsdUrlTracker()`](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/051656069a5b319f114416c6657af43358b92fae/src/plugins/opensearch_dashboards_utils/public/state_management/url/osd_url_tracker.ts#L68) in the set up function within public/plugin.ts
1. Call [`createOsdUrlTracker()`](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/opensearch_dashboards_utils/public/state_management/url/osd_url_tracker.ts) in the set up function within public/plugin.ts
* declare two private variables: `appStateUpdater` observable and `stopUrlTracking()`
```ts
private appStateUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
Expand Down Expand Up @@ -51,7 +51,7 @@ For example, we set a specific time range and time refresh interval when trying
};
```

2. Set [`osdUrlStateStorage()`](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/051656069a5b319f114416c6657af43358b92fae/src/plugins/opensearch_dashboards_utils/public/state_sync/state_sync_state_storage/create_osd_url_state_storage.ts#L83) service
2. Set [`osdUrlStateStorage()`](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/opensearch_dashboards_utils/public/state_sync/state_sync_state_storage/create_osd_url_state_storage.ts#L83) service
* when setting the plugin services, set osdUrlStateStorage service by calling `createOsdUrlStateStorage()` with the current history, useHash and withNotifyErrors

```ts
Expand Down Expand Up @@ -91,9 +91,10 @@ For example, we set a specific time range and time refresh interval when trying
}, [query, osdUrlStateStorage, pathname]);
```

4. If not, add query services from data plugin
4. If not already, add query services from data plugin
* in public/plugin_services.ts, add query services

```ts
export const [getQueryService, setQueryService] = createGetterSetter<DataPublicPluginStart['query']>('Query');
```

0 comments on commit 488beb5

Please sign in to comment.