-
Notifications
You must be signed in to change notification settings - Fork 951
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
fix bug: management section id not match the key defined in capabilities #6421
fix bug: management section id not match the key defined in capabilities #6421
Conversation
81ce8d3
to
ca218bb
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6421 +/- ##
==========================================
- Coverage 67.72% 63.96% -3.77%
==========================================
Files 3518 3598 +80
Lines 69638 78266 +8628
Branches 11365 12340 +975
==========================================
+ Hits 47165 50061 +2896
- Misses 19684 25185 +5501
- Partials 2789 3020 +231
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -94,8 +98,9 @@ export class ManagementSectionsService { | |||
|
|||
start({ capabilities }: SectionsServiceStartDeps) { | |||
this.getAllSections().forEach((section) => { | |||
if (capabilities.management.hasOwnProperty(section.id)) { | |||
const sectionCapabilities = capabilities.management[section.id]; | |||
const capabilityId = MANAGEMENT_ID_TO_CAPABILITIES[section.id] || section.id; |
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.
@ruanyl Just curious to know why don't we instead update the Id in the Capabilities to opensearch-dashboards
instead of mapping it here?
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.
@manasvinibs Good question, that's for compatibility, opensearch-dashboards
maybe deep linked, for example, in function test repo.
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.
@kavilla Is there a way to estimate the impact of changing capabilities key from opensearchDashboards
to opensearch-dashboards
in src/plugins/management/server/capabilities_provider.ts
?
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've seen some places in OSD core uses capabilities.management.opensearchDashboards
, also there might other plugins are already using this capability key, changing this key would be a breaking change, so I think it would be better to do key mapping. What do you think? @manasvinibs
@@ -94,8 +98,9 @@ export class ManagementSectionsService { | |||
|
|||
start({ capabilities }: SectionsServiceStartDeps) { | |||
this.getAllSections().forEach((section) => { | |||
if (capabilities.management.hasOwnProperty(section.id)) { | |||
const sectionCapabilities = capabilities.management[section.id]; | |||
const capabilityId = MANAGEMENT_ID_TO_CAPABILITIES[section.id] || section.id; |
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.
Is there an associated test to validate this is working correctly?
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.
+1
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.
@virajsanghvi unit test added
Hi @ruanyl , are we targeting this PR for 2.15 or 2.16? |
Maybe 2.16, haven't got a chance to add unit tests |
Signed-off-by: Yulong Ruan <[email protected]>
374a6dc
to
ea9f4ea
Compare
@virajsanghvi @manasvinibs Could you please take another look at the PR? |
const originalDataSourcesCapability = | ||
DEFAULT_MANAGEMENT_CAPABILITIES.management.opensearchDashboards.dataSources; |
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.
nit: ideally we could mock this over setting it globally, but you do clean it up so not blocking.
@@ -105,4 +106,29 @@ describe('ManagementService', () => { | |||
] | |||
`); | |||
}); | |||
|
|||
it('should disable apps register in opensearchDashboards section', () => { |
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.
Could you help explain how this is testing the "opensearch-dashboards" translation code?
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.
In the capability provider, the capability key is opensearchDashboards
, when registering the default section opensearchDashboards: this.registerSection(OpenSearchDashboardsSection)
, the section id is defined as opensearch-dashboards
and this id was used to retrieve the app status register with capability key opensearchDashboards
.
So we need to do the mapping from opensearch-dashboards
-> opensearchDashboards
Signed-off-by: Yulong Ruan <[email protected]>
…ies (#6421) * fix management section id not match the key defined in capabilities Signed-off-by: Yulong Ruan <[email protected]> * add descriptions on how the PR solved the problme Signed-off-by: Yulong Ruan <[email protected]> --------- Signed-off-by: Yulong Ruan <[email protected]> (cherry picked from commit a65a8aa) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…ies (#6421) (#7634) * fix management section id not match the key defined in capabilities * add descriptions on how the PR solved the problme --------- (cherry picked from commit a65a8aa) Signed-off-by: Yulong Ruan <[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>
Description
The
Dashboards management
section id(opensearch-dashboards
) ofManagement
category doesn't match the id(opensearchDashboards
) defined incapabilities
, the consequence is the following code will never work for apps ofDashboards management
. Even set the capability of the app to false, the nav link still displayed on the UI(it does redirect to home page when accessing the link).The original PR introduced the
id
change is #260@kavilla do you have more context of changing id from
opensearchDashboards
toopensearch-dashboards
?Changelog
Issues Resolved
Screenshot
Testing the changes
Check List
yarn test:jest
yarn test:jest_integration