Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only load schema when user has rights on produce screen #1600

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
15 changes: 12 additions & 3 deletions client/src/containers/Topic/TopicProduce/TopicProduce.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 => {
Expand All @@ -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);
Expand Down Expand Up @@ -353,6 +358,8 @@ class TopicProduce extends Form {
}

renderResults = (results, searchValue, selectedValue, tag) => {
const { roles } = this.state;

return (
<div style={{ maxHeight: '678px', overflowY: 'auto', minHeight: '89px' }}>
<ul
Expand Down Expand Up @@ -391,7 +398,9 @@ class TopicProduce extends Form {
} else if (tag === 'topicId') {
if (selectedValue !== key) {
this.setState({ topicId: key });
this.getPreferredSchemaForTopic();
if (roles.SCHEMA && roles.SCHEMA.includes('READ')) {
this.getPreferredSchemaForTopic();
}
}
}
}}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/akhq/repositories/RecordRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ public RecordMetadata produce(
}
}

if (value.isPresent() && valueSchema.isPresent()) {
if (value.isPresent() && valueSchema.isPresent() && StringUtils.isNotEmpty(valueSchema.get())) {
Schema schema = schemaRegistryRepository.getLatestVersion(clusterId, valueSchema.get());
SchemaSerializer valueSerializer = serializerFactory.createSerializer(clusterId, schema.getId());
valueAsBytes = valueSerializer.serialize(value.get());
Expand Down