|
Packit Service |
eebd6f |
import React from "react";
|
|
Packit Service |
eebd6f |
import { FormattedMessage, defineMessages, injectIntl, intlShape } from "react-intl";
|
|
Packit Service |
eebd6f |
import PropTypes from "prop-types";
|
|
Packit Service |
eebd6f |
import { connect } from "react-redux";
|
|
Packit Service |
0c2606 |
import { Pagination, PaginationVariant, TextInput } from "@patternfly/react-core";
|
|
Packit Service |
eebd6f |
import Link from "../../components/Link/Link";
|
|
Packit Service |
eebd6f |
import Layout from "../../components/Layout/Layout";
|
|
Packit Service |
eebd6f |
import BlueprintContents from "../../components/ListView/BlueprintContents";
|
|
Packit Service |
eebd6f |
import ComponentInputs from "../../components/ListView/ComponentInputs";
|
|
Packit Service |
eebd6f |
import ComponentDetailsView from "../../components/ListView/ComponentDetailsView";
|
|
Packit Service |
eebd6f |
import CreateImageUpload from "../../components/Wizard/CreateImageUpload";
|
|
Packit Service |
eebd6f |
import ExportBlueprint from "../../components/Modal/ExportBlueprint";
|
|
Packit Service |
eebd6f |
import PendingChanges from "../../components/Modal/PendingChanges";
|
|
Packit Service |
eebd6f |
import EmptyState from "../../components/EmptyState/EmptyState";
|
|
Packit Service |
eebd6f |
import Loading from "../../components/Loading/Loading";
|
|
Packit Service |
eebd6f |
import BlueprintToolbar from "../../components/Toolbar/BlueprintToolbar";
|
|
Packit Service |
eebd6f |
import BlueprintApi from "../../data/BlueprintApi";
|
|
Packit Service |
eebd6f |
import NotificationsApi from "../../data/NotificationsApi";
|
|
Packit Service |
eebd6f |
import {
|
|
Packit Service |
eebd6f |
fetchingBlueprintContents,
|
|
Packit Service |
eebd6f |
setBlueprint,
|
|
Packit Service |
eebd6f |
updateBlueprintComponents,
|
|
Packit Service |
eebd6f |
undo,
|
|
Packit Service |
eebd6f |
redo,
|
|
Packit Service |
eebd6f |
deleteHistory,
|
|
Packit Service |
eebd6f |
fetchingCompDeps,
|
|
Packit Service |
eebd6f |
} from "../../core/actions/blueprints";
|
|
Packit Service |
eebd6f |
import {
|
|
Packit Service |
eebd6f |
fetchingInputs,
|
|
Packit Service |
eebd6f |
setSelectedInputPage,
|
|
Packit Service |
eebd6f |
clearSelectedInput,
|
|
Packit Service |
eebd6f |
setSelectedInput,
|
|
Packit Service |
eebd6f |
setSelectedInputDeps,
|
|
Packit Service |
eebd6f |
setSelectedInputParent,
|
|
Packit Service |
eebd6f |
deleteFilter,
|
|
Packit Service |
eebd6f |
fetchingDepDetails,
|
|
Packit Service |
eebd6f |
} from "../../core/actions/inputs";
|
|
Packit Service |
eebd6f |
import { setModalActive } from "../../core/actions/modals";
|
|
Packit Service |
eebd6f |
import {
|
|
Packit Service |
eebd6f |
componentsSortSetKey,
|
|
Packit Service |
eebd6f |
componentsSortSetValue,
|
|
Packit Service |
eebd6f |
dependenciesSortSetKey,
|
|
Packit Service |
eebd6f |
dependenciesSortSetValue,
|
|
Packit Service |
eebd6f |
} from "../../core/actions/sort";
|
|
Packit Service |
eebd6f |
import {
|
|
Packit Service |
eebd6f |
componentsFilterAddValue,
|
|
Packit Service |
eebd6f |
componentsFilterRemoveValue,
|
|
Packit Service |
eebd6f |
componentsFilterClearValues,
|
|
Packit Service |
eebd6f |
} from "../../core/actions/filter";
|
|
Packit Service |
eebd6f |
import {
|
|
Packit Service |
eebd6f |
makeGetBlueprintById,
|
|
Packit Service |
eebd6f |
makeGetSortedSelectedComponents,
|
|
Packit Service |
eebd6f |
makeGetSortedDependencies,
|
|
Packit Service |
eebd6f |
makeGetFutureLength,
|
|
Packit Service |
eebd6f |
makeGetPastLength,
|
|
Packit Service |
eebd6f |
makeGetFilteredComponents,
|
|
Packit Service |
eebd6f |
makeGetSelectedInputs,
|
|
Packit Service |
eebd6f |
makeGetSelectedDeps,
|
|
Packit Service |
eebd6f |
} from "../../core/selectors";
|
|
Packit Service |
0c2606 |
import "./index.css";
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
const messages = defineMessages({
|
|
Packit Service |
eebd6f |
listTitleAvailableComps: {
|
|
Packit Service |
eebd6f |
defaultMessage: "Available Components",
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
addComponentTitle: {
|
|
Packit Service |
eebd6f |
defaultMessage: "Add Blueprint Components",
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
addComponentMessageOne: {
|
|
Packit Service |
eebd6f |
defaultMessage:
|
|
Packit Service |
eebd6f |
"Browse or search for components, then add them to the blueprint. Or leave the blueprint empty to create a minimal image.",
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
addComponentMessageTwo: {
|
|
Packit Service |
eebd6f |
defaultMessage:
|
|
Packit Service |
eebd6f |
"The packages needed to support the selected image type are automatically included when creating an image.",
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
blueprintTitle: {
|
|
Packit Service |
eebd6f |
defaultMessage: "Blueprint",
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
filterByLabel: {
|
|
Packit Service |
eebd6f |
defaultMessage: "Filter Available Components by Name",
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
filterByPlaceholder: {
|
|
Packit Service |
eebd6f |
defaultMessage: "Filter By Name...",
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
emptyStateNoResultsMessage: {
|
|
Packit Service |
eebd6f |
defaultMessage: "Modify your filter criteria to get results.",
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
emptyStateNoResultsTitle: {
|
|
Packit Service |
eebd6f |
defaultMessage: "No Results Match the Filter Criteria",
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
0c2606 |
paginationPerPage: {
|
|
Packit Service |
0c2606 |
defaultMessage: "per page",
|
|
Packit Service |
0c2606 |
},
|
|
Packit Service |
eebd6f |
});
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
class EditBlueprintPage extends React.Component {
|
|
Packit Service |
eebd6f |
constructor() {
|
|
Packit Service |
eebd6f |
super();
|
|
Packit Service |
0c2606 |
this.state = {
|
|
Packit Service |
0c2606 |
page: 1,
|
|
Packit Service |
0c2606 |
pageSize: 50,
|
|
Packit Service |
0c2606 |
};
|
|
Packit Service |
eebd6f |
this.setNotifications = this.setNotifications.bind(this);
|
|
Packit Service |
eebd6f |
this.handleCommit = this.handleCommit.bind(this);
|
|
Packit Service |
eebd6f |
this.handleAddComponent = this.handleAddComponent.bind(this);
|
|
Packit Service |
eebd6f |
this.handleUpdateComponent = this.handleUpdateComponent.bind(this);
|
|
Packit Service |
eebd6f |
this.handleRemoveComponent = this.handleRemoveComponent.bind(this);
|
|
Packit Service |
eebd6f |
this.handleComponentDetails = this.handleComponentDetails.bind(this);
|
|
Packit Service |
eebd6f |
this.handleComponentListItem = this.handleComponentListItem.bind(this);
|
|
Packit Service |
eebd6f |
this.handleDepListItem = this.handleDepListItem.bind(this);
|
|
Packit Service |
eebd6f |
this.handleHideModal = this.handleHideModal.bind(this);
|
|
Packit Service |
eebd6f |
this.handleShowModal = this.handleShowModal.bind(this);
|
|
Packit Service |
eebd6f |
this.handleDiscardChanges = this.handleDiscardChanges.bind(this);
|
|
Packit Service |
eebd6f |
this.handleUndo = this.handleUndo.bind(this);
|
|
Packit Service |
0c2606 |
this.handleSetPage = this.handleSetPage.bind(this);
|
|
Packit Service |
0c2606 |
this.handlePageSizeSelect = this.handlePageSizeSelect.bind(this);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
componentDidMount() {
|
|
Packit Service |
eebd6f |
const { formatMessage } = this.props.intl;
|
|
Packit Service |
eebd6f |
document.title = formatMessage(messages.blueprintTitle);
|
|
Packit Service |
eebd6f |
// get blueprint, get inputs; then update inputs
|
|
Packit Service |
eebd6f |
if (this.props.blueprint.components === undefined) {
|
|
Packit Service |
eebd6f |
this.props.fetchingBlueprintContents(this.props.route.params.blueprint.replace(/\s/g, "-"));
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
0c2606 |
this.props.fetchingInputs(this.props.inputs.inputFilters, this.state.page, this.state.pageSize);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
componentWillUnmount() {
|
|
Packit Service |
eebd6f |
this.props.deleteFilter();
|
|
Packit Service |
eebd6f |
this.props.clearSelectedInput();
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleClearFilters(event) {
|
|
Packit Service |
eebd6f |
const filter = {
|
|
Packit Service |
eebd6f |
field: "name",
|
|
Packit Service |
eebd6f |
value: "",
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
this.props.deleteFilter();
|
|
Packit Service |
0c2606 |
this.props.fetchingInputs(filter, 1, this.state.pageSize);
|
|
Packit Service |
eebd6f |
$("#cmpsr-blueprint-input-filter").val("");
|
|
Packit Service |
eebd6f |
event.preventDefault();
|
|
Packit Service |
eebd6f |
event.stopPropagation();
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
0c2606 |
handleSetPage(_event, page) {
|
|
Packit Service |
0c2606 |
this.setState({
|
|
Packit Service |
0c2606 |
page,
|
|
Packit Service |
0c2606 |
});
|
|
Packit Service |
eebd6f |
this.props.setSelectedInputPage(page);
|
|
Packit Service |
eebd6f |
const filter = this.props.inputs.inputFilters;
|
|
Packit Service |
0c2606 |
this.props.fetchingInputs(filter, page, this.state.pageSize);
|
|
Packit Service |
0c2606 |
}
|
|
Packit Service |
0c2606 |
|
|
Packit Service |
0c2606 |
handlePageSizeSelect(_event, pageSize) {
|
|
Packit Service |
0c2606 |
this.setState({
|
|
Packit Service |
0c2606 |
pageSize,
|
|
Packit Service |
0c2606 |
});
|
|
Packit Service |
0c2606 |
const filter = this.props.inputs.inputFilters;
|
|
Packit Service |
0c2606 |
this.props.fetchingInputs(filter, this.state.page, pageSize);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleCommit() {
|
|
Packit Service |
eebd6f |
// clear existing notifications
|
|
Packit Service |
eebd6f |
NotificationsApi.closeNotification(undefined, "committed");
|
|
Packit Service |
eebd6f |
NotificationsApi.closeNotification(undefined, "committing");
|
|
Packit Service |
eebd6f |
// display the committing notification
|
|
Packit Service |
eebd6f |
NotificationsApi.displayNotification(this.props.blueprint.name, "committing");
|
|
Packit Service |
eebd6f |
this.setNotifications();
|
|
Packit Service |
eebd6f |
// post blueprint (includes 'committed' notification)
|
|
Packit Service |
eebd6f |
Promise.all([BlueprintApi.handleCommitBlueprint(this.props.blueprint)])
|
|
Packit Service |
eebd6f |
.then(() => {
|
|
Packit Service |
eebd6f |
// then after blueprint is posted, reload blueprint details
|
|
Packit Service |
eebd6f |
// to get details that were updated during commit (i.e. version)
|
|
Packit Service |
eebd6f |
Promise.all([BlueprintApi.reloadBlueprintDetails(this.props.blueprint)])
|
|
Packit Service |
eebd6f |
.then((data) => {
|
|
Packit Service |
eebd6f |
const blueprintToSet = { ...this.props.blueprint, version: data[0].version };
|
|
Packit Service |
eebd6f |
this.props.setBlueprint(blueprintToSet);
|
|
Packit Service |
eebd6f |
})
|
|
Packit Service |
eebd6f |
.catch((e) => console.log(`Error in reload blueprint details: ${e}`));
|
|
Packit Service |
eebd6f |
})
|
|
Packit Service |
eebd6f |
.catch((e) => console.log(`Error in blueprint commit: ${e}`));
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleAddComponent(event, component, version) {
|
|
Packit Service |
eebd6f |
this.props.clearSelectedInput();
|
|
Packit Service |
eebd6f |
const addedPackage = {
|
|
Packit Service |
eebd6f |
name: component.name,
|
|
Packit Service |
eebd6f |
version,
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
const pendingChange = {
|
|
Packit Service |
eebd6f |
componentOld: null,
|
|
Packit Service |
eebd6f |
componentNew: `${component.name}-${version}`,
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
let pendingChanges = this.props.blueprint.localPendingChanges;
|
|
Packit Service |
eebd6f |
const prevChange = pendingChanges.find((change) => change.componentOld === pendingChange.componentNew);
|
|
Packit Service |
eebd6f |
// removing then adding a component of the same version results in no change listed
|
|
Packit Service |
eebd6f |
// if a different version of this component was removed, that change and this change will
|
|
Packit Service |
eebd6f |
// still be listed as separate changes
|
|
Packit Service |
eebd6f |
// but if a previous change exists where the same component version was removed...
|
|
Packit Service |
eebd6f |
if (prevChange !== undefined) {
|
|
Packit Service |
eebd6f |
// then filter that previous change, and don't add this change
|
|
Packit Service |
eebd6f |
pendingChanges = pendingChanges.filter((component) => component !== prevChange);
|
|
Packit Service |
eebd6f |
} else {
|
|
Packit Service |
eebd6f |
pendingChanges = [pendingChange].concat(pendingChanges);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
const packages = this.props.blueprint.packages.concat(addedPackage);
|
|
Packit Service |
eebd6f |
const { modules } = this.props.blueprint;
|
|
Packit Service |
eebd6f |
const addedComponent = { ...component, version, userSelected: true, inBlueprint: true };
|
|
Packit Service |
eebd6f |
// for now, just adding the component to the state
|
|
Packit Service |
eebd6f |
// component info will load after committing the change to the workspace and reloading the blueprint
|
|
Packit Service |
eebd6f |
const components = this.props.blueprint.components.concat(addedComponent);
|
|
Packit Service |
eebd6f |
this.props.updateBlueprintComponents(this.props.blueprint.id, components, packages, modules, pendingChanges);
|
|
Packit Service |
eebd6f |
event.preventDefault();
|
|
Packit Service |
eebd6f |
event.stopPropagation();
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleUpdateComponent(event, component, version) {
|
|
Packit Service |
eebd6f |
const name = component.name;
|
|
Packit Service |
eebd6f |
this.props.clearSelectedInput();
|
|
Packit Service |
eebd6f |
const selectedComponents = this.props.blueprint.packages.concat(this.props.blueprint.modules);
|
|
Packit Service |
0c2606 |
const oldVersion = selectedComponents.find((selectedComp) => selectedComp.name === name).version;
|
|
Packit Service |
eebd6f |
const updatedComponent = {
|
|
Packit Service |
eebd6f |
name,
|
|
Packit Service |
eebd6f |
version,
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
0c2606 |
// let??
|
|
Packit Service |
eebd6f |
const pendingChange = {
|
|
Packit Service |
eebd6f |
componentOld: `${name}-${oldVersion}`,
|
|
Packit Service |
eebd6f |
componentNew: `${name}-${version}`,
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
let pendingChanges = this.props.blueprint.localPendingChanges;
|
|
Packit Service |
eebd6f |
const prevChange = pendingChanges.find((change) => change.componentNew === pendingChange.componentOld);
|
|
Packit Service |
eebd6f |
// if this component was added or updated in this session...
|
|
Packit Service |
eebd6f |
if (prevChange !== undefined) {
|
|
Packit Service |
eebd6f |
// then only list this component once in the list of changes,
|
|
Packit Service |
eebd6f |
// where the change shows the old version of the previous change
|
|
Packit Service |
eebd6f |
pendingChange.componentOld = prevChange.componentOld;
|
|
Packit Service |
0c2606 |
pendingChanges = pendingChanges.filter((change) => change !== prevChange);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
if (prevChange === undefined || pendingChange.componentOld !== pendingChange.componentNew) {
|
|
Packit Service |
eebd6f |
pendingChanges = [pendingChange].concat(pendingChanges);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
let { packages } = this.props.blueprint;
|
|
Packit Service |
eebd6f |
let { modules } = this.props.blueprint;
|
|
Packit Service |
0c2606 |
if (modules.some((module) => module.name === name)) {
|
|
Packit Service |
eebd6f |
modules = modules.filter((item) => item.name !== updatedComponent.name).concat(updatedComponent);
|
|
Packit Service |
eebd6f |
} else {
|
|
Packit Service |
eebd6f |
packages = packages.filter((item) => item.name !== updatedComponent.name).concat(updatedComponent);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
0c2606 |
const components = this.props.blueprint.components.map((blueprintComp) => {
|
|
Packit Service |
0c2606 |
if (blueprintComp.name === name) {
|
|
Packit Service |
0c2606 |
const componentData = { ...blueprintComp, name, version, userSelected: true, inBlueprint: true };
|
|
Packit Service |
eebd6f |
return componentData;
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
0c2606 |
return blueprintComp;
|
|
Packit Service |
eebd6f |
});
|
|
Packit Service |
eebd6f |
this.props.updateBlueprintComponents(this.props.blueprint.id, components, packages, modules, pendingChanges);
|
|
Packit Service |
eebd6f |
event.preventDefault();
|
|
Packit Service |
eebd6f |
event.stopPropagation();
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleRemoveComponent(event, name) {
|
|
Packit Service |
eebd6f |
this.props.clearSelectedInput();
|
|
Packit Service |
eebd6f |
const selectedComponents = this.props.blueprint.packages.concat(this.props.blueprint.modules);
|
|
Packit Service |
eebd6f |
const { version } = selectedComponents.find((component) => component.name === name);
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
const pendingChange = {
|
|
Packit Service |
eebd6f |
componentOld: `${name}-${version}`,
|
|
Packit Service |
eebd6f |
componentNew: null,
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
let pendingChanges = this.props.blueprint.localPendingChanges;
|
|
Packit Service |
eebd6f |
const prevChange = pendingChanges.find((change) => change.componentNew === pendingChange.componentOld);
|
|
Packit Service |
eebd6f |
// if this component was updated in this session...
|
|
Packit Service |
eebd6f |
if (prevChange !== undefined) {
|
|
Packit Service |
eebd6f |
// then only list this component once in the list of changes,
|
|
Packit Service |
eebd6f |
// where the change shows the old version of the previous change
|
|
Packit Service |
eebd6f |
pendingChange.componentOld = prevChange.componentOld;
|
|
Packit Service |
eebd6f |
pendingChanges = pendingChanges.filter((component) => component !== prevChange);
|
|
Packit Service |
eebd6f |
// but if this component was added in this session (i.e. componentOld === null)
|
|
Packit Service |
eebd6f |
// then neither change should be listed
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
if (prevChange === undefined || prevChange.componentOld !== null) {
|
|
Packit Service |
eebd6f |
pendingChanges = [pendingChange].concat(pendingChanges);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
const packages = this.props.blueprint.packages.filter((pack) => pack.name !== name);
|
|
Packit Service |
eebd6f |
const modules = this.props.blueprint.modules.filter((module) => module.name !== name);
|
|
Packit Service |
eebd6f |
const components = this.props.blueprint.components.filter((component) => component.name !== name);
|
|
Packit Service |
eebd6f |
this.props.updateBlueprintComponents(this.props.blueprint.id, components, packages, modules, pendingChanges);
|
|
Packit Service |
eebd6f |
event.preventDefault();
|
|
Packit Service |
eebd6f |
event.stopPropagation();
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleComponentDetails(event, component) {
|
|
Packit Service |
eebd6f |
// the user selected a component to view more details on the right
|
|
Packit Service |
eebd6f |
if (component.name !== this.props.selectedInput.component.name) {
|
|
Packit Service |
eebd6f |
// if the user did not click on the current selected component:
|
|
Packit Service |
eebd6f |
this.props.setSelectedInput(component);
|
|
Packit Service |
eebd6f |
this.props.setSelectedInputParent([]);
|
|
Packit Service |
eebd6f |
} else {
|
|
Packit Service |
eebd6f |
// if the user clicked on the current selected component:
|
|
Packit Service |
eebd6f |
this.props.clearSelectedInput();
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
event.preventDefault();
|
|
Packit Service |
eebd6f |
event.stopPropagation();
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleComponentListItem(component) {
|
|
Packit Service |
eebd6f |
this.props.fetchingCompDeps(component, this.props.blueprint.id);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleDepListItem(component) {
|
|
Packit Service |
eebd6f |
this.props.fetchingDepDetails(component, this.props.blueprint.id);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
// handle show/hide of modal dialogs
|
|
Packit Service |
eebd6f |
handleHideModal() {
|
|
Packit Service |
eebd6f |
this.props.setModalActive(null);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleShowModal(e, modalType) {
|
|
Packit Service |
eebd6f |
switch (modalType) {
|
|
Packit Service |
eebd6f |
case "modalPendingChanges":
|
|
Packit Service |
eebd6f |
// this.getComponentUpdates();
|
|
Packit Service |
eebd6f |
this.props.setModalActive("modalPendingChanges");
|
|
Packit Service |
eebd6f |
break;
|
|
Packit Service |
eebd6f |
default:
|
|
Packit Service |
eebd6f |
this.props.setModalActive(null);
|
|
Packit Service |
eebd6f |
break;
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
e.preventDefault();
|
|
Packit Service |
eebd6f |
e.stopPropagation();
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleDiscardChanges() {
|
|
Packit Service |
eebd6f |
const workspaceChanges = this.props.blueprint.workspacePendingChanges.length;
|
|
Packit Service |
eebd6f |
const reload = workspaceChanges > 0;
|
|
Packit Service |
eebd6f |
this.props.deleteHistory(this.props.blueprint.id, reload);
|
|
Packit Service |
eebd6f |
// only fetch blueprint contents if workspace changes existed
|
|
Packit Service |
eebd6f |
// when this blueprint originally loaded
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleUndo() {
|
|
Packit Service |
eebd6f |
const workspaceChanges = this.props.blueprint.workspacePendingChanges.length;
|
|
Packit Service |
eebd6f |
if (this.props.pastLength === 1) {
|
|
Packit Service |
eebd6f |
const reload = workspaceChanges > 0;
|
|
Packit Service |
eebd6f |
this.props.deleteHistory(this.props.blueprint.id, reload);
|
|
Packit Service |
eebd6f |
} else {
|
|
Packit Service |
eebd6f |
this.props.undo(this.props.blueprint.id, false);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
0c2606 |
setNotifications() {
|
|
Packit Service |
0c2606 |
this.layout.setNotifications();
|
|
Packit Service |
0c2606 |
}
|
|
Packit Service |
0c2606 |
|
|
Packit Service |
0c2606 |
getFilteredInputs(event) {
|
|
Packit Service |
0c2606 |
if (event.which === 13 || event.keyCode === 13) {
|
|
Packit Service |
0c2606 |
const filter = {
|
|
Packit Service |
0c2606 |
field: "name",
|
|
Packit Service |
0c2606 |
value: event.target.value,
|
|
Packit Service |
0c2606 |
};
|
|
Packit Service |
0c2606 |
this.props.fetchingInputs(filter, 1, this.state.pageSize);
|
|
Packit Service |
0c2606 |
this.props.setSelectedInputPage(0);
|
|
Packit Service |
0c2606 |
$("#cmpsr-blueprint-input-filter").blur();
|
|
Packit Service |
0c2606 |
event.preventDefault();
|
|
Packit Service |
0c2606 |
}
|
|
Packit Service |
0c2606 |
}
|
|
Packit Service |
0c2606 |
|
|
Packit Service |
eebd6f |
render() {
|
|
Packit Service |
eebd6f |
if (this.props.blueprint.id === undefined) {
|
|
Packit Service |
eebd6f |
return <Loading />;
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
const blueprintDisplayName = this.props.route.params.blueprint;
|
|
Packit Service |
eebd6f |
const {
|
|
Packit Service |
eebd6f |
blueprint,
|
|
Packit Service |
eebd6f |
selectedComponents,
|
|
Packit Service |
eebd6f |
dependencies,
|
|
Packit Service |
eebd6f |
inputComponents,
|
|
Packit Service |
eebd6f |
inputs,
|
|
Packit Service |
eebd6f |
modalActive,
|
|
Packit Service |
eebd6f |
componentsSortKey,
|
|
Packit Service |
eebd6f |
componentsSortValue,
|
|
Packit Service |
eebd6f |
componentsFilters,
|
|
Packit Service |
eebd6f |
pastLength,
|
|
Packit Service |
eebd6f |
futureLength,
|
|
Packit Service |
eebd6f |
selectedInputDeps,
|
|
Packit Service |
eebd6f |
setSelectedInput,
|
|
Packit Service |
eebd6f |
setSelectedInputParent,
|
|
Packit Service |
eebd6f |
clearSelectedInput,
|
|
Packit Service |
eebd6f |
} = this.props;
|
|
Packit Service |
eebd6f |
const numPendingChanges = blueprint.localPendingChanges.length + blueprint.workspacePendingChanges.length;
|
|
Packit Service |
eebd6f |
const { formatMessage } = this.props.intl;
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
return (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
className="cmpsr-grid__wrapper"
|
|
Packit Service |
eebd6f |
ref={(c) => {
|
|
Packit Service |
eebd6f |
this.layout = c;
|
|
Packit Service |
eebd6f |
}}
|
|
Packit Service |
eebd6f |
>
|
|
Packit Service |
eebd6f |
<header className="cmpsr-header">
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<Link to="/blueprints">
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Back to Blueprints" />
|
|
Packit Service |
eebd6f |
</Link>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<Link to={`/blueprint/${blueprintDisplayName}`}>{blueprintDisplayName}</Link>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Edit Packages" />
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
{numPendingChanges > 0 && (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
this.handleShowModal(e, "modalPendingChanges")}>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
defaultMessage="{pendingChanges, plural,
|
|
Packit Service |
eebd6f |
one {# Pending Change}
|
|
Packit Service |
eebd6f |
other {# Pending Changes}
|
|
Packit Service |
eebd6f |
}"
|
|
Packit Service |
eebd6f |
values={{
|
|
Packit Service |
eebd6f |
pendingChanges: numPendingChanges,
|
|
Packit Service |
eebd6f |
}}
|
|
Packit Service |
eebd6f |
/>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)}
|
|
Packit Service |
eebd6f |
{(numPendingChanges > 0 && (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
type="button"
|
|
Packit Service |
eebd6f |
className="btn btn-primary"
|
|
Packit Service |
eebd6f |
onClick={(e) => this.handleShowModal(e, "modalPendingChanges")}
|
|
Packit Service |
eebd6f |
>
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Commit" />
|
|
Packit Service |
eebd6f |
</button>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)) || (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<button className="btn btn-primary disabled" type="button">
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Commit" />
|
|
Packit Service |
eebd6f |
</button>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)}
|
|
Packit Service |
eebd6f |
{(numPendingChanges > 0 && (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<button className="btn btn-default" type="button" onClick={this.handleDiscardChanges}>
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Discard Changes" />
|
|
Packit Service |
eebd6f |
</button>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)) || (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<button className="btn btn-default disabled" type="button">
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Discard Changes" />
|
|
Packit Service |
eebd6f |
</button>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<CreateImageUpload blueprint={blueprint} layout={this.layout} />
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
className="btn btn-link dropdown-toggle"
|
|
Packit Service |
eebd6f |
type="button"
|
|
Packit Service |
eebd6f |
id="dropdownKebab"
|
|
Packit Service |
eebd6f |
data-toggle="dropdown"
|
|
Packit Service |
eebd6f |
aria-haspopup="true"
|
|
Packit Service |
eebd6f |
aria-expanded="false"
|
|
Packit Service |
eebd6f |
>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
</button>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<ExportBlueprint blueprint={blueprint} />
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
{blueprintDisplayName}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
</header>
|
|
Packit Service |
eebd6f |
{(inputs.selectedInput.set === false && (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Blueprint Components" />
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)) || (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Component Details" />
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)}
|
|
Packit Service |
eebd6f |
{(inputs.selectedInput.set === false && (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
{componentsSortKey !== undefined && componentsSortValue !== undefined && (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
emptyState={
|
|
Packit Service |
eebd6f |
(selectedComponents === undefined || selectedComponents.length === 0) &&
|
|
Packit Service |
eebd6f |
componentsFilters.filterValues.length === 0
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
blueprintId={blueprint.id}
|
|
Packit Service |
eebd6f |
filters={componentsFilters}
|
|
Packit Service |
eebd6f |
filterRemoveValue={this.props.componentsFilterRemoveValue}
|
|
Packit Service |
eebd6f |
filterClearValues={this.props.componentsFilterClearValues}
|
|
Packit Service |
eebd6f |
filterAddValue={this.props.componentsFilterAddValue}
|
|
Packit Service |
eebd6f |
componentsSortKey={componentsSortKey}
|
|
Packit Service |
eebd6f |
componentsSortValue={componentsSortValue}
|
|
Packit Service |
eebd6f |
componentsSortSetValue={this.props.componentsSortSetValue}
|
|
Packit Service |
eebd6f |
dependenciesSortSetValue={this.props.dependenciesSortSetValue}
|
|
Packit Service |
eebd6f |
undo={this.handleUndo}
|
|
Packit Service |
eebd6f |
redo={this.props.redo}
|
|
Packit Service |
eebd6f |
pastLength={pastLength}
|
|
Packit Service |
eebd6f |
futureLength={futureLength}
|
|
Packit Service |
0c2606 |
showUndoRedo
|
|
Packit Service |
eebd6f |
/>
|
|
Packit Service |
eebd6f |
)}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
components={selectedComponents}
|
|
Packit Service |
eebd6f |
dependencies={dependencies}
|
|
Packit Service |
eebd6f |
handleRemoveComponent={this.handleRemoveComponent}
|
|
Packit Service |
eebd6f |
handleComponentDetails={this.handleComponentDetails}
|
|
Packit Service |
eebd6f |
filterClearValues={this.props.componentsFilterClearValues}
|
|
Packit Service |
eebd6f |
filterValues={componentsFilters.filterValues}
|
|
Packit Service |
eebd6f |
errorState={this.props.blueprintContentsError}
|
|
Packit Service |
eebd6f |
fetchingState={this.props.blueprintContentsFetching}
|
|
Packit Service |
eebd6f |
fetchDetails={this.handleComponentListItem}
|
|
Packit Service |
eebd6f |
undo={this.handleUndo}
|
|
Packit Service |
eebd6f |
pastLength={pastLength}
|
|
Packit Service |
eebd6f |
>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
title={formatMessage(messages.addComponentTitle)}
|
|
Packit Service |
eebd6f |
message={`${formatMessage(messages.addComponentMessageOne)} ${formatMessage(
|
|
Packit Service |
eebd6f |
messages.addComponentMessageTwo
|
|
Packit Service |
eebd6f |
)}`}
|
|
Packit Service |
eebd6f |
/>
|
|
Packit Service |
eebd6f |
</BlueprintContents>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)) ||
|
|
Packit Service |
eebd6f |
(inputs.selectedInput.set === true && (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
blueprint={blueprintDisplayName}
|
|
Packit Service |
eebd6f |
selectedComponents={blueprint.packages.concat(blueprint.modules)}
|
|
Packit Service |
eebd6f |
component={inputs.selectedInput.component}
|
|
Packit Service |
eebd6f |
dependencies={selectedInputDeps}
|
|
Packit Service |
eebd6f |
componentParent={inputs.selectedInput.parent}
|
|
Packit Service |
eebd6f |
setSelectedInput={setSelectedInput}
|
|
Packit Service |
eebd6f |
setSelectedInputParent={setSelectedInputParent}
|
|
Packit Service |
eebd6f |
clearSelectedInput={clearSelectedInput}
|
|
Packit Service |
eebd6f |
handleComponentDetails={this.handleComponentDetails}
|
|
Packit Service |
eebd6f |
handleDepListItem={this.handleDepListItem}
|
|
Packit Service |
eebd6f |
handleAddComponent={this.handleAddComponent}
|
|
Packit Service |
eebd6f |
handleUpdateComponent={this.handleUpdateComponent}
|
|
Packit Service |
eebd6f |
handleRemoveComponent={this.handleRemoveComponent}
|
|
Packit Service |
eebd6f |
/>
|
|
Packit Service |
eebd6f |
))}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
{formatMessage(messages.listTitleAvailableComps)}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
{(inputComponents !== undefined && blueprint.components !== undefined && blueprint.packages !== undefined && (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
0c2606 |
<form className="toolbar-pf-actions pf-l-flex pf-m-space-items-none">
|
|
Packit Service |
0c2606 |
|
|
Packit Service |
0c2606 |
className="pf-m-flex-1 pf-u-mb-xs"
|
|
Packit Service |
0c2606 |
type="text"
|
|
Packit Service |
0c2606 |
id="cmpsr-blueprint-input-filter"
|
|
Packit Service |
0c2606 |
aria-label={formatMessage(messages.filterByLabel)}
|
|
Packit Service |
0c2606 |
placeholder={formatMessage(messages.filterByPlaceholder)}
|
|
Packit Service |
0c2606 |
onKeyPress={(e) => this.getFilteredInputs(e)}
|
|
Packit Service |
0c2606 |
/>
|
|
Packit Service |
0c2606 |
|
|
Packit Service |
0c2606 |
className="pf-m-flex-1 pf-u-flex-nowrap-on-lg pf-u-ml-md-on-md"
|
|
Packit Service |
0c2606 |
itemCount={inputs.totalInputs}
|
|
Packit Service |
0c2606 |
perPage={this.state.pageSize}
|
|
Packit Service |
0c2606 |
page={this.state.page}
|
|
Packit Service |
0c2606 |
onSetPage={this.handleSetPage}
|
|
Packit Service |
0c2606 |
onPerPageSelect={this.handlePageSizeSelect}
|
|
Packit Service |
0c2606 |
isCompact
|
|
Packit Service |
0c2606 |
variant={PaginationVariant.bottom}
|
|
Packit Service |
0c2606 |
titles={{
|
|
Packit Service |
0c2606 |
perPageSuffix: formatMessage(messages.paginationPerPage),
|
|
Packit Service |
0c2606 |
}}
|
|
Packit Service |
0c2606 |
/>
|
|
Packit Service |
eebd6f |
</form>
|
|
Packit Service |
0c2606 |
{inputs.inputFilters !== undefined && inputs.inputFilters.value.length > 0 && (
|
|
Packit Service |
0c2606 |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
defaultMessage="Name: {name}"
|
|
Packit Service |
eebd6f |
values={{
|
|
Packit Service |
eebd6f |
name: inputs.inputFilters.value,
|
|
Packit Service |
eebd6f |
}}
|
|
Packit Service |
eebd6f |
/>
|
|
Packit Service |
eebd6f |
this.handleClearFilters(e)}>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
this.handleClearFilters(e)}>
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Clear All Filters" />
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
0c2606 |
|
|
Packit Service |
0c2606 |
)}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
{blueprint.components.length === 0 &&
|
|
Packit Service |
eebd6f |
Object.keys(this.props.blueprintContentsError).length === 0 &&
|
|
Packit Service |
eebd6f |
componentsFilters.filterValues.length === 0 && (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
type="button"
|
|
Packit Service |
eebd6f |
className="close"
|
|
Packit Service |
eebd6f |
data-dismiss="alert"
|
|
Packit Service |
eebd6f |
aria-hidden="true"
|
|
Packit Service |
eebd6f |
aria-label="Dismiss Message"
|
|
Packit Service |
eebd6f |
>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
</button>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
defaultMessage="{selectComponents} in this list to add to the blueprint."
|
|
Packit Service |
eebd6f |
values={{
|
|
Packit Service |
eebd6f |
selectComponents: (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Select components" />
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
),
|
|
Packit Service |
eebd6f |
}}
|
|
Packit Service |
eebd6f |
/>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)}
|
|
Packit Service |
eebd6f |
{(inputs.inputFilters !== undefined &&
|
|
Packit Service |
eebd6f |
inputs.inputFilters.value.length > 0 &&
|
|
Packit Service |
0c2606 |
inputComponents.length === 0 && (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
title={formatMessage(messages.emptyStateNoResultsTitle)}
|
|
Packit Service |
eebd6f |
message={formatMessage(messages.emptyStateNoResultsMessage)}
|
|
Packit Service |
eebd6f |
>
|
|
Packit Service |
eebd6f |
<button className="btn btn-link" type="button" onClick={(e) => this.handleClearFilters(e)}>
|
|
Packit Service |
eebd6f |
<FormattedMessage defaultMessage="Clear All Filters" />
|
|
Packit Service |
eebd6f |
</button>
|
|
Packit Service |
eebd6f |
</EmptyState>
|
|
Packit Service |
0c2606 |
)) ||
|
|
Packit Service |
0c2606 |
(inputs.loading && <Loading />) || (
|
|
Packit Service |
0c2606 |
|
|
Packit Service |
0c2606 |
label={formatMessage(messages.listTitleAvailableComps)}
|
|
Packit Service |
0c2606 |
components={inputComponents}
|
|
Packit Service |
0c2606 |
handleComponentDetails={this.handleComponentDetails}
|
|
Packit Service |
0c2606 |
handleAddComponent={this.handleAddComponent}
|
|
Packit Service |
0c2606 |
handleRemoveComponent={this.handleRemoveComponent}
|
|
Packit Service |
0c2606 |
/>
|
|
Packit Service |
0c2606 |
)}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)) || (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<form className="toolbar-pf-actions">
|
|
Packit Service |
0c2606 |
|
|
Packit Service |
0c2606 |
type="text"
|
|
Packit Service |
0c2606 |
className="form-control"
|
|
Packit Service |
0c2606 |
id="cmpsr-blueprint-input-filter"
|
|
Packit Service |
0c2606 |
aria-label={formatMessage(messages.filterByLabel)}
|
|
Packit Service |
0c2606 |
placeholder={formatMessage(messages.filterByPlaceholder)}
|
|
Packit Service |
0c2606 |
disabled="disabled"
|
|
Packit Service |
0c2606 |
/>
|
|
Packit Service |
eebd6f |
</form>
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
<Loading />
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
)}
|
|
Packit Service |
eebd6f |
{modalActive === "modalPendingChanges" ? (
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
handleCommit={this.handleCommit}
|
|
Packit Service |
eebd6f |
blueprint={blueprint}
|
|
Packit Service |
eebd6f |
contents={dependencies}
|
|
Packit Service |
eebd6f |
handleHideModal={this.handleHideModal}
|
|
Packit Service |
eebd6f |
/>
|
|
Packit Service |
eebd6f |
) : null}
|
|
Packit Service |
eebd6f |
</Layout>
|
|
Packit Service |
eebd6f |
);
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
EditBlueprintPage.propTypes = {
|
|
Packit Service |
eebd6f |
route: PropTypes.shape({
|
|
Packit Service |
eebd6f |
keys: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
load: PropTypes.func,
|
|
Packit Service |
eebd6f |
page: PropTypes.string,
|
|
Packit Service |
eebd6f |
params: PropTypes.object,
|
|
Packit Service |
eebd6f |
path: PropTypes.string,
|
|
Packit Service |
eebd6f |
pattern: PropTypes.object,
|
|
Packit Service |
eebd6f |
}),
|
|
Packit Service |
eebd6f |
blueprint: PropTypes.shape({
|
|
Packit Service |
eebd6f |
components: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
description: PropTypes.string,
|
|
Packit Service |
eebd6f |
groups: PropTypes.array,
|
|
Packit Service |
eebd6f |
id: PropTypes.string,
|
|
Packit Service |
eebd6f |
localPendingChanges: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
modules: PropTypes.array,
|
|
Packit Service |
eebd6f |
name: PropTypes.string,
|
|
Packit Service |
eebd6f |
packages: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
version: PropTypes.string,
|
|
Packit Service |
eebd6f |
workspacePendingChanges: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
}),
|
|
Packit Service |
eebd6f |
inputs: PropTypes.shape({
|
|
Packit Service |
0c2606 |
inputComponents: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
inputFilters: PropTypes.object,
|
|
Packit Service |
0c2606 |
loading: PropTypes.bool,
|
|
Packit Service |
eebd6f |
pageSize: PropTypes.number,
|
|
Packit Service |
eebd6f |
selectedInput: PropTypes.object,
|
|
Packit Service |
eebd6f |
selectedInputPage: PropTypes.number,
|
|
Packit Service |
eebd6f |
totalInputs: PropTypes.number,
|
|
Packit Service |
eebd6f |
}),
|
|
Packit Service |
0c2606 |
inputComponents: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
modalActive: PropTypes.string,
|
|
Packit Service |
eebd6f |
selectedInput: PropTypes.shape({
|
|
Packit Service |
eebd6f |
component: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
Packit Service |
eebd6f |
parent: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
}),
|
|
Packit Service |
eebd6f |
selectedInputDeps: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
fetchingBlueprintContents: PropTypes.func,
|
|
Packit Service |
eebd6f |
fetchingCompDeps: PropTypes.func,
|
|
Packit Service |
eebd6f |
setBlueprint: PropTypes.func,
|
|
Packit Service |
eebd6f |
updateBlueprintComponents: PropTypes.func,
|
|
Packit Service |
eebd6f |
fetchingInputs: PropTypes.func,
|
|
Packit Service |
eebd6f |
fetchingDepDetails: PropTypes.func,
|
|
Packit Service |
eebd6f |
setSelectedInputPage: PropTypes.func,
|
|
Packit Service |
eebd6f |
setSelectedInput: PropTypes.func,
|
|
Packit Service |
eebd6f |
clearSelectedInput: PropTypes.func,
|
|
Packit Service |
eebd6f |
setSelectedInputParent: PropTypes.func,
|
|
Packit Service |
eebd6f |
deleteFilter: PropTypes.func,
|
|
Packit Service |
eebd6f |
setModalActive: PropTypes.func,
|
|
Packit Service |
eebd6f |
dependenciesSortSetValue: PropTypes.func,
|
|
Packit Service |
eebd6f |
componentsSortSetValue: PropTypes.func,
|
|
Packit Service |
eebd6f |
selectedComponents: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
dependencies: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
componentsSortKey: PropTypes.string,
|
|
Packit Service |
eebd6f |
componentsSortValue: PropTypes.string,
|
|
Packit Service |
eebd6f |
componentsFilters: PropTypes.shape({
|
|
Packit Service |
eebd6f |
defaultFilterType: PropTypes.string,
|
|
Packit Service |
eebd6f |
filterTypes: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
filterValues: PropTypes.arrayOf(PropTypes.object),
|
|
Packit Service |
eebd6f |
}),
|
|
Packit Service |
eebd6f |
componentsFilterAddValue: PropTypes.func,
|
|
Packit Service |
eebd6f |
componentsFilterRemoveValue: PropTypes.func,
|
|
Packit Service |
eebd6f |
componentsFilterClearValues: PropTypes.func,
|
|
Packit Service |
eebd6f |
pastLength: PropTypes.number,
|
|
Packit Service |
eebd6f |
futureLength: PropTypes.number,
|
|
Packit Service |
eebd6f |
undo: PropTypes.func,
|
|
Packit Service |
eebd6f |
redo: PropTypes.func,
|
|
Packit Service |
eebd6f |
deleteHistory: PropTypes.func,
|
|
Packit Service |
eebd6f |
blueprintContentsError: PropTypes.shape({
|
|
Packit Service |
eebd6f |
message: PropTypes.string,
|
|
Packit Service |
eebd6f |
options: PropTypes.object,
|
|
Packit Service |
eebd6f |
problem: PropTypes.string,
|
|
Packit Service |
eebd6f |
url: PropTypes.string,
|
|
Packit Service |
eebd6f |
}),
|
|
Packit Service |
eebd6f |
blueprintContentsFetching: PropTypes.bool,
|
|
Packit Service |
eebd6f |
intl: intlShape.isRequired,
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
EditBlueprintPage.defaultProps = {
|
|
Packit Service |
eebd6f |
route: {},
|
|
Packit Service |
eebd6f |
blueprint: {},
|
|
Packit Service |
eebd6f |
inputs: {},
|
|
Packit Service |
eebd6f |
inputComponents: undefined,
|
|
Packit Service |
eebd6f |
modalActive: "",
|
|
Packit Service |
eebd6f |
selectedInput: {},
|
|
Packit Service |
eebd6f |
fetchingBlueprintContents() {},
|
|
Packit Service |
eebd6f |
setBlueprint() {},
|
|
Packit Service |
eebd6f |
fetchingCompDeps() {},
|
|
Packit Service |
eebd6f |
updateBlueprintComponents() {},
|
|
Packit Service |
eebd6f |
fetchingInputs() {},
|
|
Packit Service |
eebd6f |
fetchingDepDetails() {},
|
|
Packit Service |
eebd6f |
setSelectedInputPage() {},
|
|
Packit Service |
eebd6f |
setSelectedInput() {},
|
|
Packit Service |
eebd6f |
clearSelectedInput() {},
|
|
Packit Service |
eebd6f |
setSelectedInputParent() {},
|
|
Packit Service |
eebd6f |
selectedInputDeps: undefined,
|
|
Packit Service |
eebd6f |
deleteFilter() {},
|
|
Packit Service |
eebd6f |
setModalActive() {},
|
|
Packit Service |
eebd6f |
dependenciesSortSetValue() {},
|
|
Packit Service |
eebd6f |
componentsSortSetValue() {},
|
|
Packit Service |
eebd6f |
selectedComponents: [],
|
|
Packit Service |
eebd6f |
dependencies: [],
|
|
Packit Service |
eebd6f |
componentsSortKey: "",
|
|
Packit Service |
eebd6f |
componentsSortValue: "",
|
|
Packit Service |
eebd6f |
componentsFilters: {},
|
|
Packit Service |
eebd6f |
componentsFilterAddValue() {},
|
|
Packit Service |
eebd6f |
componentsFilterRemoveValue() {},
|
|
Packit Service |
eebd6f |
componentsFilterClearValues() {},
|
|
Packit Service |
eebd6f |
pastLength: 0,
|
|
Packit Service |
eebd6f |
futureLength: 0,
|
|
Packit Service |
eebd6f |
undo() {},
|
|
Packit Service |
eebd6f |
redo() {},
|
|
Packit Service |
eebd6f |
deleteHistory() {},
|
|
Packit Service |
eebd6f |
blueprintContentsError: {},
|
|
Packit Service |
eebd6f |
blueprintContentsFetching: true,
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
const makeMapStateToProps = () => {
|
|
Packit Service |
eebd6f |
const getBlueprintById = makeGetBlueprintById();
|
|
Packit Service |
eebd6f |
const getSortedSelectedComponents = makeGetSortedSelectedComponents();
|
|
Packit Service |
eebd6f |
const getSortedDependencies = makeGetSortedDependencies();
|
|
Packit Service |
eebd6f |
const getFilteredComponents = makeGetFilteredComponents();
|
|
Packit Service |
eebd6f |
const getPastLength = makeGetPastLength();
|
|
Packit Service |
eebd6f |
const getFutureLength = makeGetFutureLength();
|
|
Packit Service |
eebd6f |
const getSelectedInputs = makeGetSelectedInputs();
|
|
Packit Service |
eebd6f |
const getSelectedDeps = makeGetSelectedDeps();
|
|
Packit Service |
eebd6f |
const mapStateToProps = (state, props) => {
|
|
Packit Service |
eebd6f |
if (getBlueprintById(state, props.route.params.blueprint.replace(/\s/g, "-")) !== undefined) {
|
|
Packit Service |
eebd6f |
const fetchedBlueprint = getBlueprintById(state, props.route.params.blueprint.replace(/\s/g, "-"));
|
|
Packit Service |
eebd6f |
return {
|
|
Packit Service |
eebd6f |
blueprint: fetchedBlueprint.present,
|
|
Packit Service |
eebd6f |
selectedComponents: getFilteredComponents(state, getSortedSelectedComponents(state, fetchedBlueprint.present)),
|
|
Packit Service |
eebd6f |
dependencies: getFilteredComponents(state, getSortedDependencies(state, fetchedBlueprint.present)),
|
|
Packit Service |
eebd6f |
componentsSortKey: state.sort.components.key,
|
|
Packit Service |
eebd6f |
componentsSortValue: state.sort.components.value,
|
|
Packit Service |
eebd6f |
componentsFilters: state.filter.components,
|
|
Packit Service |
eebd6f |
inputs: state.inputs,
|
|
Packit Service |
eebd6f |
inputComponents: getSelectedInputs(state, fetchedBlueprint.present.components),
|
|
Packit Service |
eebd6f |
selectedInput: state.inputs.selectedInput,
|
|
Packit Service |
eebd6f |
selectedInputDeps: getSelectedDeps(
|
|
Packit Service |
eebd6f |
state,
|
|
Packit Service |
eebd6f |
state.inputs.selectedInput.component.dependencies,
|
|
Packit Service |
eebd6f |
fetchedBlueprint.present.components
|
|
Packit Service |
eebd6f |
),
|
|
Packit Service |
eebd6f |
modalActive: state.modals.modalActive,
|
|
Packit Service |
eebd6f |
pastLength: getPastLength(fetchedBlueprint),
|
|
Packit Service |
eebd6f |
futureLength: getFutureLength(fetchedBlueprint),
|
|
Packit Service |
eebd6f |
blueprintContentsError: fetchedBlueprint.present.errorState,
|
|
Packit Service |
eebd6f |
blueprintContentsFetching: !!(
|
|
Packit Service |
eebd6f |
fetchedBlueprint.present.components === undefined && fetchedBlueprint.present.errorState === undefined
|
|
Packit Service |
eebd6f |
),
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
}
|
|
Packit Service |
eebd6f |
return {
|
|
Packit Service |
eebd6f |
blueprint: {},
|
|
Packit Service |
eebd6f |
selectedComponents: [],
|
|
Packit Service |
eebd6f |
dependencies: [],
|
|
Packit Service |
eebd6f |
componentsSortKey: state.sort.components.key,
|
|
Packit Service |
eebd6f |
componentsSortValue: state.sort.components.value,
|
|
Packit Service |
eebd6f |
componentsFilters: state.filter.components,
|
|
Packit Service |
eebd6f |
inputs: state.inputs,
|
|
Packit Service |
eebd6f |
inputComponents: state.inputs.inputComponents,
|
|
Packit Service |
eebd6f |
selectedInput: state.inputs.selectedInput,
|
|
Packit Service |
eebd6f |
modalActive: state.modals.modalActive,
|
|
Packit Service |
eebd6f |
pastLength: 0,
|
|
Packit Service |
eebd6f |
futureLength: 0,
|
|
Packit Service |
eebd6f |
blueprintContentsError: {},
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
return mapStateToProps;
|
|
Packit Service |
eebd6f |
};
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
const mapDispatchToProps = (dispatch) => ({
|
|
Packit Service |
eebd6f |
fetchingBlueprintContents: (blueprintId) => {
|
|
Packit Service |
eebd6f |
dispatch(fetchingBlueprintContents(blueprintId));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
fetchingInputs: (filter, selectedInputPage, pageSize) => {
|
|
Packit Service |
eebd6f |
dispatch(fetchingInputs(filter, selectedInputPage, pageSize));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
setSelectedInputPage: (selectedInputPage) => {
|
|
Packit Service |
eebd6f |
dispatch(setSelectedInputPage(selectedInputPage));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
setBlueprint: (blueprint) => {
|
|
Packit Service |
eebd6f |
dispatch(setBlueprint(blueprint));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
updateBlueprintComponents: (blueprintId, components, packages, modules, pendingChange) => {
|
|
Packit Service |
eebd6f |
dispatch(updateBlueprintComponents(blueprintId, components, packages, modules, pendingChange));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
setSelectedInput: (selectedInput) => {
|
|
Packit Service |
eebd6f |
dispatch(setSelectedInput(selectedInput));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
setSelectedInputDeps: (dependencies) => {
|
|
Packit Service |
eebd6f |
dispatch(setSelectedInputDeps(dependencies));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
setSelectedInputParent: (selectedInputParent) => {
|
|
Packit Service |
eebd6f |
dispatch(setSelectedInputParent(selectedInputParent));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
clearSelectedInput: () => {
|
|
Packit Service |
eebd6f |
dispatch(clearSelectedInput());
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
deleteFilter: () => {
|
|
Packit Service |
eebd6f |
dispatch(deleteFilter());
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
setModalActive: (modalActive) => {
|
|
Packit Service |
eebd6f |
dispatch(setModalActive(modalActive));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
componentsSortSetKey: (key) => {
|
|
Packit Service |
eebd6f |
dispatch(componentsSortSetKey(key));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
componentsSortSetValue: (value) => {
|
|
Packit Service |
eebd6f |
dispatch(componentsSortSetValue(value));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
dependenciesSortSetKey: (key) => {
|
|
Packit Service |
eebd6f |
dispatch(dependenciesSortSetKey(key));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
dependenciesSortSetValue: (value) => {
|
|
Packit Service |
eebd6f |
dispatch(dependenciesSortSetValue(value));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
componentsFilterAddValue: (value) => {
|
|
Packit Service |
eebd6f |
dispatch(componentsFilterAddValue(value));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
componentsFilterRemoveValue: (value) => {
|
|
Packit Service |
eebd6f |
dispatch(componentsFilterRemoveValue(value));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
componentsFilterClearValues: (value) => {
|
|
Packit Service |
eebd6f |
dispatch(componentsFilterClearValues(value));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
undo: (blueprintId, reload) => {
|
|
Packit Service |
eebd6f |
dispatch(undo(blueprintId, reload));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
redo: (blueprintId, reload) => {
|
|
Packit Service |
eebd6f |
dispatch(redo(blueprintId, reload));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
deleteHistory: (blueprintId, reload) => {
|
|
Packit Service |
eebd6f |
dispatch(deleteHistory(blueprintId, reload));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
fetchingCompDeps: (component, blueprintId) => {
|
|
Packit Service |
eebd6f |
dispatch(fetchingCompDeps(component, blueprintId));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
fetchingDepDetails: (component, blueprintId) => {
|
|
Packit Service |
eebd6f |
dispatch(fetchingDepDetails(component, blueprintId));
|
|
Packit Service |
eebd6f |
},
|
|
Packit Service |
eebd6f |
});
|
|
Packit Service |
eebd6f |
|
|
Packit Service |
eebd6f |
export default connect(makeMapStateToProps, mapDispatchToProps)(injectIntl(EditBlueprintPage));
|