Skip to content

Commit

Permalink
refactor and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
goenning committed Jun 2, 2017
1 parent f2a02b6 commit 44de22f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 30 deletions.
1 change: 1 addition & 0 deletions app/middlewares/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func TestJwtGetter_WithCookie(t *testing.T) {
Users: users,
})
server.Context.SetTenant(tenant)
server.Context.Request().Header.Add("Accept", "application/json")
server.Context.Request().AddCookie(&http.Cookie{
Name: "auth",
Value: token,
Expand Down
32 changes: 16 additions & 16 deletions public/shared/Common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ interface IdeaResponseProps {
}

export const ShowIdeaResponse = (props: IdeaResponseProps): JSX.Element => {
const status = IdeaStatus.Get(props.status);
const status = IdeaStatus.Get(props.status);

if (props.response && status.show) {
return <div className="fdr-response item ui raised segment">
<IdeaStatusRibbon status={status} />
<div className="info">
<Gravatar email={props.response.user.email}/> <u>{props.response.user.name}</u>
<span title={props.response.respondedOn.toString()}>
{ moment(props.response.respondedOn).fromNow() }
</span>
</div>
<div className="content">
<MultiLineText text={ props.response.text } />
</div>
</div>;
}
return <div/>;
if (props.response && status.show) {
return <div className="fdr-response item ui raised segment">
<IdeaStatusRibbon status={status} />
<div className="info">
<Gravatar email={props.response.user.email}/> <u>{props.response.user.name}</u>
<span title={props.response.respondedOn.toString()}>
{ moment(props.response.respondedOn).fromNow() }
</span>
</div>
<div className="content">
<MultiLineText text={ props.response.text } />
</div>
</div>;
}
return <div/>;
};
16 changes: 8 additions & 8 deletions public/shared/ResponseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseFor

private async submit() {
try {
await axios.post(`/api/ideas/${this.props.idea.number}/status`, {
status: parseInt(this.status.value, 10),
text: this.text.value
});
location.reload();
await axios.post(`/api/ideas/${this.props.idea.number}/status`, {
status: parseInt(this.status.value, 10),
text: this.text.value
});
location.reload();
} catch (ex) {
this.setState({
error: ex.response.data
});
this.setState({
error: ex.response.data
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion public/shared/SocialSignInButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class SocialSignInButton extends React.Component<SocialSignInButtonProps,
if (this.props.size === 'small') {
return <a href={oauthUrl} className={cssClasses} onClick={() => this.setState({clicked: true})}>
<i className={providerClassName + ' icon'}></i>
</a>;
</a>;
} else {
return <a href={oauthUrl} className={cssClasses} onClick={() => this.setState({clicked: true})}>
<i className={providerClassName + ' icon'}></i>
Expand Down
10 changes: 5 additions & 5 deletions public/site/ShowIdeaPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as moment from 'moment';
import * as React from 'react';
import * as storage from '../storage';
import { getCurrentUser, get, getArray, isStaff } from '../storage';

import { User, Comment, Idea } from '../models';
import { CommentInput } from '../shared/CommentInput';
Expand All @@ -21,9 +21,9 @@ export class ShowIdeaPage extends React.Component<{}, {}> {
constructor(props: {}) {
super(props);

this.user = storage.getCurrentUser();
this.idea = storage.get<Idea>('idea');
this.comments = storage.getArray<Comment>('comments');
this.user = getCurrentUser();
this.idea = get<Idea>('idea');
this.comments = getArray<Comment>('comments');
}

public render() {
Expand Down Expand Up @@ -73,7 +73,7 @@ export class ShowIdeaPage extends React.Component<{}, {}> {
<ShowIdeaResponse status={ this.idea.status } response={ this.idea.response } />

{
storage.isStaff() &&
isStaff() &&
<div>
<div className="ui hidden divider"></div>
<ResponseForm idea={ this.idea } />
Expand Down

0 comments on commit 44de22f

Please sign in to comment.