-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ui-debug): add unsupported files handling #2260
Conversation
webapp/src/components/App/Singlestudy/explore/Debug/Data/Unsupported.tsx
Outdated
Show resolved
Hide resolved
webapp/src/components/App/Singlestudy/explore/Debug/Data/Unsupported.tsx
Outdated
Show resolved
Hide resolved
webapp/src/components/App/Singlestudy/explore/Debug/Data/Text.tsx
Outdated
Show resolved
Hide resolved
webapp/src/components/App/Singlestudy/explore/Debug/Data/Unsupported.tsx
Outdated
Show resolved
Hide resolved
webapp/src/components/App/Singlestudy/explore/Debug/Data/Unsupported.tsx
Outdated
Show resolved
Hide resolved
1af012f
to
cc6b26c
Compare
5642122
to
13924e6
Compare
webapp/src/components/App/Singlestudy/explore/Debug/Data/Unsupported.tsx
Outdated
Show resolved
Hide resolved
webapp/src/components/App/Singlestudy/explore/Debug/Data/Unsupported.tsx
Outdated
Show resolved
Hide resolved
14875d9
to
4240536
Compare
a730983
to
c86ac91
Compare
//////////////////////////////////////////////////////////////// | ||
|
||
const URL_SCHEMES = { | ||
MATRIX: ["matrix://", "matrixfile://"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By convention, lower case are used for object keys, even for a constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this type of constant object where both the object name and its keys represent fixed values or schemes, it's more conventional to have both in UPPER_SNAKE_CASE, it's not a regular enum-like object see: https://google.github.io/styleguide/tsguide.html#naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your link said like me lol https://google.github.io/styleguide/tsguide.html#identifiers-constants
const URL_SCHEMES = {
matrix: ...,
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know its confusing, the style guide example uses lowercase because they're dealing with actual unit names rather than symbolic constants.
The difference is that:
In URL_SCHEMES, the keys (MATRIX, JSON, FILE) are symbolic identifiers representing categories/types
In UNIT_SUFFIXES, the keys ('milliseconds', 'seconds') are the actual string names of time units
look at "Rules by identifier type" section:
says: "CONSTANT_CASE global constant values, including enum values. See Constants below."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should create a ticket and spend time to make our set of rules, especially for this kind of conventions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for a more general example:
- When keys are symbolic constants (use UPPER_SNAKE_CASE):
const ERROR_CODES = {
NOT_FOUND: 404,
SERVER_ERROR: 500,
UNAUTHORIZED: 401
};
Here, NOT_FOUND is a symbolic name representing the concept of a "not found" error. The key itself is a symbol/identifier.
- When keys are actual VALUES/NAMES (use lowercase):
const MIME_TYPES = {
'image/jpeg': '.jpg',
'image/png': '.png',
'text/html': '.html'
};
Here, 'image/jpeg' is the actual MIME type string that would be used in HTTP headers.
Think of it this way:
- If you're using the key as a reference/symbol (like URL_SCHEMES.MATRIX), use UPPER_SNAKE_CASE
- If you're using the key as a literal value (like MIME_TYPES['image/jpeg']), use lowercase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright! I didn't know this subtlety.
// We filter to only allow extensions that can be properly displayed (.txt, .log, .csv, .tsv, .ini) | ||
// Other extensions (like .RDS or .xlsx) are marked as unsupported since they can't be shown in the UI | ||
return treeData.startsWith(URL_SCHEMES.FILE) && | ||
SUPPORTED_EXTENSIONS.some((ext) => treeData.endsWith(ext)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I had already said to you, use treeData.toLowerCase().endsWith(ext)
, because extension are case insensitive, .txt
and .TXT
are both valid, an user can import file with uppercase extension!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mybad, its fixed
* @returns Whether the path is in the output folder | ||
*/ | ||
export function isOutputFolder(path: string): boolean { | ||
return path.startsWith("output/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ouput" value has been forgotten:
return path.split("/")[0] === "output";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or rename isInOuputFolder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's intended I'll rename it to better reflect the purpose
fontSize: theme.typography.body2.fontSize, | ||
flex: 1, | ||
}} | ||
{...getSyntaxProps(parseContent(text, { filePath, fileType }))} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to parse in the usePromiseWithSnackbarError to make it once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at this point their no possible error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the error it's for the API call, but I said to had directly after the call to memoized the value.
() => getStudyData<string>(studyId, filePath).then(text => parseContent(text, { filePath, fileType })):
...
deps: [studyId, filePath, fileType],
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I will see that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed its good like this, done
894f70a
to
deeaca0
Compare
deeaca0
to
2c7eeac
Compare
ANT-2362 => handle unsupported files display
ANT-2529 => display output matrices as raw text