2021-05-11 17:58:19 +03:00
|
|
|
/*
|
|
|
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React, {useState} from "react";
|
|
|
|
|
|
|
|
import QuestionDialog from './QuestionDialog';
|
|
|
|
import { _t } from '../../../languageHandler';
|
|
|
|
import Field from "../elements/Field";
|
|
|
|
import SdkConfig from "../../../SdkConfig";
|
|
|
|
import {IDialogProps} from "./IDialogProps";
|
|
|
|
import SettingsStore from "../../../settings/SettingsStore";
|
|
|
|
import {submitFeedback} from "../../../rageshake/submit-rageshake";
|
2021-05-11 19:30:33 +03:00
|
|
|
import StyledCheckbox from "../elements/StyledCheckbox";
|
|
|
|
import Modal from "../../../Modal";
|
|
|
|
import InfoDialog from "./InfoDialog";
|
|
|
|
import AccessibleButton from "../elements/AccessibleButton";
|
|
|
|
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
|
|
|
import {Action} from "../../../dispatcher/actions";
|
|
|
|
import {USER_LABS_TAB} from "./UserSettingsDialog";
|
2021-05-11 17:58:19 +03:00
|
|
|
|
|
|
|
interface IProps extends IDialogProps {
|
|
|
|
featureId: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const BetaFeedbackDialog: React.FC<IProps> = ({featureId, onFinished}) => {
|
|
|
|
const info = SettingsStore.getBetaInfo(featureId);
|
|
|
|
|
|
|
|
const [comment, setComment] = useState("");
|
2021-05-11 19:30:33 +03:00
|
|
|
const [canContact, setCanContact] = useState(false);
|
2021-05-11 17:58:19 +03:00
|
|
|
|
|
|
|
const sendFeedback = async (ok: boolean) => {
|
|
|
|
if (!ok) return onFinished(false);
|
|
|
|
|
2021-05-11 19:30:33 +03:00
|
|
|
submitFeedback(SdkConfig.get().bug_report_endpoint_url, info.feedbackLabel, comment, canContact);
|
2021-05-11 17:58:19 +03:00
|
|
|
onFinished(true);
|
2021-05-11 19:30:33 +03:00
|
|
|
|
|
|
|
Modal.createTrackedDialog("Beta Dialog Sent", featureId, InfoDialog, {
|
|
|
|
title: _t("Beta feedback"),
|
|
|
|
description: _t("Thank you for your feedback, we really appreciate it."),
|
|
|
|
button: _t("Done"),
|
|
|
|
hasCloseButton: false,
|
|
|
|
fixedWidth: false,
|
|
|
|
});
|
2021-05-11 17:58:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return (<QuestionDialog
|
2021-05-11 19:30:33 +03:00
|
|
|
className="mx_BetaFeedbackDialog"
|
2021-05-11 17:58:19 +03:00
|
|
|
hasCancelButton={true}
|
|
|
|
title={_t("Beta feedback")}
|
|
|
|
description={<React.Fragment>
|
2021-05-11 19:30:33 +03:00
|
|
|
<div className="mx_BetaFeedbackDialog_subheading">
|
|
|
|
{ _t(info.feedbackSubheading) }
|
|
|
|
|
|
|
|
{ _t("Your platform and username will be noted to help us use your feedback as much as we can.")}
|
|
|
|
|
|
|
|
<AccessibleButton kind="link" onClick={() => {
|
|
|
|
onFinished(false);
|
|
|
|
defaultDispatcher.dispatch({
|
|
|
|
action: Action.ViewUserSettings,
|
|
|
|
initialTabId: USER_LABS_TAB,
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
{ _t("To leave the beta, visit your settings.") }
|
|
|
|
</AccessibleButton>
|
|
|
|
</div>
|
2021-05-11 17:58:19 +03:00
|
|
|
|
|
|
|
<Field
|
|
|
|
id="feedbackComment"
|
2021-05-11 19:30:33 +03:00
|
|
|
label={_t("Feedback")}
|
2021-05-11 17:58:19 +03:00
|
|
|
type="text"
|
|
|
|
autoComplete="off"
|
|
|
|
value={comment}
|
|
|
|
element="textarea"
|
|
|
|
onChange={(ev) => {
|
|
|
|
setComment(ev.target.value);
|
|
|
|
}}
|
|
|
|
/>
|
2021-05-11 19:30:33 +03:00
|
|
|
|
|
|
|
<StyledCheckbox
|
|
|
|
checked={canContact}
|
|
|
|
onClick={e => setCanContact((e.target as HTMLInputElement).checked)}
|
|
|
|
>
|
|
|
|
{ _t("You may contact me if you have any follow up questions") }
|
|
|
|
</StyledCheckbox>
|
2021-05-11 17:58:19 +03:00
|
|
|
</React.Fragment>}
|
|
|
|
button={_t("Send feedback")}
|
|
|
|
buttonDisabled={!comment}
|
|
|
|
onFinished={sendFeedback}
|
|
|
|
/>);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BetaFeedbackDialog;
|