From 3b9ef222b768f5ce0a89e35acb39dfd924110f2e Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Mon, 28 Oct 2019 22:58:42 +0100 Subject: [PATCH 01/21] Add lifecycle buttons --- src/main/frontend/package-lock.json | 6 +++--- src/main/frontend/package.json | 2 +- src/main/frontend/src/components/Properties.vue | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/frontend/package-lock.json b/src/main/frontend/package-lock.json index fa834d75..2ea75d7e 100644 --- a/src/main/frontend/package-lock.json +++ b/src/main/frontend/package-lock.json @@ -951,9 +951,9 @@ } }, "@mdi/js": { - "version": "4.4.95", - "resolved": "https://registry.npmjs.org/@mdi/js/-/js-4.4.95.tgz", - "integrity": "sha512-wCrur/ICoHP7/NcNboBCdqR64gQnoUKxSRla4uOsGC61jMUnUeDMNfU7PrA/I0IzvotWc0ws2cCNVL7JsOPh2Q==", + "version": "4.5.95", + "resolved": "https://registry.npmjs.org/@mdi/js/-/js-4.5.95.tgz", + "integrity": "sha512-zQ6LqK/B61/ASwoR26AauCLfNc6u/SyTwsnWF0WLcSIh+oe+A7rQbioYT3eSsQch1gC+1Ejk8YDfD7gDk0FUXg==", "dev": true }, "@mrmlnc/readdir-enhanced": { diff --git a/src/main/frontend/package.json b/src/main/frontend/package.json index f5e59c0b..4d6b573f 100644 --- a/src/main/frontend/package.json +++ b/src/main/frontend/package.json @@ -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", diff --git a/src/main/frontend/src/components/Properties.vue b/src/main/frontend/src/components/Properties.vue index dab6bc6a..9db5ab83 100644 --- a/src/main/frontend/src/components/Properties.vue +++ b/src/main/frontend/src/components/Properties.vue @@ -17,7 +17,11 @@ - + + {{icons.publish}}Publish + {{icons.deprecate}}Deprecate + {{icons.delete}}Remove + @@ -25,9 +29,19 @@ From ea8d217aea37e8b029159fbfd23aceb1e051f4ad Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Wed, 30 Oct 2019 09:58:38 +0100 Subject: [PATCH 11/21] Make selected schema version and version list reactive to display changes right away --- src/main/frontend/src/components/Properties.vue | 5 +++-- src/main/frontend/src/components/SchemaVersion.vue | 1 + src/main/frontend/src/store.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/frontend/src/components/Properties.vue b/src/main/frontend/src/components/Properties.vue index c7e7e5fe..cac7e5e9 100644 --- a/src/main/frontend/src/components/Properties.vue +++ b/src/main/frontend/src/components/Properties.vue @@ -127,7 +127,8 @@ this.version.schemaId, this.version.schemaVersionId, status) - .then(response => vm.$store.dispatch('selectSchemaVersion', response.data)) + .then(response => vm.$store.dispatch('selectSchemaVersion', response)) + .then(() => vm.$store.dispatch('loadVersions')) .then(() => { vm.$store.commit('raiseNotification', { message: `Status for ${vm.schema.name} updated.`, @@ -151,7 +152,7 @@ this.version.schemaVersionId, this.currentSpecification ) - .then(response => vm.$store.dispatch('selectSchemaVersion', response.data)) + .then(response => vm.$store.dispatch('selectSchemaVersion', response)) .then(() => { vm.$store.commit('raiseNotification', { message: `Specification for ${vm.schema.name} v${vm.version.currentVersion} updated.`, diff --git a/src/main/frontend/src/components/SchemaVersion.vue b/src/main/frontend/src/components/SchemaVersion.vue index 7462e297..3834a2cb 100644 --- a/src/main/frontend/src/components/SchemaVersion.vue +++ b/src/main/frontend/src/components/SchemaVersion.vue @@ -177,6 +177,7 @@ message: `Schema v${vm.currentVersion} created.`, type: 'success' }) + vm.$store.dispatch('loadVersions') } ) .catch(function (err) { diff --git a/src/main/frontend/src/store.js b/src/main/frontend/src/store.js index 5f61716b..d636d850 100644 --- a/src/main/frontend/src/store.js +++ b/src/main/frontend/src/store.js @@ -59,7 +59,7 @@ export default new Vuex.Store({ this.dispatch('loadVersions') }, selectSchemaVersion(context, selected) { - this.commit('updateSchemaVersion', selected) + context.commit('updateSchemaVersion', selected) }, loadVersions(context) { if (!(context.state.schema)) { From c4f83da6b0617375065d2e5317ba95a6a41cd0b9 Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Wed, 30 Oct 2019 10:12:08 +0100 Subject: [PATCH 12/21] Add E2E test for vstate transitions --- .../integration/browse-schemata.spec.ts | 89 -------- .../schema-version-maintenance.spec.ts | 199 ++++++++++++++++++ 2 files changed, 199 insertions(+), 89 deletions(-) create mode 100644 src/test/e2e/cypress/integration/schema-version-maintenance.spec.ts diff --git a/src/test/e2e/cypress/integration/browse-schemata.spec.ts b/src/test/e2e/cypress/integration/browse-schemata.spec.ts index 887f69d7..a6a5c586 100644 --- a/src/test/e2e/cypress/integration/browse-schemata.spec.ts +++ b/src/test/e2e/cypress/integration/browse-schemata.spec.ts @@ -92,93 +92,4 @@ describe('Schemata View Tests', function () { cy.contains('.v-window-item--active',desc) }); - - it('can update schema version specification', function () { - // Setup - let orgName = faker.company.companyName() - let unitName = faker.lorem.word() - let namespace = faker.internet.domainName() - let schema = faker.company.catchPhraseNoun() - let majorMinorVersion = faker.random.number(9) + '.' + faker.random.number(9) - let patchVersion = faker.random.number(9) - let prevVersion = majorMinorVersion + '.' + patchVersion - let currentVersion = majorMinorVersion + '.' + (patchVersion + 1) - let spec = 'event SalutationHappened {\n' + - ' type eventType' - let desc = faker.lorem.sentence() - - // Create Entities - cy.visit('/#/organization') - cy.fillField('Name', orgName) - cy.fillField('Description', 'foo') - cy.contains('button', 'Create').click() - cy.contains('a', 'Create Unit').click() - - cy.selectOption('Organization', orgName) - cy.fillField('Name', unitName) - cy.fillField('Description', 'foo') - cy.contains('button', 'Create').click() - cy.contains('a', 'Create Context').click() - - cy.selectOption('Organization', orgName) - cy.selectOption('Unit', unitName) - cy.fillField('Namespace', namespace) - cy.fillField('Description', 'foo') - cy.contains('button', 'Create').click() - cy.contains('a', 'Create Schema').click() - - cy.fieldContent('SchemaID').should('be.empty') - cy.selectOption('Organization', orgName) - cy.selectOption('Unit', unitName) - cy.selectOption('Context', namespace) - cy.fillField('Name', schema) - cy.selectOption('Category', faker.random.arrayElement(['Command', 'Data', 'Document', 'Envelope', 'Event', 'Unknown'])) - cy.selectOption('Scope', faker.random.arrayElement(['Public', 'Private'])) - cy.fillField('Description', faker.lorem.sentence()) - cy.contains('button', 'Create').click() - cy.contains('a', 'Create Schema Version').click() - - cy.fieldContent('SchemaVersionID').should('be.empty') - cy.selectOption('Organization', orgName) - cy.selectOption('Unit', unitName) - cy.selectOption('Context', namespace) - cy.selectOption('Schema', schema) - cy.fillField('Previous Version', prevVersion) - cy.fillField('Current Version', currentVersion) - cy.selectOption('Status', 'Draft') - cy.fillEditor('#description-editor', desc) - cy.fillEditor('#specification-editor', spec) - cy.contains('button', 'Create').click() - - // Assert visibility in treeview - // Filter for Org - cy.visit("/#/schemata") - .fillField('Search', orgName) - - // Expand Tree - cy.contains('.v-treeview-node__label', orgName).click() - cy.contains('.v-treeview-node__label', unitName).click() - cy.contains('.v-treeview-node__label', namespace).click() - cy.contains('.v-treeview-node__label', schema).click() - - // Select version - cy.contains('.v-list-item__title', currentVersion).click() - - // Change spec - cy.fillEditor('#specification-editor', 'foo bar baz') - cy.contains('button', 'Save').click() - - // Reload and navigate to schema version - cy.reload() - cy.visit("/#/schemata") - .fillField('Search', orgName) - cy.contains('.v-treeview-node__label', orgName).click() - cy.contains('.v-treeview-node__label', unitName).click() - cy.contains('.v-treeview-node__label', namespace).click() - cy.contains('.v-treeview-node__label', schema).click() - cy.contains('.v-list-item__title', currentVersion).click() - - cy.editorContent('#specification-editor').should('contain','foo bar baz') - }); - }); \ No newline at end of file diff --git a/src/test/e2e/cypress/integration/schema-version-maintenance.spec.ts b/src/test/e2e/cypress/integration/schema-version-maintenance.spec.ts new file mode 100644 index 00000000..05001ec0 --- /dev/null +++ b/src/test/e2e/cypress/integration/schema-version-maintenance.spec.ts @@ -0,0 +1,199 @@ +import * as faker from 'faker'; + +describe('Schemata View Tests', function () { + before(() => { + }); + + after(() => { + + }); + + beforeEach(() => { + cy.viewport(1280, 960) + }); + + it('can update schema version state', function () { + // Setup + let orgName = faker.company.companyName() + let unitName = faker.lorem.word() + let namespace = faker.internet.domainName() + let schema = faker.company.catchPhraseNoun() + let majorMinorVersion = faker.random.number(9) + '.' + faker.random.number(9) + let patchVersion = faker.random.number(9) + let prevVersion = majorMinorVersion + '.' + patchVersion + let currentVersion = majorMinorVersion + '.' + (patchVersion + 1) + let spec = 'event SalutationHappened {\n' + + ' type eventType' + let desc = faker.lorem.sentence() + + // Create Entities + cy.visit('/#/organization') + cy.fillField('Name', orgName) + cy.fillField('Description', 'foo') + cy.contains('button', 'Create').click() + cy.contains('a', 'Create Unit').click() + + cy.selectOption('Organization', orgName) + cy.fillField('Name', unitName) + cy.fillField('Description', 'foo') + cy.contains('button', 'Create').click() + cy.contains('a', 'Create Context').click() + + cy.selectOption('Organization', orgName) + cy.selectOption('Unit', unitName) + cy.fillField('Namespace', namespace) + cy.fillField('Description', 'foo') + cy.contains('button', 'Create').click() + cy.contains('a', 'Create Schema').click() + + cy.fieldContent('SchemaID').should('be.empty') + cy.selectOption('Organization', orgName) + cy.selectOption('Unit', unitName) + cy.selectOption('Context', namespace) + cy.fillField('Name', schema) + cy.selectOption('Category', faker.random.arrayElement(['Command', 'Data', 'Document', 'Envelope', 'Event', 'Unknown'])) + cy.selectOption('Scope', faker.random.arrayElement(['Public', 'Private'])) + cy.fillField('Description', faker.lorem.sentence()) + cy.contains('button', 'Create').click() + cy.contains('a', 'Create Schema Version').click() + + cy.fieldContent('SchemaVersionID').should('be.empty') + cy.selectOption('Organization', orgName) + cy.selectOption('Unit', unitName) + cy.selectOption('Context', namespace) + cy.selectOption('Schema', schema) + cy.fillField('Previous Version', prevVersion) + cy.fillField('Current Version', currentVersion) + cy.fillEditor('#description-editor', desc) + cy.fillEditor('#specification-editor', spec) + cy.contains('button', 'Create').click() + + // Assert visibility in treeview + // Filter for Org + cy.visit("/#/schemata") + .fillField('Search', orgName) + + // Expand Tree + cy.contains('.v-treeview-node__label', orgName).click() + cy.contains('.v-treeview-node__label', unitName).click() + cy.contains('.v-treeview-node__label', namespace).click() + cy.contains('.v-treeview-node__label', schema).click() + + // Select version + cy.contains('.v-list-item__title', currentVersion).click() + + // Assert all states reachable + cy.contains('button', 'Publish').should('be.enabled') + cy.contains('button', 'Deprecate').should('be.enabled') + cy.contains('button', 'Remove').should('be.enabled') + cy.get('.v-chip.warning') + + //Publish + cy.contains('button', 'Publish').click() + cy.contains('button', 'Publish').should('be.disabled') + cy.contains('button', 'Deprecate').should('be.enabled') + cy.contains('button', 'Remove').should('be.disabled') + + //Deprecate + cy.contains('button', 'Deprecate').click() + cy.contains('button', 'Publish').should('be.disabled') + cy.contains('button', 'Deprecate').should('be.disabled') + cy.contains('button', 'Remove').should('be.enabled') + cy.get('.v-chip.warning') + + //Remove + cy.contains('button', 'Remove').click() + cy.contains('button', 'Publish').should('be.disabled') + cy.contains('button', 'Deprecate').should('be.disabled') + cy.contains('button', 'Remove').should('be.disabled') + cy.get('.v-chip.warning') + + }); + + it('can update schema version specification', function () { + // Setup + let orgName = faker.company.companyName() + let unitName = faker.lorem.word() + let namespace = faker.internet.domainName() + let schema = faker.company.catchPhraseNoun() + let majorMinorVersion = faker.random.number(9) + '.' + faker.random.number(9) + let patchVersion = faker.random.number(9) + let prevVersion = majorMinorVersion + '.' + patchVersion + let currentVersion = majorMinorVersion + '.' + (patchVersion + 1) + let spec = 'event SalutationHappened {\n' + + ' type eventType' + let desc = faker.lorem.sentence() + + // Create Entities + cy.visit('/#/organization') + cy.fillField('Name', orgName) + cy.fillField('Description', 'foo') + cy.contains('button', 'Create').click() + cy.contains('a', 'Create Unit').click() + + cy.selectOption('Organization', orgName) + cy.fillField('Name', unitName) + cy.fillField('Description', 'foo') + cy.contains('button', 'Create').click() + cy.contains('a', 'Create Context').click() + + cy.selectOption('Organization', orgName) + cy.selectOption('Unit', unitName) + cy.fillField('Namespace', namespace) + cy.fillField('Description', 'foo') + cy.contains('button', 'Create').click() + cy.contains('a', 'Create Schema').click() + + cy.fieldContent('SchemaID').should('be.empty') + cy.selectOption('Organization', orgName) + cy.selectOption('Unit', unitName) + cy.selectOption('Context', namespace) + cy.fillField('Name', schema) + cy.selectOption('Category', faker.random.arrayElement(['Command', 'Data', 'Document', 'Envelope', 'Event', 'Unknown'])) + cy.selectOption('Scope', faker.random.arrayElement(['Public', 'Private'])) + cy.fillField('Description', faker.lorem.sentence()) + cy.contains('button', 'Create').click() + cy.contains('a', 'Create Schema Version').click() + + cy.fieldContent('SchemaVersionID').should('be.empty') + cy.selectOption('Organization', orgName) + cy.selectOption('Unit', unitName) + cy.selectOption('Context', namespace) + cy.selectOption('Schema', schema) + cy.fillField('Previous Version', prevVersion) + cy.fillField('Current Version', currentVersion) + cy.fillEditor('#description-editor', desc) + cy.fillEditor('#specification-editor', spec) + cy.contains('button', 'Create').click() + + // Assert visibility in treeview + // Filter for Org + cy.visit("/#/schemata") + .fillField('Search', orgName) + + // Expand Tree + cy.contains('.v-treeview-node__label', orgName).click() + cy.contains('.v-treeview-node__label', unitName).click() + cy.contains('.v-treeview-node__label', namespace).click() + cy.contains('.v-treeview-node__label', schema).click() + + // Select version + cy.contains('.v-list-item__title', currentVersion).click() + + // Change spec + cy.fillEditor('#specification-editor', 'foo bar baz') + cy.contains('button', 'Save').click() + + // Reload and navigate to schema version + cy.reload() + cy.visit("/#/schemata") + .fillField('Search', orgName) + cy.contains('.v-treeview-node__label', orgName).click() + cy.contains('.v-treeview-node__label', unitName).click() + cy.contains('.v-treeview-node__label', namespace).click() + cy.contains('.v-treeview-node__label', schema).click() + cy.contains('.v-list-item__title', currentVersion).click() + + cy.editorContent('#specification-editor').should('contain','foo bar baz') + }); +}); \ No newline at end of file From d0ba2addb8470cad576cb9386adbc923706d21a0 Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Wed, 30 Oct 2019 10:25:20 +0100 Subject: [PATCH 13/21] Add assertion for enablement of save button based on state --- .../cypress/integration/schema-version-maintenance.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/e2e/cypress/integration/schema-version-maintenance.spec.ts b/src/test/e2e/cypress/integration/schema-version-maintenance.spec.ts index 05001ec0..2eb44928 100644 --- a/src/test/e2e/cypress/integration/schema-version-maintenance.spec.ts +++ b/src/test/e2e/cypress/integration/schema-version-maintenance.spec.ts @@ -87,12 +87,14 @@ describe('Schemata View Tests', function () { cy.contains('button', 'Deprecate').should('be.enabled') cy.contains('button', 'Remove').should('be.enabled') cy.get('.v-chip.warning') + cy.contains('button', 'Save').should('be.enabled') //Publish cy.contains('button', 'Publish').click() cy.contains('button', 'Publish').should('be.disabled') cy.contains('button', 'Deprecate').should('be.enabled') cy.contains('button', 'Remove').should('be.disabled') + cy.contains('button', 'Save').should('be.disabled') //Deprecate cy.contains('button', 'Deprecate').click() @@ -100,6 +102,7 @@ describe('Schemata View Tests', function () { cy.contains('button', 'Deprecate').should('be.disabled') cy.contains('button', 'Remove').should('be.enabled') cy.get('.v-chip.warning') + cy.contains('button', 'Save').should('be.disabled') //Remove cy.contains('button', 'Remove').click() @@ -107,7 +110,7 @@ describe('Schemata View Tests', function () { cy.contains('button', 'Deprecate').should('be.disabled') cy.contains('button', 'Remove').should('be.disabled') cy.get('.v-chip.warning') - + cy.contains('button', 'Save').should('be.disabled') }); it('can update schema version specification', function () { From a86401007a2aa73c24ba72c1270038fc32005d29 Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Wed, 30 Oct 2019 10:28:39 +0100 Subject: [PATCH 14/21] Refresh versions after updating selected version --- src/main/frontend/src/components/Properties.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/frontend/src/components/Properties.vue b/src/main/frontend/src/components/Properties.vue index cac7e5e9..e3f5efc8 100644 --- a/src/main/frontend/src/components/Properties.vue +++ b/src/main/frontend/src/components/Properties.vue @@ -153,6 +153,7 @@ 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.`, From 36e42aa137f16e46d7c23f91ca0a48e7db25c45c Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Wed, 30 Oct 2019 10:42:34 +0100 Subject: [PATCH 15/21] Merge SchemaRepo --- .../frontend/src/api/SchemataRepository.js | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/src/api/SchemataRepository.js b/src/main/frontend/src/api/SchemataRepository.js index 57c9c0d4..6b60ebf9 100644 --- a/src/main/frontend/src/api/SchemataRepository.js +++ b/src/main/frontend/src/api/SchemataRepository.js @@ -9,7 +9,9 @@ const resources = { 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` + versionStatus: (o, u, c, s, v) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions/${v}/status`, + schemaSpecification: (o, u, c, s, v) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions/${v}/specification`, + sources: (o, u, c, s, v, lang) => `/code/${o}:${u}:${c}:${s}:${v}/${lang}`, } function ensure(response, status) { @@ -145,4 +147,38 @@ 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) + }, + + loadSourceJava( + organization, unit, context, schema, version, language) { + + let config = { + headers: { + 'Content-Type': 'application/json' + }, + responseType: 'text' + }; + return Repository.get( + resources.sources(organization, unit, context, schema, "java"), + ) + .then(ensureOk) + .then(response => response.data) + }, } \ No newline at end of file From b7c724ac43e3e5a6772c9e4c05041fd7ab46829a Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Wed, 30 Oct 2019 11:33:18 +0100 Subject: [PATCH 16/21] Add query methods for entities --- .../frontend/src/api/SchemataRepository.js | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/src/api/SchemataRepository.js b/src/main/frontend/src/api/SchemataRepository.js index 99e40925..ba27ae7c 100644 --- a/src/main/frontend/src/api/SchemataRepository.js +++ b/src/main/frontend/src/api/SchemataRepository.js @@ -3,12 +3,17 @@ import Repository from '@/api/Repository' const resources = { organizations: () => '/organizations', + organization: (o) => `/organizations/${o}/units`, units: (o) => `/organizations/${o}/units`, + unit: (o, u) => `/organizations/${o}/units/${u}`, contexts: (o, u) => `/organizations/${o}/units/${u}/contexts`, + context: (o, u, c) => `/organizations/${o}/units/${u}/contexts/${c}`, categories: () => '/schema/categories', scopes: () => '/schema/scopes', schemata: (o, u, c) => `/organizations/${o}/units/${u}/contexts/${c}/schemas`, + schema: (o, u, c, s) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}`, versions: (o, u, c, s) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions`, + version: (o, u, c, s, v) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions/${v}`, versionStatus: (o, u, c, s, v) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions/${v}/status`, schemaSpecification: (o, u, c, s, v) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions/${v}/specification`, sources: (o, u, c, s, v, lang) => `/code/${o}:${u}:${c}:${s}:${v}/${lang}`, @@ -35,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) @@ -62,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(), @@ -172,7 +203,7 @@ export default { responseType: 'text' }; return Repository.get( - resources.sources(organization, unit, context, schema, "java"), + resources.sources(organization, unit, context, schema, version, "java"), ) .then(ensureOk) .then(response => response.data) From bb09110a415b2e9b065de8b1b1be3c2502a9e6f5 Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Wed, 30 Oct 2019 11:46:45 +0100 Subject: [PATCH 17/21] Factor out duplicated resource URLs --- .../frontend/src/api/SchemataRepository.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/frontend/src/api/SchemataRepository.js b/src/main/frontend/src/api/SchemataRepository.js index ba27ae7c..06fa4cc2 100644 --- a/src/main/frontend/src/api/SchemataRepository.js +++ b/src/main/frontend/src/api/SchemataRepository.js @@ -3,19 +3,19 @@ import Repository from '@/api/Repository' const resources = { organizations: () => '/organizations', - organization: (o) => `/organizations/${o}/units`, - units: (o) => `/organizations/${o}/units`, - unit: (o, u) => `/organizations/${o}/units/${u}`, - contexts: (o, u) => `/organizations/${o}/units/${u}/contexts`, - context: (o, u, c) => `/organizations/${o}/units/${u}/contexts/${c}`, + 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`, - schema: (o, u, c, s) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}`, - versions: (o, u, c, s) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions`, - version: (o, u, c, s, v) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions/${v}`, - versionStatus: (o, u, c, s, v) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions/${v}/status`, - 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}`, } @@ -194,7 +194,7 @@ export default { .then(ensureOk) .then(response => response.data) }, - loadSourceJava( + loadSource( organization, unit, context, schema, version, language) { let config = { headers: { @@ -203,7 +203,7 @@ export default { responseType: 'text' }; return Repository.get( - resources.sources(organization, unit, context, schema, version, "java"), + resources.sources(organization, unit, context, schema, version, language), ) .then(ensureOk) .then(response => response.data) From 1d4fb0e31fa1d841d8d9e6813ca2ac2941b6c331 Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Wed, 30 Oct 2019 12:14:09 +0100 Subject: [PATCH 18/21] Disable source button if no version is selected --- .../frontend/src/components/Properties.vue | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/frontend/src/components/Properties.vue b/src/main/frontend/src/components/Properties.vue index e3f5efc8..6dfa47af 100644 --- a/src/main/frontend/src/components/Properties.vue +++ b/src/main/frontend/src/components/Properties.vue @@ -42,6 +42,12 @@ :disabled="status !== 'Draft'" @click="saveSpecification">Save + + {{icons.source}} + Source + @@ -58,7 +64,7 @@