Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put dataset permissions in sharing tab #4763

Merged
merged 7 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions frontend/javascripts/dashboard/dataset/dataset_import_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,23 +499,28 @@ class DatasetImportView extends React.PureComponent<Props, State> {
</Hideable>
</TabPane>

<TabPane tab={<span>Sharing</span>} key="sharing" forceRender>
<Hideable hidden={this.state.activeTabKey !== "sharing"}>
<ImportSharingComponent form={form} datasetId={this.props.datasetId} />
</Hideable>
</TabPane>

<TabPane
tab={
<span>
Metadata {formErrors.general ? errorIcon : hasNoAllowedTeamsWarning}
Sharing & Permissions{" "}
{formErrors.general ? errorIcon : hasNoAllowedTeamsWarning}
</span>
}
key="general"
key="sharing"
forceRender
>
<Hideable hidden={this.state.activeTabKey !== "sharing"}>
<ImportSharingComponent
form={form}
datasetId={this.props.datasetId}
hasNoAllowedTeams={_hasNoAllowedTeams}
/>
</Hideable>
</TabPane>

<TabPane tab={<span>Metadata</span>} key="general" forceRender>
<Hideable hidden={this.state.activeTabKey !== "general"}>
<ImportGeneralComponent form={form} hasNoAllowedTeams={_hasNoAllowedTeams} />
<ImportGeneralComponent form={form} />
</Hideable>
</TabPane>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,15 @@
import { Input, Col, Row, DatePicker } from "antd";
import React from "react";

import TeamSelectionComponent from "dashboard/dataset/team_selection_component";

import { FormItemWithInfo } from "./helper_components";

type Props = {
form: Object,
hasNoAllowedTeams: boolean,
};

export default function ImportGeneralComponent({ form, hasNoAllowedTeams }: Props) {
export default function ImportGeneralComponent({ form }: Props) {
const { getFieldDecorator } = form;

const allowedTeamsComponent = (
<FormItemWithInfo
label="Teams allowed to access this dataset"
info="Except for administrators and dataset managers, only members of the teams defined here will be able to view this dataset."
validateStatus={hasNoAllowedTeams ? "warning" : "success"}
help={
hasNoAllowedTeams
? "If this field is empty, only administrators and dataset managers will be able to view this dataset."
: null
}
>
{getFieldDecorator("dataset.allowedTeams", {})(<TeamSelectionComponent mode="multiple" />)}
</FormItemWithInfo>
);
return (
<div>
<Row gutter={48}>
Expand All @@ -51,7 +34,6 @@ export default function ImportGeneralComponent({ form, hasNoAllowedTeams }: Prop
</FormItemWithInfo>
</Col>
</Row>
{allowedTeamsComponent}
<FormItemWithInfo
label="Sorting Date"
info="Datasets are sorted by date. Specify the date (e.g. publication date) in order to influence the sorting order."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,34 @@ import Toast from "libs/toast";
import features from "features";
import window from "libs/window";

import TeamSelectionComponent from "dashboard/dataset/team_selection_component";

import { FormItemWithInfo } from "./helper_components";

type Props = {
form: Object,
datasetId: APIDatasetId,
hasNoAllowedTeams: boolean,
};

export default function ImportSharingComponent({ form, datasetId }: Props) {
export default function ImportSharingComponent({ form, datasetId, hasNoAllowedTeams }: Props) {
const { getFieldDecorator } = form;
const [sharingToken, setSharingToken] = useState("");
const [dataSet, setDataSet] = useState<?APIDataset>(null);
const allowedTeamsComponent = (
<FormItemWithInfo
label="Teams allowed to access this dataset"
info="Except for administrators and dataset managers, only members of the teams defined here will be able to view this dataset."
validateStatus={hasNoAllowedTeams ? "warning" : "success"}
help={
hasNoAllowedTeams
? "If this field is empty, only administrators and dataset managers will be able to view this dataset."
: null
}
>
{getFieldDecorator("dataset.allowedTeams", {})(<TeamSelectionComponent mode="multiple" />)}
</FormItemWithInfo>
);

async function fetch() {
const newSharingToken = await getDatasetSharingToken(datasetId);
Expand Down Expand Up @@ -84,6 +101,7 @@ export default function ImportSharingComponent({ form, datasetId }: Props) {
<Checkbox>Make dataset publicly accessible </Checkbox>,
)}
</FormItemWithInfo>
{allowedTeamsComponent}
<FormItemWithInfo
label="Sharing Link"
info={
Expand Down