Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
06b2d672
Commit
06b2d672
authored
Mar 16, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix forward slash problem in files path
parent
821d4507
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
13 deletions
+18
-13
ContractSourceCode.tsx
ui/address/contract/ContractSourceCode.tsx
+5
-2
composeFileTree.ts
ui/shared/monaco/utils/composeFileTree.ts
+1
-11
formatFilePath.ts
ui/shared/monaco/utils/formatFilePath.ts
+12
-0
No files found.
ui/address/contract/ContractSourceCode.tsx
View file @
06b2d672
...
...
@@ -6,6 +6,7 @@ import type { SmartContract } from 'types/api/contract';
import
LinkInternal
from
'
ui/shared/LinkInternal
'
;
import
CodeEditor
from
'
ui/shared/monaco/CodeEditor
'
;
import
formatFilePath
from
'
ui/shared/monaco/utils/formatFilePath
'
;
interface
Props
{
data
:
string
;
...
...
@@ -37,8 +38,10 @@ const ContractSourceCode = ({ data, hasSol2Yml, address, isViper, filePath, addi
)
:
null
;
const
editorData
=
React
.
useMemo
(()
=>
{
const
defaultName
=
isViper
?
'
index.vy
'
:
'
index.sol
'
;
return
[
{
file_path
:
filePath
||
defaultName
,
source_code
:
data
},
...(
additionalSource
||
[])
];
const
defaultName
=
isViper
?
'
/index.vy
'
:
'
/index.sol
'
;
return
[
{
file_path
:
formatFilePath
(
filePath
||
defaultName
),
source_code
:
data
},
...(
additionalSource
||
[]).
map
((
source
)
=>
({
...
source
,
file_path
:
formatFilePath
(
source
.
file_path
)
}))
];
},
[
additionalSource
,
data
,
filePath
,
isViper
]);
return
(
...
...
ui/shared/monaco/utils/composeFileTree.ts
View file @
06b2d672
...
...
@@ -2,17 +2,7 @@ import type { File, FileTree } from '../types';
import
sortFileTree
from
'
./sortFileTree
'
;
const
stripLeadingSlash
=
(
str
:
string
)
=>
{
if
(
str
[
0
]
===
'
.
'
&&
str
[
1
]
===
'
/
'
)
{
return
str
.
slice
(
2
);
}
if
(
str
[
0
]
===
'
/
'
)
{
return
str
.
slice
(
1
);
}
return
str
;
};
const
stripLeadingSlash
=
(
str
:
string
)
=>
str
[
0
]
===
'
/
'
?
str
.
slice
(
1
)
:
str
;
export
default
function
composeFileTree
(
files
:
Array
<
File
>
)
{
const
result
:
FileTree
=
[];
...
...
ui/shared/monaco/utils/formatFilePath.ts
0 → 100644
View file @
06b2d672
// ensure that path always starts with /
export
default
function
formatFilePath
(
path
:
string
)
{
if
(
path
[
0
]
===
'
.
'
&&
path
[
1
]
===
'
/
'
)
{
return
path
.
slice
(
1
);
}
if
(
path
[
0
]
===
'
/
'
)
{
return
path
;
}
return
'
/
'
+
path
;
}
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