Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
377cee61
Commit
377cee61
authored
May 22, 2018
by
Jaden DIEFENBAUGH
Browse files
[toolchains] properly update all synchronization channel labels when renaming dataset blocks
parent
38ea1b96
Pipeline
#20366
canceled with stages
in 4 minutes and 19 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
conda/js/src/components/toolchain/ToolchainEditor.jsx
View file @
377cee61
...
...
@@ -300,6 +300,7 @@ export class ToolchainEditor extends React.PureComponent<Props, State> {
// changes a block's name given the set it belongs to, the old name, and the new name
updateBlockName
=
(
set
:
BlockSet
,
oldName
:
string
,
newName
:
string
)
=>
{
// func to update from/to strings with old names to new names
const
updateConn
=
(
from
,
to
):
string
[]
=>
{
const
fromSplit
=
from
.
split
(
'
.
'
);
fromSplit
[
0
]
=
fromSplit
[
0
]
===
oldName
?
newName
:
fromSplit
[
0
];
...
...
@@ -307,6 +308,8 @@ export class ToolchainEditor extends React.PureComponent<Props, State> {
toSplit
[
0
]
=
toSplit
[
0
]
===
oldName
?
newName
:
toSplit
[
0
];
return
[
fromSplit
.
join
(
'
.
'
),
toSplit
.
join
(
'
.
'
)];
};
// update the block & conn representation with the new names
const
rep
=
{...
this
.
state
.
cache
.
contents
.
representation
};
rep
.
blocks
=
{...
rep
.
blocks
};
rep
.
blocks
[
newName
]
=
rep
.
blocks
[
oldName
];
...
...
@@ -322,20 +325,26 @@ export class ToolchainEditor extends React.PureComponent<Props, State> {
})
.
reduce
((
cs
,
c
)
=>
({...
cs
,
[
c
[
0
]]:
c
[
1
]}),
{})
;
// update the channel colors
if
(
set
===
'
datasets
'
){
rep
.
channel_colors
[
newName
]
=
rep
.
channel_colors
[
oldName
];
delete
rep
.
channel_colors
[
oldName
];
}
// update blocks & connections
const
newContents
=
{
...
this
.
state
.
cache
.
contents
,
[
set
]:
this
.
state
.
cache
.
contents
[
set
].
map
(
s
=>
s
.
name
===
oldName
?
{...
s
,
name
:
newName
}
:
s
),
// update the conns, both the names of the blocks and the channel
connections
:
this
.
state
.
cache
.
contents
.
connections
.
map
(
c
=>
{
if
(
!
c
.
from
.
includes
(
oldName
)
&&
!
c
.
to
.
includes
(
oldName
))
if
(
!
c
.
from
.
includes
(
oldName
)
&&
!
c
.
to
.
includes
(
oldName
)
&&
c
.
channel
!==
oldName
)
return
c
;
const
newChannel
=
c
.
channel
===
oldName
?
newName
:
c
.
channel
;
const
updated
=
updateConn
(
c
.
from
,
c
.
to
);
return
{
...
c
,
channel
:
newChannel
,
from
:
updated
[
0
],
to
:
updated
[
1
],
};
...
...
@@ -343,6 +352,17 @@ export class ToolchainEditor extends React.PureComponent<Props, State> {
representation
:
rep
,
};
// if the changed block is a dataset, update the synchronized_channel on all blocks using its old name
if
(
set
===
'
datasets
'
){
newContents
[
'
blocks
'
]
=
this
.
state
.
cache
.
contents
.
blocks
.
map
(
s
=>
s
.
synchronized_channel
===
oldName
?
{...
s
,
synchronized_channel
:
newName
}
:
s
)
;
newContents
[
'
analyzers
'
]
=
this
.
state
.
cache
.
contents
.
analyzers
.
map
(
s
=>
s
.
synchronized_channel
===
oldName
?
{...
s
,
synchronized_channel
:
newName
}
:
s
)
;
}
const
newGroups
=
this
.
state
.
cache
.
extraContents
.
groups
.
map
(({
name
,
blocks
})
=>
({
name
,
blocks
:
blocks
.
map
(
n
=>
n
===
oldName
?
newName
:
n
)
}));
console
.
log
(
newName
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment