Skip to content

Commit

Permalink
Disable namespace owners to remove themselves (#101)
Browse files Browse the repository at this point in the history
* fix: disable owners to remove themselves

* fix: review response: don't call setState in constructor
  • Loading branch information
romanblanco authored Feb 18, 2020
1 parent 895d5a1 commit 4a21ef6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/components/namespace-form/namespace-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface IProps {
}

interface IState {
userId: string;
newLinkName: string;
newLinkURL: string;
newNamespaceGroup: string;
Expand All @@ -26,12 +27,17 @@ export class NamespaceForm extends React.Component<IProps, IState> {
super(props);

this.state = {
userId: '',
newLinkURL: '',
newLinkName: '',
newNamespaceGroup: '',
};
}

componentDidMount() {
this.userPermissions();
}

render() {
const { namespace, errorMessages } = this.props;

Expand Down Expand Up @@ -90,7 +96,8 @@ export class NamespaceForm extends React.Component<IProps, IState> {
key={group}
onClick={() => this.deleteItem(group)}
isReadOnly={
group === 'system:partner-engineers'
group === 'system:partner-engineers' ||
this.state.userId == group
}
>
{group}
Expand Down Expand Up @@ -224,6 +231,14 @@ export class NamespaceForm extends React.Component<IProps, IState> {
);
}

private userPermissions() {
(window as any).insights.chrome.auth.getUser().then(currentUser => {
this.setState({
userId: currentUser.identity.account_number,
});
});
}

private updateField(value, event) {
const update = { ...this.props.namespace };
update[event.target.id] = value;
Expand Down

0 comments on commit 4a21ef6

Please sign in to comment.