PLT-327: Add help text for Markdown
Этот коммит содержится в:
41
web/react/components/docs.jsx
Обычный файл
41
web/react/components/docs.jsx
Обычный файл
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
const TextFormatting = require('../utils/text_formatting.jsx');
|
||||||
|
const UserStore = require('../stores/user_store.jsx');
|
||||||
|
|
||||||
|
export default class Docs extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
UserStore.setCurrentUser(global.window.mm_user || {});
|
||||||
|
|
||||||
|
this.state = {text: ''};
|
||||||
|
const errorState = {text: '## 404'};
|
||||||
|
|
||||||
|
if (props.site) {
|
||||||
|
$.get('/static/help/' + props.site + '.md').then((response) => {
|
||||||
|
this.setState({text: response});
|
||||||
|
}, () => {
|
||||||
|
this.setState(errorState);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState(errorState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.state.text)}}
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Docs.defaultProps = {
|
||||||
|
site: ''
|
||||||
|
};
|
||||||
|
Docs.propTypes = {
|
||||||
|
site: React.PropTypes.string
|
||||||
|
};
|
||||||
@@ -295,6 +295,13 @@ export default class Textbox extends React.Component {
|
|||||||
this.resize();
|
this.resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showHelp(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.target.blur();
|
||||||
|
|
||||||
|
global.window.open('/docs/Messaging');
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const previewLinkVisible = this.props.messageText.length > 0;
|
const previewLinkVisible = this.props.messageText.length > 0;
|
||||||
|
|
||||||
@@ -335,12 +342,18 @@ export default class Textbox extends React.Component {
|
|||||||
dangerouslySetInnerHTML={{__html: this.state.preview ? TextFormatting.formatText(this.props.messageText) : ''}}
|
dangerouslySetInnerHTML={{__html: this.state.preview ? TextFormatting.formatText(this.props.messageText) : ''}}
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
<a
|
||||||
|
onClick={this.showHelp}
|
||||||
|
className='textbox-help-link'
|
||||||
|
>
|
||||||
|
{'Help'}
|
||||||
|
</a>
|
||||||
<a
|
<a
|
||||||
style={{visibility: previewLinkVisible ? 'visible' : 'hidden'}}
|
style={{visibility: previewLinkVisible ? 'visible' : 'hidden'}}
|
||||||
onClick={this.showPreview}
|
onClick={this.showPreview}
|
||||||
className='textbox-preview-link'
|
className='textbox-preview-link'
|
||||||
>
|
>
|
||||||
{this.state.preview ? 'Edit message' : 'Preview'}
|
{this.state.preview ? 'Edit' : 'Preview'}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
16
web/react/pages/docs.jsx
Обычный файл
16
web/react/pages/docs.jsx
Обычный файл
@@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
var Docs = require('../components/docs.jsx');
|
||||||
|
|
||||||
|
function setupDocumentationPage(props) {
|
||||||
|
ReactDOM.render(
|
||||||
|
<Docs
|
||||||
|
site={props.Site}
|
||||||
|
/>,
|
||||||
|
document.getElementById('docs')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
global.window.mm_user = global.window.mm_user || {};
|
||||||
|
global.window.setup_documentation_page = setupDocumentationPage;
|
||||||
@@ -47,20 +47,25 @@ body.ios {
|
|||||||
|
|
||||||
.textarea-wrapper {
|
.textarea-wrapper {
|
||||||
position:relative;
|
position:relative;
|
||||||
.textbox-preview-area {
|
.textbox-preview-area {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
.textbox-preview-link {
|
.textbox-preview-link, .textbox-help-link {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
bottom: -23px;
|
bottom: -23px;
|
||||||
right: 0;
|
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.textbox-preview-link {
|
||||||
|
right: 45px;
|
||||||
|
}
|
||||||
|
.textbox-help-link {
|
||||||
|
right: 0;
|
||||||
}
|
}
|
||||||
min-height:36px;
|
min-height:36px;
|
||||||
}
|
}
|
||||||
|
|||||||
1
web/static/help/Messaging.md
Символическая ссылка
1
web/static/help/Messaging.md
Символическая ссылка
@@ -0,0 +1 @@
|
|||||||
|
../../../doc/help/Messaging.md
|
||||||
24
web/templates/docs.html
Обычный файл
24
web/templates/docs.html
Обычный файл
@@ -0,0 +1,24 @@
|
|||||||
|
{{define "docs"}}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
{{template "head" . }}
|
||||||
|
<body class="white">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="inner__wrap">
|
||||||
|
<div class="row content">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div id="docs"></div>
|
||||||
|
</div>
|
||||||
|
<div class="footer-push"></div>
|
||||||
|
</div>
|
||||||
|
<div class="row footer">
|
||||||
|
{{template "footer" . }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
window.setup_documentation_page({{ .Props }});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
{{end}}
|
||||||
11
web/web.go
11
web/web.go
@@ -80,6 +80,8 @@ func InitWeb() {
|
|||||||
|
|
||||||
mainrouter.Handle("/hooks/{id:[A-Za-z0-9]+}", api.ApiAppHandler(incomingWebhook)).Methods("POST")
|
mainrouter.Handle("/hooks/{id:[A-Za-z0-9]+}", api.ApiAppHandler(incomingWebhook)).Methods("POST")
|
||||||
|
|
||||||
|
mainrouter.Handle("/docs/{doc:[A-Za-z0-9]+}", api.AppHandlerIndependent(docs)).Methods("GET")
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------
|
||||||
// *ANYTHING* team specific should go below this line
|
// *ANYTHING* team specific should go below this line
|
||||||
// ----------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------
|
||||||
@@ -494,6 +496,15 @@ func findTeam(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
page.Render(c, w)
|
page.Render(c, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func docs(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
params := mux.Vars(r)
|
||||||
|
doc := params["doc"]
|
||||||
|
|
||||||
|
page := NewHtmlTemplatePage("docs", "Documentation")
|
||||||
|
page.Props["Site"] = doc
|
||||||
|
page.Render(c, w)
|
||||||
|
}
|
||||||
|
|
||||||
func resetPassword(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
func resetPassword(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
||||||
isResetLink := true
|
isResetLink := true
|
||||||
hash := r.URL.Query().Get("h")
|
hash := r.URL.Query().Get("h")
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user