apps.websight-package-manager.web-resources.components.modals.EditPackageModal.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of websight-package-manager-view Show documentation
Show all versions of websight-package-manager-view Show documentation
Package Manager View module is responsible for view part of Package Manager.
The newest version!
import React from "/apps/websight-atlaskit-esm/web-resources/react.js";
import Button, { ButtonGroup } from "/apps/websight-atlaskit-esm/web-resources/@atlaskit/button.js";
import PackageModal from "./PackageModal.js";
import PackageService from "../../services/PackageService.js";
import { extendFunction } from "../../utils/CommonUtils.js";
export default class EditPackageModal extends React.Component {
constructor(props) {
super(props);
this.open = this.open.bind(this);
this.close = this.close.bind(this);
this.getFormFooterContent = this.getFormFooterContent.bind(this);
this.onEditFormSubmit = this.onEditFormSubmit.bind(this);
}
open() {
this.packageModal.open();
}
close() {
this.packageModal.close();
}
onEditFormSubmit(requestData, onSuccess, onValidationFailure, onComplete) {
requestData = { ...requestData,
path: this.props.packageToEdit.path
};
if (this.props.onEditSuccess) {
onSuccess = extendFunction(onSuccess, () => this.props.onEditSuccess());
}
PackageService.updatePackage(requestData, onSuccess, onValidationFailure, onComplete);
}
getFormFooterContent({
submitted
}) {
return /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
appearance: "primary",
type: "submit",
isLoading: submitted
}, "Save"), /*#__PURE__*/React.createElement(Button, {
appearance: "subtle",
onClick: this.close,
isDisabled: submitted
}, "Cancel"));
}
render() {
const {
groups,
packageToEdit
} = this.props;
return /*#__PURE__*/React.createElement(PackageModal, {
actionTitle: "Edit Package",
packageToEdit: packageToEdit,
groups: groups,
showThumbnail: true,
formFooterContent: this.getFormFooterContent,
onSubmit: this.onEditFormSubmit,
ref: element => this.packageModal = element
});
}
}