Skip to content

Commit

Permalink
Stop non-authed users from provisioning caucuses
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxwellBo committed Oct 30, 2018
1 parent ae82808 commit 862b870
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface State {
timerId?: NodeJS.Timer;
}

export const CLIENT_VERSION = 'v2.12.0';
export const CLIENT_VERSION = 'v2.12.1';

export const CLIENT_VERSION_LINK = (
<a href="https://github.com/MaxwellBo/Muncoordinated-2/releases">
Expand Down
14 changes: 10 additions & 4 deletions src/components/Resolution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default class Resolution extends React.Component<Props, State> {
renderAmendment = (id: AmendmentID, amendment: AmendmentData, amendmentFref: firebase.database.Reference) => {
const { handleProvisionAmendment } = this;
const { proposer, text, status } = amendment;
const { user } = this.state;
const { user, committee } = this.state;

const textArea = (
<TextArea
Expand All @@ -218,9 +218,15 @@ export default class Resolution extends React.Component<Props, State> {
/>
);

let hasAuth = false;

if (committee && user) {
hasAuth = committee.creatorUid === user.uid;
}

const statusDropdown = (
<Dropdown
disabled={!user}
disabled={!hasAuth}
value={status}
options={AMENDMENT_STATUS_OPTIONS}
onChange={dropdownHandler<AmendmentData>(amendmentFref, 'status')}
Expand Down Expand Up @@ -248,7 +254,7 @@ export default class Resolution extends React.Component<Props, State> {
const provisionTree = !((amendment || { caucus: undefined }).caucus) ? (
<Button
floated="right"
disabled={!amendment || amendment.proposer === '' || !user}
disabled={!amendment || amendment.proposer === '' || !hasAuth}
content="Provision Caucus"
onClick={() => handleProvisionAmendment(id, amendment!)}
/>
Expand All @@ -271,7 +277,7 @@ export default class Resolution extends React.Component<Props, State> {
floated="right"
icon="trash"
negative
disabled={!user}
disabled={!hasAuth}
basic
onClick={() => amendmentFref.remove()}
/>
Expand Down

0 comments on commit 862b870

Please sign in to comment.