Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
85af62c9
Commit
85af62c9
authored
1 year ago
by
Loïc Correnson
Committed by
David Bühler
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[ivette] sanitized view management
parent
e1f9c49c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ivette/src/renderer/Laboratory.tsx
+41
-23
41 additions, 23 deletions
ivette/src/renderer/Laboratory.tsx
with
41 additions
and
23 deletions
ivette/src/renderer/Laboratory.tsx
+
41
−
23
View file @
85af62c9
...
@@ -259,19 +259,21 @@ interface CustomViewsProps {
...
@@ -259,19 +259,21 @@ interface CustomViewsProps {
views
:
React
.
PropsWithChildren
<
View
>
[]
views
:
React
.
PropsWithChildren
<
View
>
[]
}
}
interface
CustomViewsSettings
{
type
CustomShapes
=
{
[
id
:
string
]:
Shape
};
current
?:
string
;
shapes
?:
{
[
k
:
string
]:
Shape
};
}
type
CustomViews
=
{
[
id
:
string
]:
View
};
type
CustomViews
=
{
[
id
:
string
]:
View
};
function
CustomViews
(
props
:
CustomViewsProps
):
JSX
.
Element
{
function
CustomViews
(
props
:
CustomViewsProps
):
JSX
.
Element
{
const
{
settings
,
shape
,
setShape
,
views
:
libViews
}
=
props
;
const
{
settings
,
shape
,
setShape
,
views
:
libViews
}
=
props
;
const
[
local
,
setLocal
]
=
Settings
.
useWindowSettingsData
<
CustomViewsSettings
>
(
const
[
current
,
setCurrent
]
=
Settings
.
useWindowSettingsData
<
string
>
(
settings
,
`
${
settings
}
.current`
,
Json
.
identity
as
Json
.
Decoder
<
CustomViewsSettings
>
,
Json
.
jString
,
Json
.
identity
as
Json
.
Encoder
<
CustomViewsSettings
>
,
Json
.
identity
,
''
);
const
[
shapes
,
setShapes
]
=
Settings
.
useWindowSettingsData
<
CustomShapes
>
(
`
${
settings
}
.shapes`
,
Json
.
identity
as
Json
.
Decoder
<
CustomShapes
>
,
Json
.
identity
as
Json
.
Encoder
<
CustomShapes
>
,
// Clearly abusive conversion, real encoder/decoder are needed
// Clearly abusive conversion, real encoder/decoder are needed
{},
{},
);
);
...
@@ -284,8 +286,7 @@ function CustomViews(props: CustomViewsProps): JSX.Element {
...
@@ -284,8 +286,7 @@ function CustomViews(props: CustomViewsProps): JSX.Element {
);
);
const
[
edited
,
setEdited
]
=
React
.
useState
<
string
>
();
const
[
edited
,
setEdited
]
=
React
.
useState
<
string
>
();
const
triggerDefault
=
React
.
useRef
<
View
>
();
const
triggerDefault
=
React
.
useRef
<
View
>
();
const
{
current
,
shapes
=
{}
}
=
local
;
const
theViews
:
CustomViews
=
{};
const
theViews
:
{
[
id
:
string
]:
View
}
=
{};
_
.
forEach
(
libViews
,
(
view
)
=>
{
_
.
forEach
(
libViews
,
(
view
)
=>
{
const
{
const
{
...
@@ -321,9 +322,12 @@ function CustomViews(props: CustomViewsProps): JSX.Element {
...
@@ -321,9 +322,12 @@ function CustomViews(props: CustomViewsProps): JSX.Element {
const
SELECT
=
(
id
:
string
):
void
=>
{
const
SELECT
=
(
id
:
string
):
void
=>
{
if
(
id
&&
current
!==
id
)
{
if
(
id
&&
current
!==
id
)
{
if
(
current
)
shapes
[
current
]
=
shape
;
if
(
current
)
{
setLocal
({
current
:
id
,
shapes
});
const
newShapes
=
{
...
shapes
,
[
current
]:
shape
};
setShapes
(
newShapes
);
}
setShape
(
shapes
[
id
]
||
getDefaultShape
(
theViews
[
id
]));
setShape
(
shapes
[
id
]
||
getDefaultShape
(
theViews
[
id
]));
setCurrent
(
id
);
}
}
};
};
...
@@ -334,8 +338,9 @@ function CustomViews(props: CustomViewsProps): JSX.Element {
...
@@ -334,8 +338,9 @@ function CustomViews(props: CustomViewsProps): JSX.Element {
const
isCustom
=
!
view
.
builtin
;
const
isCustom
=
!
view
.
builtin
;
const
DEFAULT
=
():
void
=>
{
const
DEFAULT
=
():
void
=>
{
shapes
[
id
]
=
undefined
;
const
newShapes
=
{
...
shapes
};
setLocal
({
current
:
id
,
shapes
});
delete
newShapes
[
id
];
setShapes
(
newShapes
);
setShape
(
getDefaultShape
(
view
));
setShape
(
getDefaultShape
(
view
));
};
};
...
@@ -365,21 +370,34 @@ function CustomViews(props: CustomViewsProps): JSX.Element {
...
@@ -365,21 +370,34 @@ function CustomViews(props: CustomViewsProps): JSX.Element {
setCustoms
({
...
customs
,
[
newId
]:
customView
});
setCustoms
({
...
customs
,
[
newId
]:
customView
});
const
newShape
=
const
newShape
=
isCurrent
?
shape
:
(
shapes
[
id
]
??
getDefaultShape
(
view
));
isCurrent
?
shape
:
(
shapes
[
id
]
??
getDefaultShape
(
view
));
const
newShapes
=
{
...
shapes
,
[
newId
]:
newShape
}
;
const
newShapes
=
{
...
shapes
,
[
newId
]:
newShape
};
set
Local
({
current
:
newId
,
s
hapes
:
newShapes
}
);
set
S
hapes
(
newShapes
);
setShape
(
newShape
);
setShape
(
newShape
);
setCurrent
(
newId
);
setEdited
(
newId
);
setEdited
(
newId
);
};
};
const
REMOVE
=
():
void
=>
{
const
REMOVE
=
():
void
=>
{
delete
customs
[
id
];
const
newCustoms
=
{
...
customs
};
delete
shapes
[
id
];
const
newShapes
=
{
...
shapes
};
setCustoms
({
...
customs
});
delete
newCustoms
[
id
];
const
newCurrent
=
current
===
id
?
undefined
:
current
;
delete
newShapes
[
id
];
setLocal
({
current
:
newCurrent
,
shapes
});
setCustoms
(
newCustoms
);
setShapes
(
newShapes
);
if
(
isCurrent
)
{
const
newView
=
(
view
.
origin
&&
theViews
[
view
.
origin
])
||
_
.
find
(
theViews
,
(
v
:
View
)
=>
!!
v
.
defaultView
)
||
_
.
find
(
theViews
,
(
v
:
View
)
=>
v
.
id
!==
current
)
||
theViews
[
0
];
const
newId
=
newView
.
id
;
const
newShape
=
shapes
[
newId
]
||
getDefaultShape
(
newView
);
setCurrent
(
newId
);
setShape
(
newShape
);
}
};
};
const
onView
=
(
action
:
string
)
=>
const
onView
=
(
action
:
string
)
:
string
=>
isCurrent
?
`
${
action
}
View`
:
`
${
action
}
View (
${
view
.
label
}
)`
;
isCurrent
?
`
${
action
}
View`
:
`
${
action
}
View (
${
view
.
label
}
)`
;
const
hasRename
=
!
edited
&&
isCustom
;
const
hasRename
=
!
edited
&&
isCustom
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment