diff --git a/src/api-client/graph.js b/src/api-client/graph.js index 5fa813c275..c2815ed129 100644 --- a/src/api-client/graph.js +++ b/src/api-client/graph.js @@ -41,7 +41,7 @@ function addGraphMethods(client) { if (resp.status === 200 || resp.status === 201) { return true; } - else if (resp.status === 401) { + else if (resp.status === 404) { return false; } else { diff --git a/src/model/RenkuModels.js b/src/model/RenkuModels.js index 59ca5a8a13..eeca9d18f5 100644 --- a/src/model/RenkuModels.js +++ b/src/model/RenkuModels.js @@ -64,6 +64,8 @@ const projectSchema = new Schema({ external_url: {initial: '',}, path_with_namespace: {initial: null}, owner: {initial: null}, + graphWebhookStatus: {initial: null}, + graphWebhookCreated: {initial: null} } }, visibility: { diff --git a/src/project/Project.js b/src/project/Project.js index 99ee4b5a60..f0e4130e31 100644 --- a/src/project/Project.js +++ b/src/project/Project.js @@ -271,7 +271,7 @@ class View extends Component { stopNotebookServer: (serverName) => { this.stopNotebookServer(serverName); }, - onGraphWebhookCreate: (e) => { + createGraphWebhook: (e) => { e.preventDefault(); this.createGraphWebhook(); }, diff --git a/src/project/Project.present.js b/src/project/Project.present.js index 04f606ce7c..d4c1c61cc4 100644 --- a/src/project/Project.present.js +++ b/src/project/Project.present.js @@ -77,6 +77,13 @@ function isRequestPending(props, request) { return requests[request] === SpecialPropVal.UPDATING; } +function webhookError(props) { + if (props == null || props === SpecialPropVal.UPDATING || props === true || props === false) { + return false; + } + return true; +} + class ImageBuildInfo extends Component { render() { const imageBuild = this.props.imageBuild || {status: 'success'}; @@ -137,67 +144,89 @@ class MergeRequestSuggestions extends Component { */ class KnowledgeGraphIntegrationWarningBanner extends Component { render() { - const errorKnowledgeGraph = this.props.core.graphWebhookError; - if (errorKnowledgeGraph) { - return( - - - - Some error occured with the Knowledge-graph integration. - - - + const status = this.props.core.graphWebhookStatus; + if (status === false) { + const isPrivate = this.props.visibility && this.props.visibility.level === "private" ? true : false; + return ( + ) } - - const doesUserHaveRights = this.props.core.graphWebhookPossible; - if (!doesUserHaveRights) return null; - const isProjectedIntegrated = this.props.core.graphWebhookAvailable; - const created = this.props.core.graphWebhookCreated; - if (isProjectedIntegrated && !created) return null; - const loading = this.props.core.graphWebhookLoading; - return ( - - - - - - ) + const error = webhookError(status); + if (error) { + return ( + + An error has occured while checking webhook state: " + {status.message}" +
Please try to reload the page. +
+ ) + } + return null; } } class KnowledgeGraphWarning extends Component { render() { - if (this.props.done) { + const webhook = this.props.webhook; + if (webhook === true) { return ( - Webhook successfully created. + Lineage computation successfully activated. ) } - return ( - - Knowledge-graph integration is not turned on. - - ) + else if (webhook === false || webhook === SpecialPropVal.UPDATING) { + const updating = webhook === SpecialPropVal.UPDATING ? true : false; + return ( + + Lineage computation is turned off. + + + ) + } + else { + let error; + if (webhookError(webhook)) { + error = `An error has occured with the Lineage computation: "${webhook.message}".`; + } + else { + error = "An unknown error has occured with the Lineage computation."; + } + return ( + + {error} +
Try again: +
+ ) + } + } +} + +class KnowledgeGraphPrivateWarning extends Component { + render() { + if (!this.props.isPrivate) return null; + return [ +
, + + WARNING! + Some metadata may become public even for private projects. This is not reversible. + + ] } } class KnowledgeGraphLink extends Component { render() { - if (this.props.loading) { + if (this.props.updating) { return ( - - Turning it on... - + Turning it on... ) } return ( - + ) } } diff --git a/src/project/Project.state.js b/src/project/Project.state.js index ad3cb73a8d..226ec3dc6c 100644 --- a/src/project/Project.state.js +++ b/src/project/Project.state.js @@ -37,30 +37,25 @@ class ProjectModel extends StateModel { } fetchGraphWebhookStatus(client, id) { - // temporary value to avoid fake warning. - this.set('core.graphWebhookAvailable', true); + this.set('core.graphWebhookCreated', false); + this.setUpdating({core: {graphWebhookStatus: true}}); return client.checkGraphWebhook(id) .then((resp) => { - this.set('core.graphWebhookAvailable', resp); + this.set('core.graphWebhookStatus', resp); }) .catch((err) => { - this.set('core.graphWebhookError', err); + this.set('core.graphWebhookStatus', err); }); } createGraphWebhook(client, id) { - this.set('core.graphWebhookLoading', true); + this.setUpdating({core: {graphWebhookCreated: true}}); return client.createGraphWebhook(id) .then((resp) => { - this.set('core.graphWebhookAvailable', resp); - this.set('core.graphWebhookLoading', false); - if (resp) { - // we need this to display a positive feedback when the webhook is created - this.set('core.graphWebhookCreated', true); - } + this.set('core.graphWebhookCreated', resp); }) .catch((err) => { - this.set('core.graphWebhookError', err); + this.set('core.graphWebhookCreated', err); }); } diff --git a/src/project/new/ProjectNew.present.js b/src/project/new/ProjectNew.present.js index be832454e5..f00e132bb0 100644 --- a/src/project/new/ProjectNew.present.js +++ b/src/project/new/ProjectNew.present.js @@ -192,11 +192,19 @@ class DataVisibility extends Component { const options = visibilities.map(v => ) + let warningPrivate = null; + if (this.props.value === "private") { + warningPrivate = + Please be aware that some metadata may become public even for private projects + due to Lineage computation. + ; + } return {options} + {warningPrivate} {vizExplanation} }