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

Show & download generated java sources #76

Merged
merged 23 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3b9ef22
Add lifecycle buttons
wwerner Oct 28, 2019
c60e27a
Add version state transition buttons
wwerner Oct 28, 2019
031a1c0
Merge master
wwerner Oct 29, 2019
af23a16
Update test to use ObjectStore API w/ StateSources
wwerner Oct 29, 2019
b5f12ed
Call status update with correct view model value
wwerner Oct 29, 2019
9f4d3db
Return 409 if version status cannot be updated
wwerner Oct 29, 2019
45392ff
Make parent indices non-unique, otherwise an entity could not have mo…
wwerner Oct 29, 2019
486c3e3
Remove status from schema version creation, since all new versions ar…
wwerner Oct 29, 2019
6e89271
Remove schema version status from e2e tests which create schema versions
wwerner Oct 29, 2019
497043d
Move version selection and version list loading to vuex
wwerner Oct 29, 2019
7248a00
Improve button & warning layout
wwerner Oct 30, 2019
ea8d217
Make selected schema version and version list reactive to display cha…
wwerner Oct 30, 2019
c4f83da
Add E2E test for vstate transitions
wwerner Oct 30, 2019
d0ba2ad
Add assertion for enablement of save button based on state
wwerner Oct 30, 2019
a864010
Refresh versions after updating selected version
wwerner Oct 30, 2019
36e42aa
Merge SchemaRepo
wwerner Oct 30, 2019
74b9203
Merge 71-schema_version_state_transitions
wwerner Oct 30, 2019
b7c724a
Add query methods for entities
wwerner Oct 30, 2019
bb09110
Factor out duplicated resource URLs
wwerner Oct 30, 2019
1d4fb0e
Disable source button if no version is selected
wwerner Oct 30, 2019
1cbac0c
Retrieve source code from properties view
wwerner Oct 30, 2019
e064f6b
Include source highlighting for java
wwerner Oct 30, 2019
543b2ba
Show generated sources in dialog
wwerner Oct 30, 2019
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
6 changes: 3 additions & 3 deletions src/main/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/main/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"devDependencies": {
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@mdi/js": "^4.4.95",
"@mdi/js": "^4.5.95",
"@vue/cli-plugin-babel": "^3.4.0",
"@vue/cli-plugin-eslint": "^3.4.0",
"@vue/cli-service": "^3.8.0",
Expand Down
90 changes: 83 additions & 7 deletions src/main/frontend/src/api/SchemataRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ import Repository from '@/api/Repository'

const resources = {
organizations: () => '/organizations',
units: (o) => `/organizations/${o}/units`,
contexts: (o, u) => `/organizations/${o}/units/${u}/contexts`,
organization: (o) => `${resources.organizations()}/${o}`,
units: (o) => `${resources.organization(o)}/units`,
unit: (o, u) => `${resources.units(o)}/${u}`,
contexts: (o, u) => `${resources.unit(o, u)}/contexts`,
context: (o, u, c) => `${resources.contexts(o, u)}/${c}`,
categories: () => '/schema/categories',
scopes: () => '/schema/scopes',
schemata: (o, u, c) => `/organizations/${o}/units/${u}/contexts/${c}/schemas`,
versions: (o, u, c, s) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions`,
schemaSpecification: (o, u, c, s, v) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions/${v}/specification`
schemata: (o, u, c) => `${resources.context(o, u, c)}/schemas`,
schema: (o, u, c, s) => `${resources.schemata(o, u, c)}/${s}`,
versions: (o, u, c, s) => `${resources.schema(o, u, c, s)}/versions`,
version: (o, u, c, s, v) => `${resources.versions(o, u, c, s)}/${v}`,
versionStatus: (o, u, c, s, v) => `${resources.version(o, u, c, s, v)}/status`,
schemaSpecification: (o, u, c, s, v) => `${resources.version(o, u, c, s, v)}/specification`,
sources: (o, u, c, s, v, lang) => `/code/${o}:${u}:${c}:${s}:${v}/${lang}`,
}

function ensure(response, status) {
Expand All @@ -33,18 +40,34 @@ export default {
.then(ensureOk)
.then(response => response.data)
},
getOrganization(organization) {
return Repository.get(resources.organization(organization))
.then(ensureOk)
.then(response => response.data)
},

getUnits(organization) {
return Repository.get(resources.units(organization))
.then(ensureOk)
.then(response => response.data)
},
getUnit(organization, unit) {
return Repository.get(resources.unit(organization, unit))
.then(ensureOk)
.then(response => response.data)
},

getContexts(organization, unit) {
return Repository.get(resources.contexts(organization, unit))
.then(ensureOk)
.then(response => response.data)
},
getContext(organization, unit, context) {
return Repository.get(resources.context(organization, unit, context))
.then(ensureOk)
.then(response => response.data)
},

getCategories() {
return Repository.get(resources.categories())
.then(ensureOk)
Expand All @@ -60,12 +83,22 @@ export default {
.then(ensureOk)
.then(response => response.data)
},
getSchema(organization, unit, context, schema) {
return Repository.get(resources.schema(organization, unit, context, schema))
.then(ensureOk)
.then(response => response.data)
},

getVersions(organization, unit, context, schema) {
return Repository.get(resources.versions(organization, unit, context, schema))
.then(ensureOk)
.then(response => response.data)
},
getVersion(organization, unit, context, schema, version) {
return Repository.get(resources.version(organization, unit, context, schema, version))
.then(ensureOk)
.then(response => response.data)
},

createOrganization(name, description) {
return Repository.post(resources.organizations(),
Expand Down Expand Up @@ -115,12 +148,11 @@ export default {
},
createSchemaVersion(
organization, unit, context, schema,
specification, description, status, previousVersion, currentVersion) {
specification, description, previousVersion, currentVersion) {
return Repository.post(resources.versions(organization, unit, context, schema),
{
schemaVersionId: '',
specification: specification,
status: status,
previousVersion: previousVersion,
currentVersion: currentVersion,
description: description
Expand All @@ -145,4 +177,48 @@ export default {
.then(ensureOk)
.then(response => response.data)
},
setSchemaVersionStatus(
organization, unit, context, schema, version, status) {

let config = {
headers: {
'Content-Type': 'application/json'
},
responseType: 'text'
};
return Repository.patch(
resources.versionStatus(organization, unit, context, schema, version),
status,
config
)
.then(ensureOk)
.then(response => response.data)
},
loadSources(
organization, unit, context, schema, version, language) {
let config = {
headers: {
'Content-Type': 'application/json'
},
responseType: 'text'
};
return Promise.all([
this.getOrganization(organization),
this.getUnit(organization, unit),
this.getContext(organization, unit, context),
this.getSchema(organization, unit, context, schema),
this.getVersion(organization, unit, context, schema, version),
]).then(([org, unit, context, schema, version]) => {
return Repository.get(
resources.sources(
org.name,
unit.name,
context.namespace,
schema.name,
version.currentVersion,
language), config)
})
.then(ensureOk)
.then(response => response.data)
},
}
141 changes: 124 additions & 17 deletions src/main/frontend/src/components/Properties.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<template>
<v-card height="45vh" id="schemata-properties">
<v-card-text>
<v-alert v-if="status && status !== 'Published'" :value="true" type="warning" dense outlined>
Status <b>{{status}}</b>. Do not use in production.
</v-alert>
<v-tabs>
<v-tab>Specification</v-tab>
<v-tab>Description</v-tab>

<v-tab-item>
<v-tabs>
<v-tab>Specification</v-tab>
<v-tab>Description</v-tab>
<v-spacer></v-spacer>
<v-chip label color="warning" v-if="status && status !== 'Published'" class="mt-3 mr-3">
Status&nbsp;<b>{{status}}</b>. Do not use in production.
</v-chip>


<v-tab-item>
<v-card-text>
<editor
id="specification-editor"
v-model="currentSpecification"
Expand All @@ -17,37 +20,84 @@
height="200"
:options="editorOptions"
></editor>
<br>
</v-card-text>
<v-card-actions>
<v-btn outlined color="primary" @click="publish"
:disabled="status !== 'Draft'">
<v-icon>{{icons.publish}}</v-icon>
Publish
</v-btn>
<v-btn outlined color="warning" @click="deprecate"
:disabled="status !== 'Published' && status !== 'Draft'">
<v-icon>{{icons.deprecate}}</v-icon>
Deprecate
</v-btn>
<v-btn outlined color="error" @click="remove"
:disabled="status !== 'Deprecated' && status !== 'Draft'">
<v-icon>{{icons.delete}}</v-icon>
Remove
</v-btn>
<v-spacer></v-spacer>
<v-btn outlined color="info"
:disabled="!version"
@click="loadSources">
<v-icon>{{icons.source}}</v-icon>
Source
</v-btn>
<v-btn color="info"
:disabled="status !== 'Draft'"
@click="saveSpecification">Save
</v-btn>
</v-tab-item>
</v-card-actions>
<v-dialog v-model="sourceDialog">
<v-card>
<editor
id="source-editor"
v-model="sources.java"
theme="vs-dark"
language="java"
height="400"
:options="{ readOnly: true, automaticLayout: true }"
></editor>
</v-card>
</v-dialog>
</v-tab-item>

<v-tab-item>
<v-tab-item>
<v-card-text>
<div v-html="compiledDescription()"></div>
</v-tab-item>
</v-tabs>
</v-card-text>
</v-card>
</v-card-text>
</v-tab-item>
</v-tabs>

</v-card>

</template>

<script>
import {mapFields} from 'vuex-map-fields';
import {mdiDelete, mdiLabel, mdiLabelOff, mdiSourcePull} from '@mdi/js'
import marked from 'marked'
import editor from 'monaco-editor-vue';
import Repository from '@/api/SchemataRepository'
import editor from 'monaco-editor-vue';

export default {
components: {editor},
data: function () {
return {
currentSpecification: undefined,
icons: {
publish: mdiLabel,
delete: mdiDelete,
deprecate: mdiLabelOff,
source: mdiSourcePull
},
sourceDialog: false,
sources: {
java: undefined,
}
}
},

computed: {
...mapFields([
'schema',
Expand Down Expand Up @@ -80,6 +130,41 @@
compiledDescription: function () {
return marked(this.description)
},

publish() {
this._setStatus('Published')
},
deprecate() {
this._setStatus('Deprecated')
},
remove() {
this._setStatus('Removed')
},

_setStatus(status) {
let vm = this
Repository.setSchemaVersionStatus(
this.version.organizationId,
this.version.unitId,
this.version.contextId,
this.version.schemaId,
this.version.schemaVersionId,
status)
.then(response => vm.$store.dispatch('selectSchemaVersion', response))
.then(() => vm.$store.dispatch('loadVersions'))
.then(() => {
vm.$store.commit('raiseNotification', {
message: `Status for ${vm.schema.name} updated.`,
type: 'success'
})
}
)
.catch(function (err) {
let response = err.response ? err.response.data + ' - ' : ''
vm.$store.commit('raiseError', {message: response + err})
})
},

saveSpecification: function () {
let vm = this
Repository.saveSchemaVersionSpecification(
Expand All @@ -90,6 +175,8 @@
this.version.schemaVersionId,
this.currentSpecification
)
.then(response => vm.$store.dispatch('selectSchemaVersion', response))
.then(() => vm.$store.dispatch('loadVersions'))
.then(() => {
vm.$store.commit('raiseNotification', {
message: `Specification for ${vm.schema.name} v${vm.version.currentVersion} updated.`,
Expand All @@ -101,10 +188,30 @@
let response = err.response ? err.response.data + ' - ' : ''
vm.$store.commit('raiseError', {message: response + err})
})
},
loadSources() {
let vm = this
Repository.loadSources(
this.version.organizationId,
this.version.unitId,
this.version.contextId,
this.version.schemaId,
this.version.schemaVersionId,
"java"
)
.then(response => {
vm.sources.java = response
vm.sourceDialog = true
})
.catch(function (err) {
let response = err.response ? err.response.data + ' - ' : ''
vm.$store.commit('raiseError', {message: response + err})
})
}
}
}
</script>

<style>

</style>
Loading