Hide settings items for non admins
Update image uploader for use with team logo Fix can't cancel cropping modal
This commit is contained in:
@ -29,8 +29,8 @@ class SettingsSidebar extends React.Component<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { team } = this.props.auth;
|
const { team, user } = this.props.auth;
|
||||||
if (!team) return;
|
if (!team || !user) return;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sidebar>
|
<Sidebar>
|
||||||
@ -54,21 +54,25 @@ class SettingsSidebar extends React.Component<Props> {
|
|||||||
</Section>
|
</Section>
|
||||||
<Section>
|
<Section>
|
||||||
<Header>Team</Header>
|
<Header>Team</Header>
|
||||||
|
{user.isAdmin && (
|
||||||
<SidebarLink to="/settings/details" icon={<SettingsIcon />}>
|
<SidebarLink to="/settings/details" icon={<SettingsIcon />}>
|
||||||
Details
|
Details
|
||||||
</SidebarLink>
|
</SidebarLink>
|
||||||
|
)}
|
||||||
<SidebarLink to="/settings/members" icon={<UserIcon />}>
|
<SidebarLink to="/settings/members" icon={<UserIcon />}>
|
||||||
Members
|
Members
|
||||||
</SidebarLink>
|
</SidebarLink>
|
||||||
<SidebarLink to="/settings/shares" icon={<LinkIcon />}>
|
<SidebarLink to="/settings/shares" icon={<LinkIcon />}>
|
||||||
Share Links
|
Share Links
|
||||||
</SidebarLink>
|
</SidebarLink>
|
||||||
|
{user.isAdmin && (
|
||||||
<SidebarLink
|
<SidebarLink
|
||||||
to="/settings/integrations/slack"
|
to="/settings/integrations/slack"
|
||||||
icon={<SettingsIcon />}
|
icon={<SettingsIcon />}
|
||||||
>
|
>
|
||||||
Integrations
|
Integrations
|
||||||
</SidebarLink>
|
</SidebarLink>
|
||||||
|
)}
|
||||||
</Section>
|
</Section>
|
||||||
</Scrollable>
|
</Scrollable>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -78,6 +78,8 @@ class Details extends React.Component<Props> {
|
|||||||
<ImageUpload
|
<ImageUpload
|
||||||
onSuccess={this.handleAvatarUpload}
|
onSuccess={this.handleAvatarUpload}
|
||||||
onError={this.handleAvatarError}
|
onError={this.handleAvatarError}
|
||||||
|
submitText="Crop logo"
|
||||||
|
borderRadius={0}
|
||||||
>
|
>
|
||||||
<Avatar src={avatarUrl} />
|
<Avatar src={avatarUrl} />
|
||||||
<Flex auto align="center" justify="center">
|
<Flex auto align="center" justify="center">
|
||||||
|
@ -16,6 +16,8 @@ type Props = {
|
|||||||
children?: React.Node,
|
children?: React.Node,
|
||||||
onSuccess: string => *,
|
onSuccess: string => *,
|
||||||
onError: string => *,
|
onError: string => *,
|
||||||
|
submitText: string,
|
||||||
|
borderRadius: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -26,6 +28,11 @@ class DropToImport extends React.Component<Props> {
|
|||||||
file: File;
|
file: File;
|
||||||
avatarEditorRef: AvatarEditor;
|
avatarEditorRef: AvatarEditor;
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
submitText: 'Crop Picture',
|
||||||
|
borderRadius: 150,
|
||||||
|
};
|
||||||
|
|
||||||
onDropAccepted = async (files: File[]) => {
|
onDropAccepted = async (files: File[]) => {
|
||||||
this.isCropping = true;
|
this.isCropping = true;
|
||||||
this.file = files[0];
|
this.file = files[0];
|
||||||
@ -38,13 +45,18 @@ class DropToImport extends React.Component<Props> {
|
|||||||
const asset = await uploadFile(imageBlob, { name: this.file.name });
|
const asset = await uploadFile(imageBlob, { name: this.file.name });
|
||||||
this.props.onSuccess(asset.url);
|
this.props.onSuccess(asset.url);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.props.onError('Unable to upload image');
|
this.props.onError(err);
|
||||||
} finally {
|
} finally {
|
||||||
this.isUploading = false;
|
this.isUploading = false;
|
||||||
this.isCropping = false;
|
this.isCropping = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleClose = () => {
|
||||||
|
this.isUploading = false;
|
||||||
|
this.isCropping = false;
|
||||||
|
};
|
||||||
|
|
||||||
handleZoom = (event: SyntheticDragEvent<*>) => {
|
handleZoom = (event: SyntheticDragEvent<*>) => {
|
||||||
let target = event.target;
|
let target = event.target;
|
||||||
if (target instanceof HTMLInputElement) {
|
if (target instanceof HTMLInputElement) {
|
||||||
@ -53,8 +65,10 @@ class DropToImport extends React.Component<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
renderCropping() {
|
renderCropping() {
|
||||||
|
const { submitText } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen title="">
|
<Modal isOpen onRequestClose={this.handleClose} title="">
|
||||||
<Flex auto column align="center" justify="center">
|
<Flex auto column align="center" justify="center">
|
||||||
<AvatarEditorContainer>
|
<AvatarEditorContainer>
|
||||||
<AvatarEditor
|
<AvatarEditor
|
||||||
@ -63,7 +77,7 @@ class DropToImport extends React.Component<Props> {
|
|||||||
width={250}
|
width={250}
|
||||||
height={250}
|
height={250}
|
||||||
border={25}
|
border={25}
|
||||||
borderRadius={150}
|
borderRadius={this.props.borderRadius}
|
||||||
color={[255, 255, 255, 0.6]} // RGBA
|
color={[255, 255, 255, 0.6]} // RGBA
|
||||||
scale={this.zoom}
|
scale={this.zoom}
|
||||||
rotate={0}
|
rotate={0}
|
||||||
@ -79,7 +93,7 @@ class DropToImport extends React.Component<Props> {
|
|||||||
/>
|
/>
|
||||||
{this.isUploading && <LoadingIndicator />}
|
{this.isUploading && <LoadingIndicator />}
|
||||||
<CropButton onClick={this.handleCrop} disabled={this.isUploading}>
|
<CropButton onClick={this.handleCrop} disabled={this.isUploading}>
|
||||||
Crop avatar
|
{submitText}
|
||||||
</CropButton>
|
</CropButton>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Modal>
|
</Modal>
|
||||||
@ -89,20 +103,21 @@ class DropToImport extends React.Component<Props> {
|
|||||||
render() {
|
render() {
|
||||||
if (this.isCropping) {
|
if (this.isCropping) {
|
||||||
return this.renderCropping();
|
return this.renderCropping();
|
||||||
} else {
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropzone
|
<Dropzone
|
||||||
accept="image/png, image/jpeg"
|
accept="image/png, image/jpeg"
|
||||||
onDropAccepted={this.onDropAccepted}
|
onDropAccepted={this.onDropAccepted}
|
||||||
style={{}}
|
style={{}}
|
||||||
disablePreview
|
disablePreview
|
||||||
{...this.props}
|
onSuccess={this.props.onSuccess}
|
||||||
|
onError={this.props.onError}
|
||||||
>
|
>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</Dropzone>
|
</Dropzone>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AvatarEditorContainer = styled(Flex)`
|
const AvatarEditorContainer = styled(Flex)`
|
||||||
|
Reference in New Issue
Block a user