deleteResource: function(resource, project, options) { // todo: remove instance from project after deletion if (resource instanceof Instance) { actions.InstanceActions.destroy( { instance: resource, project: project }, options ); } else if (resource instanceof Volume) { actions.VolumeActions.destroy( { volume: resource, project: project }, options ); } else if (resource instanceof ExternalLink) { actions.ExternalLinkActions.destroy_noModal( { external_link: resource, project: project }, options ); } else if (resource instanceof Image) { actions.ProjectImageActions.removeImageFromProject({ project: project, image: resource }); } else { throw new Error("Unknown resource type"); } },
onDoneEditing: function (text) { this.setState({ name: text, isEditing: false }); actions.InstanceActions.update(this.props.instance, {name: text}); },
ModalHelpers.renderModal(ModalComponent, props, function() { attachedVolumes.forEach(volume => VolumeStore.pollUntilDetached(volume) ); actions.InstanceActions.destroy(payload, options); if (project) { appBrowserHistory.push(`/projects/${project.id}/resources`); } });
ModalHelpers.renderModal(InstanceLaunchWizardModal, props, function (launchData) { var size = launchData.size, version = launchData.version, identity = launchData.identity, name = launchData.name, project = launchData.project; actions.InstanceActions.launch({ project: project, instanceName: name, identity: identity, size: size, version: version }); });
addResourceToProject: function(resource, project, options) { // todo: settings projects here is a bad hack - it's because there are a // few places in the code that access instance/volume.get('projects')[0] // Instead we need to change those places to access a resources project // either through stores.ProjectInstanceStore or the route URL (getParams().projectId); if (resource instanceof Instance) { resource.set("project", project); actions.InstanceActions.update( resource, { project: project }, options ); } else if (resource instanceof Volume) { resource.set("project", project); actions.VolumeActions.update( resource, { project: project }, options ); } else if (resource instanceof ExternalLink) { resource.set("projects", [project.id]); actions.ProjectExternalLinkActions.addExternalLinkToProject( { project: project, external_link: resource }, options ); } else if (resource instanceof Image) { resource.set("projects", [project.id]); actions.ProjectImageActions.addImageToProject( { project: project, image: resource }, options ); } else { throw new Error("Unknown resource type"); } },
onSubmitLaunch: function() { let licenseList = this.state.imageVersion.get('licenses'); if (this.canLaunch()) { if (licenseList.length >= 1 && this.state.view === 'BASIC_VIEW') { this.viewLicense(); return } let launchData = { project: this.state.project, instanceName: this.state.instanceName.trim(), identity: this.state.identityProvider, size: this.state.providerSize, version: this.state.imageVersion, scripts: this.state.attachedScripts }; actions.InstanceActions.launch(launchData); this.hide(); return } this.setState({showValidationErr: true}) },
removeResourceFromProject: function(resource, project, options) { if (resource instanceof Instance) { actions.InstanceActions.update( resource, { project: null }, options ); } else if (resource instanceof Volume) { actions.VolumeActions.update( resource, { project: project }, options ); } else if (resource instanceof ExternalLink) { actions.ProjectExternalLinkActions.removeExternalLinkFromProject( { project: project, external_link: resource }, options ); } else if (resource instanceof Image) { actions.ProjectImageActions.removeImageFromProject( { project: project, image: resource }, options ); } else { throw new Error("Unknown resource type"); } },
ModalHelpers.renderModal(InstanceUnshelveModal, null, function() { actions.InstanceActions.unshelve({ instance: instance }); });
currentProject = params.currentProject, resourcesCount = resources && resources.size ? resources.size() : 0; resources.map(r => this.moveResource(r, currentProject, newProject)); Utils.dispatch(ProjectConstants.EMIT_CHANGE); // NOTE: this _completed_ the move selected resources action; // interested in how many use this project-related action trackAction("moved-project-resources", { "number-of-resources": resourcesCount }); }, moveResource(resource, currentProject, newProject) { if (resource instanceof Instance) { actions.InstanceActions.update(resource, { project: newProject }); } else if (resource instanceof Volume) { actions.VolumeActions.update(resource, { project: newProject }); } else if (resource instanceof ExternalLink) { resource.set("projects", [newProject.id]); actions.ProjectExternalLinkActions.addExternalLinkToProject({ project: newProject, external_link: resource }); actions.ProjectExternalLinkActions.removeExternalLinkFromProject({ project: currentProject, external_link: resource });
ModalHelpers.renderModal(InstanceStartModal, null, function() { actions.InstanceActions.start({ instance: instance }); });
ModalHelpers.renderModal(InstanceSuspendModal, null, function () { actions.InstanceActions.suspend({ instance: instance }) });
ModalHelpers.renderModal(InstanceResumeModal, null, function() { actions.InstanceActions.resume({ instance: instance }) });
ModalHelpers.renderModal(InstanceReportModal, props, function (reportInfo) { actions.InstanceActions.report({ instance: instance, reportInfo: reportInfo }) })
ModalHelpers.renderModal(InstanceRedeployModal, null, function() { actions.InstanceActions.redeploy({ instance: instance }); });