Skip to content

Commit 9fd2710

Browse files
authored
Merge pull request #243 from thingsdb/update
Multiple updates
2 parents 7587347 + 279f56b commit 9fd2710

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

react/src/Components/Nodes/SVGNodes/OpenNodeGraph.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const withStores = withVlow([{
2121
const OpenNodeGraph = ({nodes, streamInfo}) => {
2222
const [open, setOpen] = React.useState(false);
2323
const [loading, setLoading] = React.useState(false);
24+
const hasStreamInfo = nodes.length > 1;
2425

2526
const handleLoading = React.useCallback(() => {
2627
setTimeout(()=> {
@@ -29,7 +30,7 @@ const OpenNodeGraph = ({nodes, streamInfo}) => {
2930
}, []);
3031

3132
React.useEffect(() => {
32-
if (open) {
33+
if (open && hasStreamInfo) {
3334
setLoading(true);
3435
NodesActions.getStreamInfo(handleLoading);
3536
}
@@ -52,17 +53,17 @@ const OpenNodeGraph = ({nodes, streamInfo}) => {
5253
actionButtons={
5354
<React.Fragment>
5455
<Tooltip disableFocusListener disableTouchListener title="Refresh stream info">
55-
<Button color="primary" onClick={handleRefresh} >
56+
<Button color="primary" onClick={handleRefresh}>
5657
<RefreshIcon color="primary" />
5758
</Button>
5859
</Tooltip>
5960
<StartStopPolling onPoll={handleRefresh} title="stream info" />
6061
</React.Fragment>
6162
}
6263
button={
63-
<Tooltip disableFocusListener disableTouchListener title={Object.keys(streamInfo).length ? 'Ready' : 'Getting stream data...'} >
64+
<Tooltip disableFocusListener disableTouchListener title={!hasStreamInfo ? 'No stream data on one node' : Object.keys(streamInfo).length ? 'Ready' : 'Getting stream data...'} >
6465
<span>
65-
<Button variant="outlined" color="primary" onClick={handleClickOpen} >
66+
<Button variant="outlined" color="primary" disabled={!hasStreamInfo} onClick={handleClickOpen} >
6667
{'View stream graph'}
6768
</Button>
6869
</span>

react/src/Components/Users/Config/UserAccess.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const UserAccess = ({user, collections}) => {
5050
const getSwitches = (scope, privileges) => {
5151
let s = {
5252
full: false,
53+
user: false,
5354
query: false,
5455
change: false,
5556
grant: false,
@@ -58,12 +59,18 @@ const UserAccess = ({user, collections}) => {
5859
};
5960

6061
s.full = privileges.includes('FULL');
62+
s.user = privileges.includes('USER');
6163
if (s.full) {
6264
s.query = true;
6365
s.change = true;
6466
s.grant = true;
6567
s.join = true;
6668
s.run = true;
69+
} else if (s.user) {
70+
s.query = true;
71+
s.change = true;
72+
s.join = true;
73+
s.run = true;
6774
} else {
6875
s.query = privileges.includes('QUERY');
6976
s.change = privileges.includes('CHANGE');

react/src/Components/Utils/Language.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default {
3737
'every': 'This function tests whether all elements in the array pass a given test. It returns a boolean value.',
3838
'extend': 'Adds a list or tuple with items to the end of a list, and returns the new length.',
3939
'extend_unique': 'Adds a list or tuple with items to the end of a list, and returns the new length. Only items which do not have a duplicate in the list will be added.',
40+
'fill': 'Fills a list with a given value.',
4041
'filter': 'When this method is used on an list or tuple, a new list is returned with elements that pass the test.',
4142
'find': 'This function returns the value of the first element in the list or tuple that satisfies the callback function. Otherwise nil is returned unless an alternative return value is specified.',
4243
'find_index': 'This function returns the index of the first element in a list or tuple that satisfies the callback function. Otherwise nil is returned.',
@@ -48,6 +49,9 @@ export default {
4849
'last':'Returns the last item in the list. A lookup_err() is raised when this function is used on an empty list unless a default value is given, in which case the given value will be returned.',
4950
'len': 'Returns the length of a list or tuple.',
5051
'map': 'Iterate over items in an list or tuple.',
52+
'map_id': 'The function must be called on a list with things and returns a new list with the Ids of all the things.',
53+
'map_type': 'The function must be called on a list with Ids (integer values) or things and returns a new list with the Ids and things converted to corresponding typed things.',
54+
'map_wrap': 'The function must be called on a list with things and returns a new list with every thing wrapped according the given type.',
5155
'pop': 'Removes the last element from a list and returns that element. This method changes the length of the list. The pop() method works on a list type array, but not on a tuple since tuples are immutable.',
5256
'push': 'Adds new items to the end of an list, and returns the new length',
5357
'reduce': 'Executes a given reducer closure on each element of the list, resulting in a single output value.',
@@ -81,6 +85,8 @@ export default {
8185
'has': 'Determines if a set has a given thing.',
8286
'len': 'Returns the length of a set.',
8387
'map': 'Iterate over items in an set.',
88+
'map_id': 'The function returns a list with the Ids of all the things in the set.',
89+
'map_wrap': 'The function returns a list with every thing wrapped according the given type.',
8490
'one': 'This function returns a thing from a set. The set must contain at least one thing, otherwise a lookup_err() is raised.',
8591
'reduce': 'Executes a given reducer closure on every thing in the set, accumulating to a single return value.',
8692
'remove': 'This function can be used to remove things from a set. If a closure is used, then all things that satisfy the test are removed from the set and returned as list. The order of the removed things is not guaranteed since the set itself is unordered. It is also possible to specify things as arguments. In this case a list is returned with all the things which are removed from the set, in the order that the arguments are used. Things which are not found in the set are ignored.',
@@ -130,6 +136,7 @@ export default {
130136
'len': 'Returns the number of items in a thing.',
131137
'map': 'Iterate over all properties on a thing.',
132138
'remove': 'This function removes all properties from a thing that satisfies the callback function. The removed values will be returned in a new list. An empty list is returned if no values are removed.',
139+
'ren': 'Rename a property on a thing.',
133140
'restrict': 'Set or remove a value restriction on a thing. Function restriction() can be used to view the current restriction.',
134141
'restriction': 'Returns the value restriction of a thing as type str or nil when the thing is not value restricted.',
135142
'set': 'Creates a new property on a thing. If the property already existed then the old property will be overwritten. This function is equal to an assignment except that it can be used when the name of the property is dynamic.',
@@ -161,14 +168,14 @@ export default {
161168
'del_type': 'Deletes an existing Type. It is not possible to delete a Type which is used by another type. You should first change or delete the other type before you are able to delete this type. See the example below.',
162169
'enum': 'Get an enum member by value',
163170
'enum_info': 'Return info about the enumerator type.',
171+
'enum_map': 'Returns a thing with key/value pairs for all the members of a given enum.',
164172
'enums_info': 'Return info about all the enumerator types in the current scope',
165173
'err': 'Returns an error.',
166174
'change_id': 'Returns the current change Id for the running query. The return value will be nil if the query does not require a change.',
167175
'float': 'Returns a float from a specified value. If no value is given, the default float 0.0 is returned. If the specified value is of type raw, then the initial characters of the string are converted until a non-digit character is found. Initial white space is ignored and the number may start with an optional + or - sign. Type bool values are converted to 1.0 for true and 0.0 for false.',
168176
'future': 'Returns a future. It is not possible to assign a future to a collection or add the future to a list. If you do, then nil will be assigned instead.',
169177
'has_enum': 'Determine if the current scope has a given enumerator type',
170178
'has_type': 'Determines if a Type exists in the current @collection scope.',
171-
'if': 'Runs a block code based on the result of a given condition.',
172179
'int': 'Returns an int from a specified value. If no value is given, the default integer 0 is returned. If the specified value was a float value, then the new integer value will be rounded towards zero. If the specified value is of type raw, then the initial characters of the string are converted until a non-digit character is found. Initial white space is ignored and the number may start with an optional + or - sign. Type bool values are converted to 1 for true and 0 for false.',
173180
'is_array': 'This function determines whether the value passed to this function is an array type or not. The functions is_lis_t and is_tuple can be used to check if the array is mutable.',
174181
'is_ascii': 'This function determines whether the value passed to this function is of type raw and contains only valid ascii characters.',
@@ -206,6 +213,7 @@ export default {
206213
'new': 'Creates a new instance of a defined Type.',
207214
'new_type': 'Creates a new Type. This function only creates a new type and does not allow you to specify any fields. With the set_type() function you can define the fields for the new type.',
208215
'now': 'Return the time in seconds since the epoch as a floating point number. If you require the same time multiple times within a query, then call now() only once and save it to a variable, for example now = now();',
216+
'nse': 'This function promises ThingsDB that your code has no-side-effects and therefore does not require a change.',
209217
'raise': 'Raises an error.',
210218
'rand': 'Returns pseudo-random random number between 0.0 and 1.0.',
211219
'randint': 'Returns pseudo-random random integer number between a given range. The first argument specifies the start of the range and must have a value less than the second argument when specifies the end of the range. The start is inclusive and the end is exclusive, for example: randint(0, 2) will return either 0 or 1.',
@@ -215,7 +223,6 @@ export default {
215223
'regex': 'This function can be used to create a regular expression from a given pattern with optional flags.',
216224
'rename_enum': 'Rename an enum type.',
217225
'rename_type': 'Rename a type.',
218-
'return': 'The return function moves the argument to the output of the current query/closure call. If no return is specified, then the last value will be the value which is returned. A second argument can be given to the return function which can be used to specify how deep the result should be returned. The default deep value is set to 1, but any value between 0 and 127 is possible. A query can run different procedures and/or closures which might have change the deep value. In case you need to know the current deep value, the function deep() can be used. When no arguments are used the return value will be nil.',
219226
'room': 'Returns a room from a specified value, that may be dynamic. If no value is given, a new room is returned.',
220227
'set': 'Returns a new empty set. If an array is given, then all elements in the given array must be or type thing and a new set is returned based on the given things. Instead of an array, it is also possible to provide things comma separated.',
221228
'set_enum': 'Create a new enumerator type',

react/src/Components/Utils/QueryInput.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ monaco.languages.setMonarchTokensProvider('mySpecialLanguage', {
104104
{ include: '@whitespace' },
105105

106106
// regular expression: ensure it is terminated before beginning (otherwise it is an opeator)
107-
[/\/(?=([^\\\/]|\\.)+\/(i?)(\s*)(\.|;|\/|,|\)|\]|\}|$))/, { token: 'regexp', bracket: '@open', next: '@regexp' }],
107+
[/\/(?=([^\\\/]|\\.)+\/([ims]*)(\s*)(\.|;|\/|,|\)|\]|\}|$))/, { token: 'regexp', bracket: '@open', next: '@regexp' }],
108108

109109
// delimiters and operators
110110
[/[()\[\]]/, '@brackets'],
@@ -128,8 +128,6 @@ monaco.languages.setMonarchTokensProvider('mySpecialLanguage', {
128128
[/[;,.]/, 'delimiter'],
129129

130130
// strings
131-
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
132-
[/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string
133131
[/"/, 'string', '@string_double'],
134132
[/'/, 'string', '@string_single'],
135133
[/`/, 'string', '@string_backtick'],
@@ -157,7 +155,7 @@ monaco.languages.setMonarchTokensProvider('mySpecialLanguage', {
157155
[/[^\\\/]/, 'regexp'],
158156
[/@regexpesc/, 'regexp.escape'],
159157
[/\\\./, 'regexp.invalid'],
160-
[/(\/)(i?)/, [{ token: 'regexp', bracket: '@close', next: '@pop' }, 'keyword.other']],
158+
[/(\/)([ims]*)/, [{ token: 'regexp', bracket: '@close', next: '@pop' }, 'keyword.other']],
161159
],
162160

163161
regexrange: [
@@ -183,8 +181,9 @@ monaco.languages.setMonarchTokensProvider('mySpecialLanguage', {
183181
],
184182

185183
string_backtick: [
184+
[/\{\{/, 'string'],
186185
[/\{/, { token: 'delimiter.bracket', next: '@bracketCounting' }],
187-
[/[^\\`{]+/, 'string'],
186+
[/[^\{`\{]+/, 'string'],
188187
[/@escapes/, 'string.escape'],
189188
[/\\./, 'string.escape.invalid'],
190189
[/`/, 'string', '@pop']

0 commit comments

Comments
 (0)