Skip to content

Commit

Permalink
Make survey link configurable
Browse files Browse the repository at this point in the history
User can disable the display of the survey in the helper menu.

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
  • Loading branch information
abbyhu2000 committed Mar 24, 2023
1 parent 32aadbd commit ac8f8da
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 8 deletions.
2 changes: 2 additions & 0 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,5 @@
#data_source.encryption.wrappingKeyName: 'changeme'
#data_source.encryption.wrappingKeyNamespace: 'changeme'
#data_source.encryption.wrappingKey: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

#opensearchDashboards.isSurveyAllowed: true
1 change: 1 addition & 0 deletions src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export class ChromeService {
onIsLockedUpdate={setIsNavDrawerLocked}
isLocked$={getIsNavDrawerLocked$}
branding={injectedMetadata.getBranding()}
isSurveyAllowed={injectedMetadata.getIsSurveyAllowed()}
/>
),

Expand Down
1 change: 1 addition & 0 deletions src/core/public/chrome/ui/header/header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function mockProps() {
mark: { defaultUrl: '/' },
applicationTitle: 'OpenSearch Dashboards',
},
isSurveyAllowed: true,
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface HeaderProps {
loadingCount$: ReturnType<HttpStart['getLoadingCount$']>;
onIsLockedUpdate: OnIsLockedUpdate;
branding: ChromeBranding;
isSurveyAllowed: boolean;
}

export function Header({
Expand All @@ -99,6 +100,7 @@ export function Header({
onIsLockedUpdate,
homeHref,
branding,
isSurveyAllowed,
...observables
}: HeaderProps) {
const isVisible = useObservable(observables.isVisible$, false);
Expand Down Expand Up @@ -220,6 +222,7 @@ export function Header({
helpSupportUrl$={observables.helpSupportUrl$}
opensearchDashboardsDocLink={opensearchDashboardsDocLink}
opensearchDashboardsVersion={opensearchDashboardsVersion}
isSurveyAllowed={isSurveyAllowed}
/>
</EuiHeaderSectionItem>
</EuiHeaderSection>
Expand Down
23 changes: 15 additions & 8 deletions src/core/public/chrome/ui/header/header_help_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ interface Props {
opensearchDashboardsVersion: string;
useDefaultContent?: boolean;
opensearchDashboardsDocLink: string;
isSurveyAllowed: boolean;
}

interface State {
Expand Down Expand Up @@ -202,8 +203,21 @@ class HeaderHelpMenuUI extends Component<Props, State> {
opensearchDashboardsVersion,
useDefaultContent,
opensearchDashboardsDocLink,
isSurveyAllowed,
} = this.props;
const { helpExtension, helpSupportUrl } = this.state;
const opensearchSurvey = isSurveyAllowed ? (
<div>
<EuiButtonEmpty href={SATISFACTION_SURVEY_LINK} target="_blank" size="xs" flush="left">
<FormattedMessage
id="core.ui.chrome.headerGlobalNav.helpMenuSatisfactionSurveyTitle"
defaultMessage="Satisfaction Survey"
/>
</EuiButtonEmpty>

<EuiSpacer size="xs" />
</div>
) : null;

const defaultContent = useDefaultContent ? (
<Fragment>
Expand All @@ -225,14 +239,7 @@ class HeaderHelpMenuUI extends Component<Props, State> {

<EuiSpacer size="xs" />

<EuiButtonEmpty href={SATISFACTION_SURVEY_LINK} target="_blank" size="xs" flush="left">
<FormattedMessage
id="core.ui.chrome.headerGlobalNav.helpMenuSatisfactionSurveyTitle"
defaultMessage="Satisfaction Survey"
/>
</EuiButtonEmpty>

<EuiSpacer size="xs" />
{opensearchSurvey}

<EuiButtonEmpty
href={OPENSEARCH_DASHBOARDS_FEEDBACK_LINK}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const createSetupContractMock = () => {
getInjectedVars: jest.fn(),
getOpenSearchDashboardsBuildNumber: jest.fn(),
getBranding: jest.fn(),
getIsSurveyAllowed: jest.fn(),
};
setupContract.getCspConfig.mockReturnValue({ warnLegacyBrowsers: true });
setupContract.getOpenSearchDashboardsVersion.mockReturnValue('opensearchDashboardsVersion');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export interface InjectedMetadataParams {
};
};
branding: Branding;
isSurveyAllowed: boolean;
};
}

Expand Down Expand Up @@ -146,6 +147,10 @@ export class InjectedMetadataService {
getBranding: () => {
return this.state.branding;
},

getIsSurveyAllowed: () => {
return this.state.isSurveyAllowed;
},
};
}
}
Expand Down Expand Up @@ -180,6 +185,7 @@ export interface InjectedMetadataSetup {
[key: string]: unknown;
};
getBranding: () => Branding;
getIsSurveyAllowed: () => boolean;
}

/** @internal */
Expand Down
3 changes: 3 additions & 0 deletions src/core/server/opensearch_dashboards_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export const config = {
defaultValue: true,
}),
}),
isSurveyAllowed: schema.boolean({
defaultValue: true,
}),
}),
deprecations,
};
1 change: 1 addition & 0 deletions src/core/server/rendering/rendering_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export class RenderingService {
applicationTitle: brandingAssignment.applicationTitle,
useExpandedHeader: brandingAssignment.useExpandedHeader,
},
isSurveyAllowed: opensearchDashboardsConfig.isSurveyAllowed,
},
};

Expand Down
1 change: 1 addition & 0 deletions src/core/server/rendering/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface RenderingMetadata {
};
};
branding: Branding;
isSurveyAllowed: boolean;
};
}

Expand Down
1 change: 1 addition & 0 deletions src/core/server/rendering/views/template.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function mockProps() {
},
},
branding: injectedMetadata.getBranding(),
isSurveyAllowed: injectedMetadata.getIsSurveyAllowed(),
},
};
}
Expand Down
1 change: 1 addition & 0 deletions src/legacy/server/config/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export default () =>
applicationTitle: Joi.any().default(''),
useExpandedHeader: Joi.boolean().default(true),
}),
isSurveyAllowed: Joi.boolean().default(true),
}).default(),

savedObjects: HANDLED_IN_NEW_PLATFORM,
Expand Down

0 comments on commit ac8f8da

Please sign in to comment.