diff --git a/webapp/components/backstage/backstage_controller.jsx b/webapp/components/backstage/backstage_controller.jsx
index 9e842e1f72..0ec6a00916 100644
--- a/webapp/components/backstage/backstage_controller.jsx
+++ b/webapp/components/backstage/backstage_controller.jsx
@@ -13,8 +13,8 @@ import ErrorBar from 'components/error_bar.jsx';
export default class BackstageController extends React.Component {
static get propTypes() {
return {
- children: React.PropTypes.node.isRequired,
- params: React.PropTypes.object.isRequired
+ user: React.PropTypes.object,
+ children: React.PropTypes.node.isRequired
};
}
@@ -23,9 +23,12 @@ export default class BackstageController extends React.Component {
this.onTeamChange = this.onTeamChange.bind(this);
+ const team = TeamStore.getCurrent();
+
this.state = {
- user: UserStore.getCurrentUser(),
- team: props.params.team ? TeamStore.getByName(props.params.team) : TeamStore.getCurrent()
+ team,
+ isAdmin: UserStore.isSystemAdminForCurrentUser(this.props.user) ||
+ TeamStore.isTeamAdminForCurrentTeam(team)
};
}
@@ -38,8 +41,12 @@ export default class BackstageController extends React.Component {
}
onTeamChange() {
+ const team = TeamStore.getCurrent();
+
this.state = {
- team: this.props.params.team ? TeamStore.getByName(this.props.params.team) : TeamStore.getCurrent()
+ team,
+ isAdmin: UserStore.isSystemAdminForCurrentUser(this.props.user) ||
+ TeamStore.isTeamAdminForCurrentTeam(team)
};
}
@@ -51,7 +58,7 @@ export default class BackstageController extends React.Component {
{
React.Children.map(this.props.children, (child) => {
@@ -61,7 +68,8 @@ export default class BackstageController extends React.Component {
return React.cloneElement(child, {
team: this.state.team,
- user: this.state.user
+ user: this.props.user,
+ isAdmin: this.state.isAdmin
});
})
}
diff --git a/webapp/components/integrations/components/commands_container.jsx b/webapp/components/integrations/components/commands_container.jsx
index 4ab4652182..095dc4feae 100644
--- a/webapp/components/integrations/components/commands_container.jsx
+++ b/webapp/components/integrations/components/commands_container.jsx
@@ -12,7 +12,9 @@ export default class CommandsContainer extends React.Component {
static get propTypes() {
return {
team: React.PropTypes.object,
- children: React.PropTypes.node
+ user: React.PropTypes.object,
+ children: React.PropTypes.node.isRequired,
+ isAdmin: React.PropTypes.bool
};
}
@@ -65,7 +67,9 @@ export default class CommandsContainer extends React.Component {
commands: this.state.commands,
users: this.state.users,
loading: this.state.loading,
- team: this.props.team
+ team: this.props.team,
+ user: this.props.user,
+ isAdmin: this.props.isAdmin
})}
);
diff --git a/webapp/components/integrations/components/installed_command.jsx b/webapp/components/integrations/components/installed_command.jsx
index 96ccaf3e34..2e45739a09 100644
--- a/webapp/components/integrations/components/installed_command.jsx
+++ b/webapp/components/integrations/components/installed_command.jsx
@@ -13,7 +13,8 @@ export default class InstalledCommand extends React.Component {
onRegenToken: React.PropTypes.func.isRequired,
onDelete: React.PropTypes.func.isRequired,
filter: React.PropTypes.string,
- creator: React.PropTypes.object.isRequired
+ creator: React.PropTypes.object.isRequired,
+ canChange: React.PropTypes.bool.isRequired
};
}
@@ -84,6 +85,40 @@ export default class InstalledCommand extends React.Component {
trigger += ' ' + command.auto_complete_hint;
}
+ let actions = null;
+ if (this.props.canChange) {
+ actions = (
+
+
+
+
+ {' - '}
+
+
+
+ {' - '}
+
+
+
+
+ );
+ }
+
return (
@@ -120,36 +155,7 @@ export default class InstalledCommand extends React.Component {
-
-
-
-
- {' - '}
-
-
-
- {' - '}
-
-
-
-
+ {actions}
);
}
diff --git a/webapp/components/integrations/components/installed_commands.jsx b/webapp/components/integrations/components/installed_commands.jsx
index e080cd706a..1854e6eb10 100644
--- a/webapp/components/integrations/components/installed_commands.jsx
+++ b/webapp/components/integrations/components/installed_commands.jsx
@@ -14,9 +14,11 @@ export default class InstalledCommands extends React.Component {
static get propTypes() {
return {
team: React.PropTypes.object,
+ user: React.PropTypes.object,
users: React.PropTypes.object,
commands: React.PropTypes.array,
- loading: React.PropTypes.bool
+ loading: React.PropTypes.bool,
+ isAdmin: React.PropTypes.bool
};
}
@@ -37,6 +39,8 @@ export default class InstalledCommands extends React.Component {
render() {
const commands = this.props.commands.map((command) => {
+ const canChange = this.props.isAdmin || this.props.user.id === command.creator_id;
+
return (
);
});
diff --git a/webapp/components/integrations/components/installed_incoming_webhook.jsx b/webapp/components/integrations/components/installed_incoming_webhook.jsx
index 86274c3d62..10328c6051 100644
--- a/webapp/components/integrations/components/installed_incoming_webhook.jsx
+++ b/webapp/components/integrations/components/installed_incoming_webhook.jsx
@@ -14,7 +14,8 @@ export default class InstalledIncomingWebhook extends React.Component {
incomingWebhook: React.PropTypes.object.isRequired,
onDelete: React.PropTypes.func.isRequired,
filter: React.PropTypes.string,
- creator: React.PropTypes.object.isRequired
+ creator: React.PropTypes.object.isRequired,
+ canChange: React.PropTypes.bool.isRequired
};
}
@@ -83,6 +84,23 @@ export default class InstalledIncomingWebhook extends React.Component {
);
}
+ let actions = null;
+ if (this.props.canChange) {
+ actions = (
+
+ );
+ }
+
return (
@@ -116,17 +134,7 @@ export default class InstalledIncomingWebhook extends React.Component {
-
+ {actions}
);
}
diff --git a/webapp/components/integrations/components/installed_incoming_webhooks.jsx b/webapp/components/integrations/components/installed_incoming_webhooks.jsx
index ed98f10534..5b0bc185a9 100644
--- a/webapp/components/integrations/components/installed_incoming_webhooks.jsx
+++ b/webapp/components/integrations/components/installed_incoming_webhooks.jsx
@@ -19,7 +19,9 @@ import {FormattedMessage} from 'react-intl';
export default class InstalledIncomingWebhooks extends React.Component {
static get propTypes() {
return {
- team: React.PropTypes.object
+ team: React.PropTypes.object,
+ user: React.PropTypes.object,
+ isAdmin: React.PropTypes.bool
};
}
@@ -74,12 +76,15 @@ export default class InstalledIncomingWebhooks extends React.Component {
render() {
const incomingWebhooks = this.state.incomingWebhooks.map((incomingWebhook) => {
+ const canChange = this.props.isAdmin || this.props.user.id === incomingWebhook.user_id;
+
return (
);
});
diff --git a/webapp/components/integrations/components/installed_outgoing_webhook.jsx b/webapp/components/integrations/components/installed_outgoing_webhook.jsx
index 3ff2c01a4b..04cc1b033f 100644
--- a/webapp/components/integrations/components/installed_outgoing_webhook.jsx
+++ b/webapp/components/integrations/components/installed_outgoing_webhook.jsx
@@ -14,7 +14,8 @@ export default class InstalledOutgoingWebhook extends React.Component {
onRegenToken: React.PropTypes.func.isRequired,
onDelete: React.PropTypes.func.isRequired,
filter: React.PropTypes.string,
- creator: React.PropTypes.object.isRequired
+ creator: React.PropTypes.object.isRequired,
+ canChange: React.PropTypes.bool.isRequired
};
}
@@ -146,6 +147,33 @@ export default class InstalledOutgoingWebhook extends React.Component {
);
}
+ let actions = null;
+ if (this.props.canChange) {
+ actions = (
+
+ );
+ }
+
return (
@@ -203,27 +231,7 @@ export default class InstalledOutgoingWebhook extends React.Component {
{urls}
-
+ {actions}
);
}
diff --git a/webapp/components/integrations/components/installed_outgoing_webhooks.jsx b/webapp/components/integrations/components/installed_outgoing_webhooks.jsx
index 4e9a0260f7..7f278d1120 100644
--- a/webapp/components/integrations/components/installed_outgoing_webhooks.jsx
+++ b/webapp/components/integrations/components/installed_outgoing_webhooks.jsx
@@ -19,7 +19,9 @@ import {FormattedMessage} from 'react-intl';
export default class InstalledOutgoingWebhooks extends React.Component {
static get propTypes() {
return {
- team: React.PropTypes.object
+ team: React.PropTypes.object,
+ user: React.PropTypes.object,
+ isAdmin: React.PropTypes.bool
};
}
@@ -77,6 +79,8 @@ export default class InstalledOutgoingWebhooks extends React.Component {
render() {
const outgoingWebhooks = this.state.outgoingWebhooks.map((outgoingWebhook) => {
+ const canChange = this.props.isAdmin || this.props.user.id === outgoingWebhook.creator_id;
+
return (
);
});