Skip to content

Commit

Permalink
Release Workbase 1.2.10 (#297)
Browse files Browse the repository at this point in the history
## What is the goal of this PR?
Prepares Workbase for the 1.2.10 release.

## What are the changes implemented in this PR?
  • Loading branch information
Soroush Saffari authored Jun 12, 2020
1 parent 7436abc commit 71cdc36
Show file tree
Hide file tree
Showing 21 changed files with 155 additions and 63 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.9
1.2.10
4 changes: 2 additions & 2 deletions dependencies/graknlabs/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def graknlabs_grakn_core():
git_repository(
name = "graknlabs_grakn_core",
remote = "https://github.com/graknlabs/grakn",
commit = "ababa285be4d0d71a537d77d1990c4291da7c16e", # sync-marker: do not remove this comment, this is used for sync-dependencies by @graknlabs_grakn_core
tag = "1.7.2", # sync-marker: do not remove this comment, this is used for sync-dependencies by @graknlabs_grakn_core
)

def graknlabs_client_nodejs():
git_repository(
name = "graknlabs_client_nodejs",
remote = "https://github.com/graknlabs/client-nodejs",
commit = "b85668f7063b2313ed02ab35cd0922e67d1f9f4b", # sync-marker: do not remove this comment, this is used for sync-dependencies by @graknlabs_client_nodejs
tag = "1.7.0", # sync-marker: do not remove this comment, this is used for sync-dependencies by @graknlabs_client_nodejs
)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@blueprintjs/table": "^3.1.1",
"codemirror": "^5.38.0",
"electron-store": "^1.3.0",
"grakn-client": "https://repo.grakn.ai/repository/npm-snapshot-group/grakn-client/-/grakn-client-0.0.0-b85668f7063b2313ed02ab35cd0922e67d1f9f4b.tgz",
"grakn-client": "1.7.0",
"grpc": "^1.18.0",
"hex-to-hsl": "^1.0.2",
"image-data-uri": "^1.1.1",
Expand Down Expand Up @@ -165,5 +165,5 @@
"prebuild": "node version.js",
"unit": "node ./node_modules/jest/bin/jest.js ./test/unit"
},
"version": "1.2.9"
"version": "1.2.10"
}
22 changes: 11 additions & 11 deletions src/renderer/components/SchemaDesign/LeftBar/NewAttributePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
<div class="row">
<div class="data-type-options">
<div class="list-label">data type</div>
<div v-if="superType === 'attribute'" class="btn data-type-btn" :class="(showDataTypeList) ? 'type-list-shown' : ''" @click="toggleDataList"><div class="type-btn-text" >{{valueType}}</div><div class="type-btn-caret"><vue-icon className="vue-icon" icon="caret-down"></vue-icon></div></div>
<div v-else class="inherited-data-type">{{valueType}}</div>
<div v-if="superType === 'attribute'" class="btn data-type-btn" :class="(showDataTypeList) ? 'type-list-shown' : ''" @click="toggleDataList"><div class="type-btn-text" >{{dataType}}</div><div class="type-btn-caret"><vue-icon className="vue-icon" icon="caret-down"></vue-icon></div></div>
<div v-else class="inherited-data-type">{{dataType}}</div>

<div class="data-type-list" v-show="showDataTypeList">
<ul v-for="type in valueTypes" :key=type>
<li class="type-item" @click="selectDataType(type)" :class="[(type === valueType) ? 'type-item-selected' : '']">{{type}}</li>
<ul v-for="type in dataTypes" :key=type>
<li class="type-item" @click="selectDataType(type)" :class="[(type === dataType) ? 'type-item-selected' : '']">{{type}}</li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -371,8 +371,8 @@
superTypes: [],
superType: undefined,
showDataTypeList: false,
valueTypes: ['string', 'long', 'double', 'boolean', 'datetime'],
valueType: undefined,
dataTypes: ['string', 'long', 'double', 'boolean', 'date'],
dataType: undefined,
showSpinner: false,
toggledAttributeTypes: [],
toggledRoleTypes: [],
Expand Down Expand Up @@ -411,15 +411,15 @@
if (val !== 'attribute') { // if super type is not 'attribute' set data type of super type
const graknTx = await this[OPEN_GRAKN_TX]();
const attributeType = await graknTx.getSchemaConcept(val);
this.valueType = (await attributeType.valueType()).toLowerCase();
this.dataType = (await attributeType.dataType()).toLowerCase();
this.showDataTypeList = false;
const sup = await graknTx.getSchemaConcept(val);
this.supAttributes = await Promise.all((await (await sup.attributes()).collect()).map(async x => x.label()));
this.hasAttributes = this.hasAttributes.filter(x => !this.supAttributes.includes(x));
graknTx.close();
} else {
this.valueType = this.valueTypes[0];
this.dataType = this.dataTypes[0];
this.hasAttributes = this.metaTypeInstances.attributes;
this.supAttributes = [];
Expand All @@ -433,7 +433,7 @@
} else {
this.showSpinner = true;
this[DEFINE_ATTRIBUTE_TYPE]({
attributeLabel: this.attributeLabel, superType: this.superType, valueType: this.valueType, attributeTypes: this.toggledAttributeTypes, roleTypes: this.toggledRoleTypes,
attributeLabel: this.attributeLabel, superType: this.superType, dataType: this.dataType, attributeTypes: this.toggledAttributeTypes, roleTypes: this.toggledRoleTypes,
})
.then(() => {
this.showSpinner = false;
Expand All @@ -452,7 +452,7 @@
this.showAttributeTypeList = false;
},
selectDataType(type) {
this.valueType = type;
this.dataType = type;
this.showDataTypeList = false;
},
resetPanel() {
Expand All @@ -461,7 +461,7 @@
this.showDataTypeList = false;
this.superTypes = ['attribute', ...this.metaTypeInstances.attributes];
this.superType = this.superTypes[0];
this.valueType = this.valueTypes[0];
this.dataType = this.dataTypes[0];
this.toggledAttributeTypes = [];
this.toggledRoleTypes = [];
this.showHasPanel = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div v-for="(value, index) in attributes" :key="index">
<div class="content-item">
<div class="label">{{value.type}}: {{value.valueType}}</div>
<div class="label">{{value.type}}: {{value.dataType}}</div>
<div class="btn right-bar-btn reset-setting-btn" @click="removeAttributeType(value.type, index)"><vue-icon icon="trash" className="vue-icon" iconSize="12"></vue-icon></div>
</div>
</div>
Expand Down
22 changes: 11 additions & 11 deletions src/renderer/components/SchemaDesign/SchemaHandler.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { valueType } from 'grakn-client';
import { dataType } from 'grakn-client';

let tx;

function SchemaHandler(graknTx) {
tx = graknTx;
}

function toGraknDatatype(valueTypeParam) {
switch (valueTypeParam) {
case 'string': return valueType.STRING;
case 'datetime': return valueType.DATETIME;
case 'boolean': return valueType.BOOLEAN;
case 'long': return valueType.LONG;
case 'double': return valueType.DOUBLE;
default: throw new Error(`Datatype not recognised. Received [${valueTypeParam}]`);
function toGraknDatatype(dataTypeParam) {
switch (dataTypeParam) {
case 'string': return dataType.STRING;
case 'date': return dataType.DATETIME;
case 'boolean': return dataType.BOOLEAN;
case 'long': return dataType.LONG;
case 'double': return dataType.DOUBLE;
default: throw new Error(`Datatype not recognised. Received [${dataTypeParam}]`);
}
}

Expand All @@ -37,8 +37,8 @@ SchemaHandler.prototype.defineRelationType = async function define({ relationLab
return type;
};

SchemaHandler.prototype.defineAttributeType = async function define({ attributeLabel, superType, valueType }) {
const type = await tx.putAttributeType(attributeLabel, toGraknDatatype(valueType));
SchemaHandler.prototype.defineAttributeType = async function define({ attributeLabel, superType, dataType }) {
const type = await tx.putAttributeType(attributeLabel, toGraknDatatype(dataType));
const directSuper = await tx.getSchemaConcept(superType);
await type.sup(directSuper);
};
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/SchemaDesign/SchemaUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export async function loadMetaTypeInstances(graknTx) {
.then(labels => labels.filter(l => l !== 'entity')
.concat()
.sort());
metaTypeInstances.relations = await Promise.all(rels.map(async type => type.label()))
metaTypeInstances.relations = await Promise.all(rels.map(async type => ((!await type.isImplicit()) ? type.label() : null)))
.then(labels => labels.filter(l => l && l !== 'relation')
.concat()
.sort());
metaTypeInstances.attributes = await Promise.all(attributes.map(type => type.label()))
.then(labels => labels.filter(l => l !== 'attribute')
.concat()
.sort());
metaTypeInstances.roles = await Promise.all(roles.map(async type => type.label()))
metaTypeInstances.roles = await Promise.all(roles.map(async type => ((!await type.isImplicit()) ? type.label() : null)))
.then(labels => labels.filter(l => l && l !== 'role')
.concat()
.sort());
Expand All @@ -47,7 +47,7 @@ export async function computeAttributes(nodes, graknTx) {
return Promise.all(nodes.map(async (node) => {
const concept = await graknTx.getSchemaConcept(node.label);
const attributes = await (await concept.attributes()).collect();
node.attributes = await Promise.all(attributes.map(async concept => ({ type: await concept.label(), valueType: await concept.valueType() })));
node.attributes = await Promise.all(attributes.map(async concept => ({ type: await concept.label(), dataType: await concept.dataType() })));
return node;
}));
}
Expand All @@ -57,7 +57,7 @@ export async function computeRoles(nodes, graknTx) {
return Promise.all(nodes.map(async (node) => {
const concept = await graknTx.getSchemaConcept(node.label);
const roles = await (await concept.playing()).collect();
node.roles = await Promise.all(roles.map(concept => concept.label())).then(nodes => nodes.filter(x => x));
node.roles = await Promise.all(roles.map(async concept => ((await concept.isImplicit()) ? null : concept.label()))).then(nodes => nodes.filter(x => x));
return node;
}));
}
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/components/SchemaDesign/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import CDB from '../../shared/CanvasDataBuilder';
import { META_LABELS } from '../../shared/SharedUtils';

export default {
async [OPEN_GRAKN_TX]({ state, commit }) {
const graknTx = await state.graknSession.transaction().write();
async [OPEN_GRAKN_TX]({ commit }) {
const graknTx = await global.graknSession.transaction().write();
if (!global.graknTx) global.graknTx = {};
global.graknTx.schemaDesign = graknTx;
commit('setSchemaHandler', new SchemaHandler(graknTx));
Expand All @@ -43,7 +43,8 @@ export default {
if (keyspace !== state.currentKeyspace) {
dispatch(CANVAS_RESET);
commit('currentKeyspace', keyspace);
await commit('graknSession', await global.grakn.session(keyspace));
if (global.graknSession) await global.graknSession.close();
global.graknSession = await global.grakn.session(keyspace);
dispatch(UPDATE_METATYPE_INSTANCES);
dispatch(LOAD_SCHEMA);
}
Expand Down
3 changes: 0 additions & 3 deletions src/renderer/components/SchemaDesign/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ export default {
loadingSchema(state, isRunning) {
state.loadingSchema = isRunning;
},
graknSession(state, session) {
state.graknSession = session;
},
setVisFacade(state, facade) {
state.visFacade = Object.freeze(facade); // Freeze it so that Vue does not attach watchers to its properties
},
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/SchemaDesign/store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default {
currentKeyspace: null,
selectedNodes: null,
loadingSchema: false,
graknSession: undefined,
canvasData: { entities: 0, attributes: 0, relations: 0 },
contextMenu: { show: false, x: null, y: null },
schemaHandler: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CodeMirror.defineSimpleMode('graql', {
start: [
{ regex: /#.*/, token: 'comment' },
{ regex: /".*?"/, token: 'string' },
{ regex: /(match|isa|isa!|sub|sub!|has|id|type|limit|offset|sort|asc|desc|get|compute|path|from|to)(?![-a-zA-Z_0-9])/, // eslint-disable-line max-len
{ regex: /(match|insert|delete|select|isa|sub|plays|relates|datatype|abstract|has|value|id|of|limit|offset|order|by|compute|from|to|in|aggregate|label|get|using|where)(?![-a-zA-Z_0-9])/, // eslint-disable-line max-len
token: 'keyword' },
{ regex: /true|false/, token: 'number' },
{ regex: /\$[-a-zA-Z_0-9]+/, token: 'variable' },
Expand Down
31 changes: 29 additions & 2 deletions src/renderer/components/Visualiser/VisualiserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ export async function loadMetaTypeInstances(graknTx) {
.then(labels => labels.filter(l => l !== 'entity')
.concat()
.sort());
metaTypeInstances.relations = await Promise.all(rels.map(type => type.label()))
metaTypeInstances.relations = await Promise.all(rels.map(async type => ((!await type.isImplicit()) ? type.label() : null)))
.then(labels => labels.filter(l => l && l !== 'relation')
.concat()
.sort());
metaTypeInstances.attributes = await Promise.all(attributes.map(type => type.label()))
.then(labels => labels.filter(l => l !== 'attribute')
.concat()
.sort());
metaTypeInstances.roles = await Promise.all(roles.map(type => type.label()))
metaTypeInstances.roles = await Promise.all(roles.map(async type => ((!await type.isImplicit()) ? type.label() : null)))
.then(labels => labels.filter(l => l && l !== 'role')
.concat()
.sort());
Expand Down Expand Up @@ -128,6 +128,27 @@ export function addResetGraphListener(dispatch, action) {
});
}

/**
* Checks if a ConceptMap inside the provided Answer contains at least one implicit concept
* @param {Object} answer ConceptMap Answer to be inspected
* @return {Boolean}
*/
async function answerContainsImplicitType(answer) {
const concepts = Array.from(answer.map().values());
return Promise.all(concepts.map(async concept => ((concept.isThing()) ? (await concept.type()).isImplicit() : concept.isImplicit())))
.then(a => a.includes(true));
}

/**
* Filters out Answers that contained inferred concepts in their ConceptMap
* @param {Object[]} answers array of ConceptMap Answers to be inspected
* @return {Object[]} filtered array of Answers
*/
export async function filterMaps(answers) { // Filter out ConceptMaps that contain implicit relations
return Promise.all(answers.map(async x => ((await answerContainsImplicitType(x)) ? null : x)))
.then(maps => maps.filter(map => map));
}

/**
* Executes query to load neighbours of given node and filters our all the answers that contain implicit concepts, given that we
* don't want to show implicit concepts (relations to attributes) to the user, for now.
Expand All @@ -138,5 +159,11 @@ export function addResetGraphListener(dispatch, action) {
export async function getFilteredNeighbourAnswers(node, graknTx, limit) {
const query = getNeighboursQuery(node, limit);
const resultAnswers = await (await graknTx.query(query)).collect();
const filteredResult = await filterMaps(resultAnswers);
if (resultAnswers.length !== filteredResult.length) {
const offsetDiff = resultAnswers.length - filteredResult.length;
node.offset += QuerySettings.getNeighboursLimit();
return filteredResult.concat(await getFilteredNeighbourAnswers(node, graknTx, offsetDiff));
}
return resultAnswers;
}
15 changes: 11 additions & 4 deletions src/renderer/components/shared/CanvasDataBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ const getConceptLabel = (concept) => {
return label;
};

const shouldVisualiseInstance = (instance) => {
let shouldSkip = false;
if (instance.type().isImplicit()) shouldSkip = true;
return !shouldSkip;
};

const shouldVisualiseType = (type) => {
let shouldSkip = false;
if (META_LABELS.has(getConceptLabel(type))) shouldSkip = true;
if (type.isImplicit()) shouldSkip = true;
else if (META_LABELS.has(getConceptLabel(type))) shouldSkip = true;
return !shouldSkip;
};

Expand Down Expand Up @@ -253,7 +260,7 @@ const buildInstances = async (answers) => {
}));
}).reduce(collect, []);

const shouldVisualiseVals = data.map(item => item.concept.isThing());
const shouldVisualiseVals = data.map(item => item.concept.isThing() && shouldVisualiseInstance(item.concept));
data = data.map((item, index) => {
item.shouldVisualise = shouldVisualiseVals[index];
return item;
Expand Down Expand Up @@ -496,7 +503,7 @@ const buildNeighbours = async (targetConcept, answers) => {
}));
}).reduce(collect, []);

const shouldVisualiseVals = data.map(item => item.concept.isThing());
const shouldVisualiseVals = data.map(item => item.concept.isThing() && shouldVisualiseInstance(item.concept));

data = data.map((item, index) => {
item.shouldVisualise = shouldVisualiseVals[index];
Expand Down Expand Up @@ -543,7 +550,7 @@ const buildRPInstances = async (answers, currentData, shouldLimit, graknTx) => {

answers.forEach((answer) => {
Array.from(answer.map().entries()).forEach(([graqlVar, concept]) => {
if (concept.isRelation()) {
if (concept.isRelation() && shouldVisualiseInstance(concept)) {
const relation = concept;

promises.push(new Promise((resolve) => {
Expand Down
8 changes: 7 additions & 1 deletion test/helpers/MockConcepts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function getMockEntityType() {
id: '0000',
label: () => Promise.resolve('person'),
instances: () => Promise.resolve({ next: () => Promise.resolve(getMockEntity1()) }), // eslint-disable-line no-use-before-define
isImplicit: () => Promise.resolve(false),
attributes: () => Promise.resolve({ next: () => Promise.resolve(getMockAttributeType()), collect: () => Promise.resolve([getMockAttributeType()]) }), // eslint-disable-line no-use-before-define
playing: () => Promise.resolve({ next: () => Promise.resolve(getMockRoleType1()), collect: () => Promise.resolve([getMockRoleType1(), getMockRoleType2()]) }), // eslint-disable-line no-use-before-define
isType: () => true,
Expand All @@ -16,13 +17,15 @@ function getMockRoleType1() {
return {
baseType: 'Role_TYPE',
label: () => Promise.resolve('child'),
isImplicit: () => Promise.resolve(false),
};
}

function getMockRoleType2() {
return {
baseType: '',
label: () => Promise.resolve('@has'),
isImplicit: () => Promise.resolve(true),
};
}

Expand All @@ -31,8 +34,9 @@ function getMockAttributeType() {
baseType: 'ATTRIBUTE_TYPE',
id: '1111',
label: () => Promise.resolve('name'),
isImplicit: () => Promise.resolve(false),
isType: () => true,
valueType: () => Promise.resolve('String'),
dataType: () => Promise.resolve('String'),
};
}

Expand All @@ -41,13 +45,15 @@ function getMockRelationType() {
baseType: 'RELATION_TYPE',
id: '2222',
label: () => Promise.resolve('parentship'),
isImplicit: () => Promise.resolve(false),
};
}

function getMockImplicitRelationType() {
return {
baseType: 'RELATION_TYPE',
id: '2222',
isImplicit: () => Promise.resolve(true),
isThing: () => false,
};
}
Expand Down
Loading

0 comments on commit 71cdc36

Please sign in to comment.