Skip to content

Commit

Permalink
Address CR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba committed May 10, 2022
1 parent 63c69e6 commit 5b3dc19
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('<PolicyAdd />', () => {
expect(exists('featureStatesDropdown')).toBe(false);
});

test('include all features', async () => {
test('include all features by default', async () => {
const { actions } = testBed;

// Complete step 2
Expand All @@ -269,6 +269,7 @@ describe('<PolicyAdd />', () => {

expect(requestUrl).toBe(`${API_BASE_PATH}policies`);
expect(parsedReqBody.config).toEqual({
includeGlobalState: true,
featureStates: [],
});
});
Expand All @@ -293,6 +294,7 @@ describe('<PolicyAdd />', () => {

expect(requestUrl).toBe(`${API_BASE_PATH}policies`);
expect(parsedReqBody.config).toEqual({
includeGlobalState: true,
featureStates: ['kibana'],
});
});
Expand Down Expand Up @@ -320,7 +322,10 @@ describe('<PolicyAdd />', () => {
const parsedReqBody = JSON.parse((requestBody as Record<string, any>).body);

expect(requestUrl).toBe(`${API_BASE_PATH}policies`);
expect(parsedReqBody.config).toEqual({ featureStates: [FEATURE_STATES_NONE_OPTION] });
expect(parsedReqBody.config).toEqual({
includeGlobalState: true,
featureStates: [FEATURE_STATES_NONE_OPTION],
});
});
});

Expand Down Expand Up @@ -358,7 +363,7 @@ describe('<PolicyAdd />', () => {
snapshotName: SNAPSHOT_NAME,
schedule: DEFAULT_POLICY_SCHEDULE,
repository: repository.name,
config: { featureStates: [] },
config: { featureStates: [], includeGlobalState: true },
retention: {
expireAfterValue: Number(EXPIRE_AFTER_VALUE),
expireAfterUnit: 'd', // default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { setupEnvironment } from './helpers';
import { getPolicy } from '../../test/fixtures';
import { setupPoliciesListPage, PoliciesListTestBed } from './helpers/policy_list.helpers';

const POLICY_WITH_GLOBAL_STATE = getPolicy({
const POLICY_WITH_GLOBAL_STATE_AND_FEATURES = getPolicy({
name: 'with_state',
retention: { minCount: 1 },
config: { includeGlobalState: true, featureStates: ['kibana'] },
Expand All @@ -33,13 +33,13 @@ describe('<PolicyList />', () => {
beforeEach(async () => {
httpRequestsMockHelpers.setLoadPoliciesResponse({
policies: [
POLICY_WITH_GLOBAL_STATE,
POLICY_WITH_GLOBAL_STATE_AND_FEATURES,
POLICY_WITHOUT_GLOBAL_STATE,
POLICY_WITH_JUST_GLOBAL_STATE,
],
});
httpRequestsMockHelpers.setGetPolicyResponse(POLICY_WITH_GLOBAL_STATE.name, {
policy: POLICY_WITH_GLOBAL_STATE,
httpRequestsMockHelpers.setGetPolicyResponse(POLICY_WITH_GLOBAL_STATE_AND_FEATURES.name, {
policy: POLICY_WITH_GLOBAL_STATE_AND_FEATURES,
});

testBed = await setupPoliciesListPage(httpSetup);
Expand All @@ -61,7 +61,7 @@ describe('<PolicyList />', () => {
test('should show feature states if include global state is enabled', async () => {
const { find, actions } = testBed;

// Assert against first resutl shown in the table, which should have includeGlobalState enabled
// Assert against first result shown in the table, which should have includeGlobalState enabled
await actions.clickPolicyAt(0);

expect(find('includeGlobalState.value').text()).toEqual('Yes');
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('<PolicyList />', () => {
policy: POLICY_WITH_JUST_GLOBAL_STATE,
});

// Assert against third resutl shown in the table, which should have just includeGlobalState enabled
// Assert against third result shown in the table, which should have just includeGlobalState enabled
await actions.clickPolicyAt(2);

expect(find('includeGlobalState.value').text()).toEqual('Yes');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export const PolicyForm: React.FunctionComponent<Props> = ({
// when creating the local state for the form and also set featureStates to be an empty array, which
// for the API it means that it will include all featureStates.
featureStates: [],
// IncludeGlobalState is set as default by the api, so we want to replicate that behaviour in our
// form state so that it gets explicitly represented in the request.
includeGlobalState: true,
...(originalPolicy.config || {}),
},
retention: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ export const RestoreSnapshotStepLogistics: React.FunctionComponent<StepProps> =
defaultMessage="Restores the configuration, history, and other data stored in Elasticsearch by a feature such as Elasticsearch security."
/>

{/* Only display callout if includeFeatureState is enabled and the snapshot was created by ES 7.12+ */}
{semverGt(version, '7.12.0') && isFeatureStatesToggleEnabled && (
<>
<EuiSpacer size="s" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const PolicyFeatureStatesSummary: React.FunctionComponent<SnapshotConfig>
<EuiDescriptionListTitle>
<FormattedMessage
id="xpack.snapshotRestore.summary.policyFeatureStatesLabel"
defaultMessage="Include feature state"
defaultMessage="Include feature state {hasSpecificFeatures, plural, one {from} other {}}"
values={{ hasSpecificFeatures: !hasNoFeatureStates && !hasAllFeatureStates ? 1 : 0 }}
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription data-test-subj="value">
Expand All @@ -48,13 +49,7 @@ export const PolicyFeatureStatesSummary: React.FunctionComponent<SnapshotConfig>
/>
)}
{!hasNoFeatureStates && !hasAllFeatureStates && (
<>
<FormattedMessage
id="xpack.snapshotRestore.summary.policyFeatureStatesFromLabel"
defaultMessage="Only from:"
/>{' '}
<CollapsibleFeatureStatesList featureStates={featureStates} />
</>
<CollapsibleFeatureStatesList featureStates={featureStates} />
)}
</EuiDescriptionListDescription>
</EuiDescriptionList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const SnapshotFeatureStatesSummary: React.FunctionComponent<SnapshotConfi
<EuiDescriptionListTitle>
<FormattedMessage
id="xpack.snapshotRestore.summary.snapshotFeatureStatesLabel"
defaultMessage="Include feature state"
defaultMessage="Include feature state {hasSpecificFeatures, plural, one {from} other {}}"
values={{ hasSpecificFeatures: !hasNoFeatureStates ? 1 : 0 }}
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription data-test-subj="value">
Expand All @@ -40,13 +41,7 @@ export const SnapshotFeatureStatesSummary: React.FunctionComponent<SnapshotConfi
defaultMessage="No"
/>
) : (
<>
<FormattedMessage
id="xpack.snapshotRestore.summary.snapshotFeatureStatesFromLabel"
defaultMessage="Only from:"
/>{' '}
<CollapsibleFeatureStatesList featureStates={featureStates} />
</>
<CollapsibleFeatureStatesList featureStates={featureStates} />
)}
</EuiDescriptionListDescription>
</EuiDescriptionList>
Expand Down

0 comments on commit 5b3dc19

Please sign in to comment.