From dd374c9f081f81cea3d78088e70a34f0d22949bb Mon Sep 17 00:00:00 2001 From: Alexis SOUQUIERE Date: Sun, 19 Nov 2023 20:25:44 +0100 Subject: [PATCH] fix(schema): only load schema when user has rights on produce screen (#1600) close #1597 --- client/src/App.js | 2 +- .../Topic/TopicProduce/TopicProduce.jsx | 15 ++++++++++++--- .../org/akhq/repositories/RecordRepository.java | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/src/App.js b/client/src/App.js index 98320d4df..f48a6b58e 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -19,7 +19,7 @@ class App extends React.Component { window.location = uriLogin(); } - return error; + return Promise.reject(error); } catch (e) { // Propagate cancel if (axios.isCancel(error)) { diff --git a/client/src/containers/Topic/TopicProduce/TopicProduce.jsx b/client/src/containers/Topic/TopicProduce/TopicProduce.jsx index 5f142e871..2ff95c2f0 100644 --- a/client/src/containers/Topic/TopicProduce/TopicProduce.jsx +++ b/client/src/containers/Topic/TopicProduce/TopicProduce.jsx @@ -48,7 +48,8 @@ class TopicProduce extends Form { topicsSearchValue: '', multiMessage: false, tombstone: false, - valuePlaceholder: '{"param": "value"}' + valuePlaceholder: '{"param": "value"}', + roles: JSON.parse(sessionStorage.getItem('roles')) }; schema = { @@ -62,6 +63,7 @@ class TopicProduce extends Form { async componentDidMount() { const { clusterId, topicId } = this.props.match.params; + const { roles } = this.state; let response = await this.getApi(uriTopicsPartitions(clusterId, topicId)); let partitions = response.data.map(item => { @@ -78,7 +80,10 @@ class TopicProduce extends Form { } }); - await this.getPreferredSchemaForTopic(); + if (roles.SCHEMA && roles.SCHEMA.includes('READ')) { + await this.getPreferredSchemaForTopic(); + } + const topicEventData = popProduceToTopicValues(); if (Object.keys(topicEventData).length) { await this.initByTopicEvent(topicEventData); @@ -353,6 +358,8 @@ class TopicProduce extends Form { } renderResults = (results, searchValue, selectedValue, tag) => { + const { roles } = this.state; + return (