Skip to content

Commit

Permalink
Make survey link configuration
Browse files Browse the repository at this point in the history
Add a new config in the yml file so user can enable/disable the survey link in the helper menu.

Signed-off-by: abbyhu2000 <[email protected]>
  • Loading branch information
abbyhu2000 committed Mar 30, 2023
1 parent 27613c8 commit 96b86f4
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 83 deletions.
14 changes: 1 addition & 13 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,4 @@
#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

# opensearchDashboards.link:
# community:
# text: "Community"
# url: "https://forum.opensearch.org/"
# giveFeedback:
# text: "Give feedback"
# url: "https://amazonmr.au1.qualtrics.com/jfe/form/SV_1BxJNrtCo4LbweW"
# openAnIssue: ""
# text: "Open an issue in GitHub"
# url: "https://github.com/opensearch-project/OpenSearch-Dashboards/issues/new/choose"

#opensearchDashboards.survey.url: "https://amazonmr.au1.qualtrics.com/jfe/form/SV_1BxJNrtCo4LbweW"
2 changes: 1 addition & 1 deletion src/core/public/chrome/chrome_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class ChromeService {
onIsLockedUpdate={setIsNavDrawerLocked}
isLocked$={getIsNavDrawerLocked$}
branding={injectedMetadata.getBranding()}
isSurveyAllowed={injectedMetadata.getIsSurveyAllowed()}
survey={injectedMetadata.getSurvey()}
/>
),

Expand Down
5 changes: 1 addition & 4 deletions src/core/public/chrome/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
* under the License.
*/

export const OPENSEARCH_DASHBOARDS_FEEDBACK_LINK = 'https://github.com/opensearch-project';
export const OPENSEARCH_DASHBOARDS_ASK_OPENSEARCH_LINK = 'https://github.com/opensearch-project';
export const OPENSEARCH_DASHBOARDS_ASK_OPENSEARCH_LINK = 'https://forum.opensearch.org/';
export const GITHUB_CREATE_ISSUE_LINK =
'https://github.com/opensearch-project/OpenSearch-Dashboards/issues/new/choose';
export const SATISFACTION_SURVEY_LINK =
'https://amazonmr.au1.qualtrics.com/jfe/form/SV_1BxJNrtCo4LbweW';
40 changes: 20 additions & 20 deletions src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

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

export function Header({
Expand All @@ -100,7 +100,7 @@ export function Header({
onIsLockedUpdate,
homeHref,
branding,
isSurveyAllowed,
survey,
...observables
}: HeaderProps) {
const isVisible = useObservable(observables.isVisible$, false);
Expand Down Expand Up @@ -222,7 +222,7 @@ export function Header({
helpSupportUrl$={observables.helpSupportUrl$}
opensearchDashboardsDocLink={opensearchDashboardsDocLink}
opensearchDashboardsVersion={opensearchDashboardsVersion}
isSurveyAllowed={isSurveyAllowed}
surveyLink={survey}
/>
</EuiHeaderSectionItem>
</EuiHeaderSection>
Expand Down
34 changes: 9 additions & 25 deletions src/core/public/chrome/ui/header/header_help_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ import { ExclusiveUnion } from '@elastic/eui';
import { combineLatest } from 'rxjs';
import { HeaderExtension } from './header_extension';
import { ChromeHelpExtension } from '../../chrome_service';
import {
GITHUB_CREATE_ISSUE_LINK,
OPENSEARCH_DASHBOARDS_FEEDBACK_LINK,
SATISFACTION_SURVEY_LINK,
} from '../../constants';
import { GITHUB_CREATE_ISSUE_LINK } from '../../constants';

/** @public */
export type ChromeHelpExtensionMenuGitHubLink = EuiButtonEmptyProps & {
Expand Down Expand Up @@ -126,7 +122,7 @@ interface Props {
opensearchDashboardsVersion: string;
useDefaultContent?: boolean;
opensearchDashboardsDocLink: string;
isSurveyAllowed: boolean;
surveyLink?: string;
}

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

Expand All @@ -224,7 +220,7 @@ class HeaderHelpMenuUI extends Component<Props, State> {
<EuiButtonEmpty href={opensearchDashboardsDocLink} target="_blank" size="xs" flush="left">
<FormattedMessage
id="core.ui.chrome.headerGlobalNav.helpMenuOpenSearchDashboardsDocumentationTitle"
defaultMessage="OpenSearch Dashboards documentation"
defaultMessage="Documentation"
/>
</EuiButtonEmpty>

Expand All @@ -233,26 +229,14 @@ class HeaderHelpMenuUI extends Component<Props, State> {
<EuiButtonEmpty href={helpSupportUrl} target="_blank" size="xs" flush="left">
<FormattedMessage
id="core.ui.chrome.headerGlobalNav.helpMenuAskElasticTitle"
defaultMessage="Ask OpenSearch"
defaultMessage="Community"
/>
</EuiButtonEmpty>

<EuiSpacer size="xs" />

{opensearchSurvey}

<EuiButtonEmpty
href={OPENSEARCH_DASHBOARDS_FEEDBACK_LINK}
target="_blank"
size="xs"
flush="left"
>
<FormattedMessage
id="core.ui.chrome.headerGlobalNav.helpMenuGiveFeedbackTitle"
defaultMessage="Give feedback"
/>
</EuiButtonEmpty>

<EuiSpacer size="xs" />

<EuiButtonEmpty
Expand Down Expand Up @@ -348,7 +332,7 @@ class HeaderHelpMenuUI extends Component<Props, State> {
})}
onClick={this.onMenuButtonClick}
>
<EuiIcon type="help" size="m" />
<EuiIcon type="questionInCircle" size="l" />
</EuiHeaderSectionItemButton>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const createSetupContractMock = () => {
getInjectedVars: jest.fn(),
getOpenSearchDashboardsBuildNumber: jest.fn(),
getBranding: jest.fn(),
getIsSurveyAllowed: jest.fn(),
getSurvey: 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,7 +75,7 @@ export interface InjectedMetadataParams {
};
};
branding: Branding;
isSurveyAllowed: boolean;
survey?: string;
};
}

Expand Down Expand Up @@ -148,8 +148,8 @@ export class InjectedMetadataService {
return this.state.branding;
},

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

/** @internal */
Expand Down
6 changes: 4 additions & 2 deletions src/core/server/opensearch_dashboards_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ export const config = {
defaultValue: true,
}),
}),
isSurveyAllowed: schema.boolean({
defaultValue: true,
survey: schema.object({
url: schema.string({
defaultValue: 'https://amazonmr.au1.qualtrics.com/jfe/form/SV_1BxJNrtCo4LbweW',
}),
}),
}),
deprecations,
Expand Down
Loading

0 comments on commit 96b86f4

Please sign in to comment.