Skip to content
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

[AMBARI-24142] Show/Hide config-section not working for Ranger and Ra… #1577

Merged
merged 3 commits into from Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions ambari-web/app/mappers/configs/themes_mapper.js
Expand Up @@ -142,6 +142,7 @@ App.themesMapper = App.QuickDataMapper.create({
var parsedSubSection = this.parseIt(subSection, this.get("subSectionConfig"));
parsedSubSection.section_id = parsedSection.id;
parsedSubSection.id = parsedSubSection.name + '_' + serviceName + '_' + themeName;
parsedSubSection.theme_name = themeName;

this.loadSubSectionTabs(subSection, parsedSubSection);
if (parsedSubSection['depends_on']) {
Expand All @@ -167,6 +168,7 @@ App.themesMapper = App.QuickDataMapper.create({
subSection['subsection-tabs'].forEach(function (subSectionTab) {
var parsedSubSectionTab = this.parseIt(subSectionTab, this.get("subSectionTabConfig"));
parsedSubSectionTab.sub_section_id = parsedSubSection.id;
parsedSubSectionTab.theme_name = parsedSubSection.theme_name;
if (parsedSubSectionTab['depends_on']) {
subSectionTabConditions.push(parsedSubSectionTab);
}
Expand Down
8 changes: 6 additions & 2 deletions ambari-web/app/mixins/common/configs/enhanced_configs.js
Expand Up @@ -826,9 +826,13 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
if (valueAttributes && !Em.none(valueAttributes.visible)) {
let themeResource;
if (subsectionCondition.get('type') === 'subsection') {
themeResource = App.SubSection.find().findProperty('name', subsectionConditionName);
themeResource = App.SubSection.find().find(function (subsection) {
return subsection.get('name') === subsectionConditionName && subsectionCondition.get('id').toLowerCase().includes(subsection.get('themeName').toLowerCase());
});
} else if (subsectionCondition.get('type') === 'subsectionTab') {
themeResource = App.SubSectionTab.find().findProperty('name', subsectionConditionName);
themeResource = App.SubSectionTab.find().find(function (subsectionTab) {
return subsectionTab.get('name') === subsectionConditionName && subsectionCondition.get('id').toLowerCase().includes(subsectionTab.get('themeName').toLowerCase());
});
}
themeResource.set('isHiddenByConfig', !valueAttributes.visible);
themeResource.get('configs').setEach('hiddenBySection', !valueAttributes.visible);
Expand Down
5 changes: 5 additions & 0 deletions ambari-web/app/models/configs/theme/sub_section.js
Expand Up @@ -27,6 +27,11 @@ App.SubSection = DS.Model.extend({
*/
name: DS.attr('string'),

/**
* theme from which this is coming from , eg: default, database, credentials, etc.
*/
themeName: DS.attr('string'),

/**
* @type {string}
*/
Expand Down
5 changes: 5 additions & 0 deletions ambari-web/app/models/configs/theme/sub_section_tab.js
Expand Up @@ -27,6 +27,11 @@ App.SubSectionTab = DS.Model.extend({
*/
name: DS.attr('string'),

/**
* theme from which this is coming from , eg: default, database, credentials, etc.
*/
themeName: DS.attr('string'),

/**
* @type {string}
*/
Expand Down
19 changes: 12 additions & 7 deletions ambari-web/test/mappers/configs/themes_mapper_test.js
Expand Up @@ -219,7 +219,8 @@ describe('App.themeMapper', function () {
"name": "SSEC1",
"row_index": 2,
"row_span": 5,
"section_id": 1
"section_id": 1,
"theme_name": "t1",
}
]);
});
Expand All @@ -239,7 +240,8 @@ describe('App.themeMapper', function () {
"name": "SSEC1",
"row_index": 2,
"row_span": 5,
"section_id": 1
"section_id": 1,
"theme_name": "t1"
}],
'subsection'
]);
Expand All @@ -260,7 +262,8 @@ describe('App.themeMapper', function () {
"name": "SSEC1",
"row_index": 2,
"row_span": 5,
"section_id": 1
"section_id": 1,
"theme_name": "t1"
}
]);
});
Expand Down Expand Up @@ -293,30 +296,32 @@ describe('App.themeMapper', function () {
});

it('mapThemeConditions should be called', function() {
App.themesMapper.loadSubSectionTabs(subSection, {id: 2});
App.themesMapper.loadSubSectionTabs(subSection, {id: 2, theme_name: "t1"});
expect(App.themesMapper.mapThemeConditions.getCall(0).args).to.be.eql([
[{
"depends_on": [],
"display_name": "sec1",
"id": "SEC1",
"is_active": true,
"name": "SEC1",
"sub_section_id": 2
"sub_section_id": 2,
"theme_name": "t1"
}],
'subsectionTab'
]);
});

it('App.store.safeLoadMany should be called', function() {
App.themesMapper.loadSubSectionTabs(subSection, {id: 2});
App.themesMapper.loadSubSectionTabs(subSection, {id: 2, theme_name: "t1"});
expect(App.store.safeLoadMany.getCall(0).args[1]).to.be.eql([
{
"depends_on": [],
"display_name": "sec1",
"id": "SEC1",
"is_active": true,
"name": "SEC1",
"sub_section_id": 2
"sub_section_id": 2,
"theme_name": "t1"
}
]);
});
Expand Down