terriajs
Version:
Geospatial data visualization platform.
44 lines • 2.15 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import i18next from "i18next";
import { runInAction } from "mobx";
import { RawButton } from "../../Styled/Button";
import Text from "../../Styled/Text";
import CustomComponent from "./CustomComponent";
import parseCustomMarkdownToReact from "./parseCustomMarkdownToReact";
function showFeedback(viewState) {
runInAction(() => {
viewState.feedbackFormIsVisible = true;
viewState.terria.notificationState.dismissCurrentNotification();
});
}
export const FeedbackLink = (props) =>
// If we have feedbackUrl = show button to open feedback dialog
props.viewState.terria.configParameters.feedbackUrl ? (_jsx(RawButton, { fullWidth: true, onClick: () => showFeedback(props.viewState), css: `
text-align: left;
`, children: _jsx(Text, { bold: true, isLink: true, children: parseCustomMarkdownToReact(props.feedbackMessage
? props.feedbackMessage
: i18next.t("models.raiseError.notificationFeedback")) }) })) : (
// If we only have supportEmail - show message and the email address
_jsx(_Fragment, { children: parseCustomMarkdownToReact(props.emailMessage
? `${props.emailMessage} ${props.viewState.terria.supportEmail}`
: i18next.t("models.raiseError.notificationFeedbackEmail", {
email: props.viewState.terria.supportEmail
})) }));
/**
* A `<feedbacklink>` custom component, which displays a feedback button (if the feature is enabled), or an email address.
*/
export default class FeedbackLinkCustomComponent extends CustomComponent {
static componentName = "feedbacklink";
get name() {
return FeedbackLinkCustomComponent.componentName;
}
get attributes() {
return ["email-message", "feedback-message"];
}
processNode(context, node, _children) {
if (!context.viewState)
return undefined;
return (_jsx(FeedbackLink, { viewState: context.viewState, emailMessage: node.attribs?.["email-message"], feedbackMessage: node.attribs?.["feedback-message"] }));
}
}
//# sourceMappingURL=FeedbackLinkCustomComponent.js.map