{"version":3,"sources":["webpack:///./src/main/web/components/admin/repositories/TurtleEditor.ts","webpack:///./src/main/web/components/admin/repositories/RepositoryConfigEditor.tsx"],"names":["props","context","onChangeTurtle","editor","editorChange","source","onChange","setState","getTurtle","state","turtleString","componentWillReceiveProps","nextProps","this","render","React","createElement","className","value","onBeforeChange","options","foldGutter","textAreaClassName","matchTags","bothTags","matchBrackets","mode","indentWithTabs","indentUnit","tabSize","viewportMargin","Infinity","lineNumbers","lineWrapping","gutters","Component","TurtleEditorComponent","cancellation","Cancellation","fetchConfig","id","responseError","undefined","loadingError","submittedSuccessfully","validateConfiguration","map","getRepositoryConfig","observe","config","error","handleNewRepositoryID","e","preventDefault","stopPropagation","newRepositoryID","target","getNewRepositoryIDValidation","isEditMode","reg","RegExp","length","test","onSubmitConfig","turtle","refs","updateOrAddRepositoryConfig","onValue","v","refresh","onError","console","log","renderTemplateSelector","repositoryTemplates","Spinner","items","MenuItem","eventKey","key","DropdownButton","bsStyle","title","onSelect","onTemplateSelected","selectTemplate","templateId","getRepositoryConfigTemplate","executeDeleteRepository","deleteRepositoryConfig","onDeleteRepository","dialogRef","hideDialog","getOverlaySystem","hide","message","onHide","onConfirm","confirm","show","ConfirmationDialog","componentDidMount","preselectedTemplate","componentWillUnmount","cancelAll","showRestartPrompt","reloadPageOnSuccess","initializerMode","Alert","styles","holder","Form","horizontal","FormGroup","formGroup","validationState","FormControl","type","placeholder","HelpBlock","ref","checked","disabled","Button","ActionButton","onClick","window","location","reload","defaultProps","RepositoryConfigEditor"],"mappings":"6IAmBA,OAEA,OACA,OAEA,OACA,OACA,OACA,OACA,OAEA,aAOA,cACE,+BAAYA,EAAcC,GAA1B,MACE,YAAMD,EAAOC,IAAQ,K,OAqCvB,EAAAC,eAAiB,SAACC,EAAYC,EAAkBC,GAC1C,EAAKL,MAAMM,SACb,EAAKN,MAAMM,SAASD,GAEpB,EAAKE,SAAS,CACZF,OAAQA,KAKP,EAAAG,UAAY,WACjB,OAAO,EAAKC,MA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B,mBAAmB,EACnBH,yBAAqB5D,EACrBgE,qBAAqB,EACrBC,iBAAiB,GAwPrB,uBAhQA,CAA4C,EAAAxE,WAA/B,EAAA+F,yBAkQb,UAAeA","file":"default~app~mp-admin-repository-mgmt-5d5373e9658507935ed7.js","sourcesContent":["/**\n * ResearchSpace\n * Copyright (C) 2020, © Trustees of the British Museum\n * Copyright (C) 2015-2019, metaphacts GmbH\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport * as React from 'react';\n\nimport 'codemirror/lib/codemirror.css';\nimport 'codemirror/mode/turtle/turtle';\n\nimport 'codemirror/addon/fold/foldcode';\nimport 'codemirror/addon/fold/brace-fold';\nimport 'codemirror/addon/fold/indent-fold';\nimport 'codemirror/addon/edit/matchtags';\nimport 'codemirror/addon/edit/matchbrackets';\n\nimport { Controlled as ReactCodeMirror } from 'react-codemirror2';\n\ninterface Props {\n turtleString: string;\n onChange?: (turtle: string) => void;\n}\n\nexport class TurtleEditorComponent extends React.Component {\n constructor(props: Props, context: any) {\n super(props, context);\n this.state = {\n source: props.turtleString ? props.turtleString : '',\n };\n }\n\n componentWillReceiveProps(nextProps: Props) {\n if (this.props.turtleString !== nextProps.turtleString) {\n this.setState({ source: nextProps.turtleString });\n }\n }\n\n public render() {\n const codeMirrorAddonOptions = {\n foldGutter: false,\n textAreaClassName: ['form-control'],\n matchTags: { bothTags: true },\n matchBrackets: true,\n };\n return React.createElement(ReactCodeMirror, {\n className: 'turtle-editor',\n value: this.state.source,\n onBeforeChange: this.onChangeTurtle,\n options: {\n ...codeMirrorAddonOptions,\n mode: 'text/turtle',\n indentWithTabs: false,\n indentUnit: 2,\n tabSize: 2,\n viewportMargin: Infinity,\n lineNumbers: true,\n lineWrapping: true,\n gutters: ['CodeMirror-linenumbers'],\n },\n });\n }\n\n onChangeTurtle = (editor: {}, editorChange: {}, source: string) => {\n if (this.props.onChange) {\n this.props.onChange(source);\n } else {\n this.setState({\n source: source,\n });\n }\n };\n\n public getTurtle = () => {\n return this.state.source;\n };\n}\n\nexport default TurtleEditorComponent;\n","/**\n * ResearchSpace\n * Copyright (C) 2020, © Trustees of the British Museum\n * Copyright (C) 2015-2019, metaphacts GmbH\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\nimport * as React from 'react';\nimport { Button, Alert, DropdownButton, MenuItem, FormControl, Form, FormGroup, HelpBlock } from 'react-bootstrap';\nimport { createElement } from 'react';\nimport { Cancellation } from 'platform/api/async';\nimport { Component } from 'platform/api/components';\nimport { refresh } from 'platform/api/navigation';\n\nimport { Spinner } from 'platform/components/ui/spinner';\nimport {\n getRepositoryConfig,\n getRepositoryConfigTemplate,\n updateOrAddRepositoryConfig,\n deleteRepositoryConfig,\n} from 'platform/api/services/repository';\nimport { ConfirmationDialog } from 'platform/components/ui/confirmation-dialog';\nimport * as styles from './RepositoryConfigEditor.scss';\nimport { TurtleEditorComponent } from './TurtleEditor';\nimport { getOverlaySystem } from 'platform/components/ui/overlay';\n\ninterface Props {\n id?: string;\n repositoryTemplates?: string[];\n showRestartPrompt?: boolean;\n preselectedTemplate?: string;\n reloadPageOnSuccess?: boolean;\n initializerMode?: boolean; // true if editor is used from RepositoryConfigInitializer\n}\n\ninterface State {\n readonly source?: string;\n readonly loadingError?: any;\n readonly responseError?: any;\n readonly submittedSuccessfully?: boolean;\n readonly newRepositoryID?: string;\n readonly validateConfiguration?: boolean;\n}\n\ntype ValidationState = 'warning' | 'error' | 'success';\n\nconst SUCCESS_MESSAGE = 'The repository configuration was updated.';\n\nexport class RepositoryConfigEditor extends Component {\n private readonly cancellation = new Cancellation();\n static defaultProps = {\n id: undefined,\n repositoryTemplates: [],\n showRestartPrompt: false,\n preselectedTemplate: undefined,\n reloadPageOnSuccess: false,\n initializerMode: false,\n };\n constructor(props: Props, context: any) {\n super(props, context);\n this.state = {\n validateConfiguration: true,\n };\n }\n\n componentDidMount() {\n if (this.props.preselectedTemplate) {\n this.selectTemplate(this.props.preselectedTemplate);\n } else {\n this.fetchConfig(this.props.id);\n }\n }\n\n fetchConfig = (id: string) => {\n this.setState({\n responseError: undefined,\n loadingError: undefined,\n submittedSuccessfully: false,\n validateConfiguration: true,\n });\n if (!id) {\n this.setState({\n source: undefined,\n });\n return;\n }\n this.cancellation.map(getRepositoryConfig(id)).observe({\n value: (config) =>\n this.setState({\n source: config,\n }),\n error: (loadingError) => this.setState({ loadingError }),\n });\n };\n\n componentWillReceiveProps(nextProps: Props) {\n if (this.props.id !== nextProps.id) {\n this.fetchConfig(nextProps.id);\n }\n }\n\n componentWillUnmount() {\n this.cancellation.cancelAll();\n }\n\n render() {\n const { source, loadingError, responseError, submittedSuccessfully } = this.state;\n const { showRestartPrompt, reloadPageOnSuccess, initializerMode } = this.props;\n\n if (loadingError) {\n return {loadingError} ;\n }\n\n if (this.isEditMode() && !source) {\n return ;\n }\n\n return (\n
\n
\n

{this.isEditMode() ? `Edit Repository Config \"${this.props.id}\"` : `Create new Repository Config`}

\n
\n {!this.isEditMode() && (\n
\n
\n \n Repository ID:\n
\n \n {this.getNewRepositoryIDValidation() && (\n Repository ID must be a unique, alphanumeric string of length >= 5 characters.\n )}\n
\n
\n
\n )}\n
{this.renderTemplateSelector()}
\n
\n \n
\n \n
\n \n {this.isEditMode() ? 'Update Config' : 'Create Config'}\n \n {this.isEditMode() && !initializerMode && (\n this.onDeleteRepository(this.props.id)}\n >\n Delete\n \n )}\n {responseError && {responseError} }\n {reloadPageOnSuccess && submittedSuccessfully && window.location.reload()}\n {showRestartPrompt && submittedSuccessfully && {SUCCESS_MESSAGE} }\n
\n
\n );\n }\n\n handleNewRepositoryID = (e: React.SyntheticEvent) => {\n e.preventDefault();\n e.stopPropagation();\n this.setState({ newRepositoryID: (e.target as any).value });\n };\n\n getNewRepositoryIDValidation = (): ValidationState => {\n if (this.isEditMode()) {\n return undefined;\n }\n const id = this.state.newRepositoryID;\n const reg = new RegExp('');\n if (!id || id.length < 5 || !reg.test(id)) {\n return 'warning';\n }\n return 'success';\n };\n\n onSubmitConfig = () => {\n const id = this.props.id ? this.props.id : this.state.newRepositoryID;\n const turtle = (this.refs['editor'] as TurtleEditorComponent).getTurtle();\n updateOrAddRepositoryConfig(id, turtle, this.state.validateConfiguration)\n .onValue((v) => {\n this.setState({\n responseError: undefined,\n submittedSuccessfully: true,\n });\n refresh();\n })\n .onError((error) => {\n console.log(error);\n this.setState({\n responseError: error,\n submittedSuccessfully: false,\n });\n });\n };\n\n isEditMode = () => {\n return this.props.id ? true : false;\n };\n\n renderTemplateSelector = () => {\n const { repositoryTemplates } = this.props;\n if (!repositoryTemplates) {\n return ;\n }\n const items = repositoryTemplates.map((id) => {\n return (\n \n {id}\n \n );\n });\n return (\n \n {items}\n \n );\n };\n\n selectTemplate = (templateId) => {\n this.cancellation.map(getRepositoryConfigTemplate(templateId)).observe({\n value: (value) => {\n this.setState({ source: value, submittedSuccessfully: false });\n },\n error: (error) => this.setState({ loadingError: error, submittedSuccessfully: false }),\n });\n };\n\n onTemplateSelected = (eventKey: any, e?: React.SyntheticEvent<{}>) => {\n e.preventDefault();\n e.stopPropagation();\n this.selectTemplate(eventKey);\n };\n\n executeDeleteRepository = (id) => {\n deleteRepositoryConfig(id).observe({\n value: () => {\n this.setState({\n responseError: undefined,\n submittedSuccessfully: true,\n });\n refresh();\n },\n error: (error) => {\n this.setState({\n responseError: error,\n submittedSuccessfully: false,\n });\n },\n });\n };\n\n onDeleteRepository = (id: string) => {\n const dialogRef = 'delete-repository-confirmation';\n const hideDialog = () => getOverlaySystem().hide(dialogRef);\n const props = {\n message: `Do you want to delete the \"${id}\" repository?`,\n onHide: () => {\n hideDialog();\n },\n onConfirm: (confirm) => {\n hideDialog();\n if (confirm) {\n this.executeDeleteRepository(id);\n }\n },\n };\n getOverlaySystem().show(dialogRef, createElement(ConfirmationDialog, props));\n };\n}\n\nexport default RepositoryConfigEditor;\n"],"sourceRoot":""}