- Notifications
You must be signed in to change notification settings - Fork1k
feat(site): add support for.sh
and.tpl
files to template editor#9674
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -6,13 +6,17 @@ import { SyntaxHighlighter } from "components/SyntaxHighlighter/SyntaxHighlighte | ||||||
import { UseTabResult } from "hooks/useTab"; | ||||||
import { FC } from "react"; | ||||||
import { combineClasses } from "utils/combineClasses"; | ||||||
import { AllowedExtension, TemplateVersionFiles } from "utils/templateVersion"; | ||||||
import InsertDriveFileOutlined from "@mui/icons-material/InsertDriveFileOutlined"; | ||||||
const iconByExtension: Record<AllowedExtension, JSX.Element> = { | ||||||
tf: <TerraformIcon />, | ||||||
md: <MarkdownIcon />, | ||||||
mkd: <MarkdownIcon />, | ||||||
Dockerfile: <DockerIcon />, | ||||||
protobuf: <InsertDriveFileOutlined />, | ||||||
sh: <InsertDriveFileOutlined />, | ||||||
tpl: <InsertDriveFileOutlined />, | ||||||
}; | ||||||
const getExtension = (filename: string) => { | ||||||
@@ -24,11 +28,14 @@ const getExtension = (filename: string) => { | ||||||
return filename; | ||||||
}; | ||||||
const languageByExtension: Record<AllowedExtension, string> = { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. actually, move this whole CollaboratorAuthor
| ||||||
tf: "hcl", | ||||||
md: "markdown", | ||||||
mkd: "markdown", | ||||||
Dockerfile: "dockerfile", | ||||||
sh: "bash", | ||||||
tpl: "tpl", | ||||||
protobuf: "protobuf", | ||||||
}; | ||||||
export const TemplateFiles: FC<{ | ||||||
@@ -47,7 +54,7 @@ export const TemplateFiles: FC<{ | ||||||
<div className={styles.tabs}> | ||||||
{filenames.map((filename, index) => { | ||||||
const tabValue = index.toString(); | ||||||
const extension = getExtension(filename) as AllowedExtension; | ||||||
const icon = iconByExtension[extension]; | ||||||
const hasDiff = | ||||||
previousFiles && | ||||||
@@ -76,7 +83,11 @@ export const TemplateFiles: FC<{ | ||||||
<SyntaxHighlighter | ||||||
value={currentFile} | ||||||
compareWith={previousFile} | ||||||
language={ | ||||||
languageByExtension[ | ||||||
getExtension(selectedFilename) as AllowedExtension | ||||||
] | ||||||
} | ||||||
/> | ||||||
</div> | ||||||
); | ||||||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -23,7 +23,17 @@ export const getTemplateVersionFiles = async ( | ||||||||||||||||||||||||||
return files; | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
export const allowedExtensions = [ | ||||||||||||||||||||||||||
"tf", | ||||||||||||||||||||||||||
"md", | ||||||||||||||||||||||||||
"mkd", | ||||||||||||||||||||||||||
"Dockerfile", | ||||||||||||||||||||||||||
"protobuf", | ||||||||||||||||||||||||||
"sh", | ||||||||||||||||||||||||||
"tpl", | ||||||||||||||||||||||||||
] as const; | ||||||||||||||||||||||||||
export type AllowedExtension = (typeof allowedExtensions)[number]; | ||||||||||||||||||||||||||
Comment on lines +26 to +36 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Hm... in this case the Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. we just aren't using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. we are! we use it to do some checks + filtering when unzipping the template files. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. oh, well then nevermind lmao. you're doing great. 💕 | ||||||||||||||||||||||||||
export const isAllowedFile = (name: string) => { | ||||||||||||||||||||||||||
return allowedExtensions.some((ext) => name.endsWith(ext)); | ||||||||||||||||||||||||||