Skip to content

Commit

Permalink
Merge pull request #87 from fstaudt/master
Browse files Browse the repository at this point in the history
Add readonly mode
  • Loading branch information
jglambed committed May 23, 2019
2 parents 6a2f0af + 59aab1e commit bf3844a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 13 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -70,7 +70,8 @@ var clusters = [
NAME:"prod",
// Schema Registry service URL (i.e. http://localhost:8081)
SCHEMA_REGISTRY: "http://localhost:8081", // https://schema-registry.demo.landoop.com
COLOR: "#141414" // optional
COLOR: "#141414", // optional
readonlyMode: true // optional
},
{
NAME:"dev",
Expand All @@ -86,6 +87,7 @@ var clusters = [
* Use `allowGlobalConfigChanges` to enable configuring Global Compatibility Level from the UI.
* Use `allowTransitiveCompatibilities` to enable transitive compatibility levels. This is supported in SR >= 3.1.1
* Use `allowSchemaDeletion` to enable schema deletion from the UI. This is supported in SR >= 3.3.0
* Use `readonlyMode` to prevent any configuration or schema changes from the UI. It overwrites the previous parameters (`allowGlobalConfigChanges`, `allowSchemaDeletion`).

## Changelog
[Here](https://github.com/Landoop/schema-registry-ui/wiki/Changelog)
Expand Down
12 changes: 10 additions & 2 deletions docker/README.md
Expand Up @@ -19,22 +19,29 @@ Visit http://localhost:8000 to see the UI.

### Advanced Settings

Three of the Schema Registry UI settings need to be enabled explicitly. These
Four of the Schema Registry UI settings need to be enabled explicitly. These
are:

1. Support for global compatibility level configuration support —i.e change the
default compatibility level of your schema registry.
2. Support for transitive compatibility levels (Schema Registry version 3.1.1 or better).
3. Support for Schema deletion (Schema Registry version 3.3.0 or better).
4. Support for readonly mode (overwrites settings for global compatibility configuration and schema deletion)

They are handled by the `ALLOW_GLOBAL`, `ALLOW_TRANSITIVE` and `ALLOW_DELETION`
They are handled by the `ALLOW_GLOBAL`, `ALLOW_TRANSITIVE`, `ALLOW_DELETION` and `READONLY_MODE`
environment variables. E.g:

docker run --rm -p 8000:8000 \
-e "SCHEMAREGISTRY_URL=http://schema.registry.url" \
-e ALLOW_GLOBAL=1 \
-e ALLOW_TRANSITIVE=1 \
-e ALLOW_DELETION=1 \
-e READONLY_MODE=1 \
landoop/schema-registry-ui

docker run --rm -p 8000:8000 \
-e "SCHEMAREGISTRY_URL=http://schema.registry.url" \
-e READONLY_MODE=1 \
landoop/schema-registry-ui

### Proxying Schema Registry
Expand Down Expand Up @@ -71,6 +78,7 @@ You can control most of Kafka Topics UI settings via environment variables:
* `ALLOW_GLOBAL=[true|false]` (default false)
* `ALLOW_TRANSITIVE=[true|false]` (default false)
* `ALLOW_DELETION=[true|false]` (default false).
* `READONLY_MODE=[true|false]` (default false).

## Docker Options

Expand Down
7 changes: 7 additions & 0 deletions docker/run.sh
Expand Up @@ -5,6 +5,7 @@ INSECURE_PROXY=""
ALLOW_GLOBAL="${ALLOW_GLOBAL:-false}"
ALLOW_TRANSITIVE="${ALLOW_TRANSITIVE:-false}"
ALLOW_DELETION="${ALLOW_DELETION:-false}"
READONLY_MODE="${READONLY_MODE:-false}"
CADDY_OPTIONS="${CADDY_OPTIONS:-}"
RELATIVE_PROXY_URL="${RELATIVE_PROXY_URL:-false}"
PORT="${PORT:-8000}"
Expand Down Expand Up @@ -55,6 +56,11 @@ EOF
echo "Enabling schema deletion support."
fi

if echo "$READONLY_MODE" | egrep -sq "true|TRUE|y|Y|yes|YES|1"; then
READONLY_SETTING=",readonlyMode: true"
echo "Enabling readonly mode."
fi

if [[ -z "$SCHEMAREGISTRY_URL" ]]; then
echo "Schema Registry URL was not set via SCHEMAREGISTRY_URL environment variable."
else
Expand All @@ -67,6 +73,7 @@ var clusters = [
$GLOBAL_SETTING
$TRANSITIVE_SETTING
$DELETION_SETTING
$READONLY_SETTTING
}
]
EOF
Expand Down
3 changes: 2 additions & 1 deletion env.js
Expand Up @@ -3,7 +3,8 @@ var clusters = [
NAME: "prod",
// Schema Registry service URL (i.e. http://localhost:8081)
SCHEMA_REGISTRY: "http://localhost:8081", // https://schema-registry.demo.landoop.com
COLOR: "#141414" // optional
COLOR: "#141414", // optional
readonlyMode: true // optional
},
{
NAME: "dev",
Expand Down
7 changes: 4 additions & 3 deletions src/factories/env-factory.js
Expand Up @@ -17,8 +17,9 @@ var envFactory = function ($rootScope) {
COLOR : function () { return selectedCluster.COLOR; },
allowGlobalConfigChanges : function () { return selectedCluster.allowGlobalConfigChanges; },
allowTransitiveCompatibilities: function () { return selectedCluster.allowTransitiveCompatibilities; },
allowSchemaDeletion: function () { return selectedCluster.allowSchemaDeletion; }
};
allowSchemaDeletion: function () { return selectedCluster.allowSchemaDeletion; },
readonlyMode: function() { return selectedCluster.readonlyMode; }
};

function setCluster(clusterName) {
if(clusterArray.length === 0) {
Expand All @@ -36,4 +37,4 @@ var envFactory = function ($rootScope) {

envFactory.$inject = ['$rootScope'];

angularAPP.factory('env', envFactory);
angularAPP.factory('env', envFactory);
2 changes: 1 addition & 1 deletion src/schema-registry/config/config.controller.js
Expand Up @@ -21,7 +21,7 @@ var SchemaRegistryConfigCtrl = function ($scope, $http, $log, $mdDialog, SchemaR

SchemaRegistryFactory.getGlobalConfig().then(
function success(config) {
$scope.allowChanges = env.allowGlobalConfigChanges();
$scope.allowChanges = !env.readonlyMode() && env.allowGlobalConfigChanges();
$scope.config = config;
$scope.connectionFailure = false;
$scope.form = $scope.config.compatibilityLevel;
Expand Down
1 change: 1 addition & 0 deletions src/schema-registry/view/view.controller.js
Expand Up @@ -26,6 +26,7 @@ var SubjectsCtrl = function ($rootScope, $scope, $route, $routeParams, $log, $lo
}
);
$scope.allowSchemaDeletion = env.allowSchemaDeletion();
$scope.readonlyMode = env.readonlyMode();
$scope.allowTransitiveCompatibilities = env.allowTransitiveCompatibilities();

$scope.$watch(function () {
Expand Down
10 changes: 5 additions & 5 deletions src/schema-registry/view/view.html
Expand Up @@ -71,20 +71,20 @@ <h3 class="md-toolbar-tools" style="margin-top:10px;text-align:center;" hide-gt-
<div class="buttonGroup" ng-hide="hideEdit" ng-if="aceReady && !showDeleteConfirmation" >

<!-- When in non-editable state, display the EDIT button -->
<md-button ng-show="!isAvroAceEditable" ng-click="toggleEditor();"
<md-button ng-show="!isAvroAceEditable" ng-click="toggleEditor();" ng-if="!readonlyMode"
aria-label="EDIT"
aria-hidden="false">
<i class="fa fa-pencil-square-o ng-scope" aria-hidden="true"></i>
EDIT
</md-button>
<!-- When in edit-state, display the CANCEL button -->
<md-button ng-show="isAvroAceEditable" ng-click="cancelEditor();"
<md-button ng-show="isAvroAceEditable && !readonlyMode" ng-click="cancelEditor();"
type="button" aria-label="CANCEL"
aria-hidden="false">
<i class="fa fa-ban ng-scope" aria-hidden="true"></i>
CANCEL
</md-button>
<md-menu d-position-mode="target-right target" ng-if="!isAvroAceEditable && allowSchemaDeletion">
<md-menu d-position-mode="target-right target" ng-if="!isAvroAceEditable && allowSchemaDeletion && !readonlyMode">
<md-button ng-click="$mdOpenMenu($event)">
<i class="fa fa-trash" aria-hidden="true"></i>
DELETE
Expand Down Expand Up @@ -269,7 +269,7 @@ <h3 class="md-toolbar-tools" style="margin-top:10px;text-align:center;" hide-gt-
</md-content>
</md-tab-body>
</md-tab>
<md-tab md-on-select="hideEdit = true;">
<md-tab md-on-select="hideEdit = true;" ng-if="!readonlyMode">
<md-tab-label>
Config
<!--<i class="fa fa-file-text-o" style="padding-right:10px;" aria-hidden="true"></i> Schema-->
Expand Down Expand Up @@ -325,4 +325,4 @@ <h5>Version 1 <span
</md-tabs>
</md-content>
<!--old code ends here-->
</md-card>
</md-card>

0 comments on commit bf3844a

Please sign in to comment.