Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(site): allow any file extension on template editor#12000

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

Merged
BrunoQuaresma merged 20 commits intomainfrombq/template-editor
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
20 commits
Select commitHold shift + click to select a range
4635cbd
Display all files in the editor
BrunoQuaresmaFeb 2, 2024
541c953
Adjust group padding
BrunoQuaresmaFeb 2, 2024
1785b90
Show error for unsupported files
BrunoQuaresmaFeb 2, 2024
9653fc7
Save version on URL even when building
BrunoQuaresmaFeb 2, 2024
ce75edd
Remove unecessary state
BrunoQuaresmaFeb 2, 2024
4403a18
Keep user navigation from URL
BrunoQuaresmaFeb 2, 2024
3957240
Merge branch 'main' of https://github.com/coder/coder into bq/templat…
BrunoQuaresmaFeb 5, 2024
a418467
Show stack files
BrunoQuaresmaFeb 5, 2024
0c72ecc
Remove unecessary imports
BrunoQuaresmaFeb 5, 2024
2353ea9
Add file tree on template files
BrunoQuaresmaFeb 5, 2024
0c2ffc9
Add edit button
BrunoQuaresmaFeb 5, 2024
98aa054
Use same editor bg
BrunoQuaresmaFeb 5, 2024
8508e69
Add storybook for visual testing
BrunoQuaresmaFeb 6, 2024
94775b1
Fix tests
BrunoQuaresmaFeb 6, 2024
4593f0e
Fix test
BrunoQuaresmaFeb 6, 2024
1a7ef6d
Merge branch 'main' of https://github.com/coder/coder into bq/templat…
BrunoQuaresmaFeb 7, 2024
955bced
wip: group empty folders
BrunoQuaresmaFeb 7, 2024
bfdabb3
Group empty folders + remove contextual actions if there is any
BrunoQuaresmaFeb 7, 2024
469a35c
Grey out hidden files
BrunoQuaresmaFeb 7, 2024
9a95846
Fix storybook
BrunoQuaresmaFeb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
wip: group empty folders
  • Loading branch information
@BrunoQuaresma
BrunoQuaresma committedFeb 7, 2024
commit955bced3a64f90c3df497640f261998c0c1add63
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,3 +49,20 @@ export const NestedOpen: Story = {
activePath: "folder/nested.tf",
},
};

export const GroupEmptyFolders: Story = {
args: {
fileTree: {
"main.tf": "resource aws_instance my_instance {}",
"variables.tf": "variable my_var {}",
"outputs.tf": "output my_output {}",
folder: {
"other-folder": {
another: {
"nested.tf": "resource aws_instance my_instance {}",
},
},
},
},
},
};
21 changes: 17 additions & 4 deletionssite/src/modules/templates/TemplateFiles/TemplateFileTree.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,14 +46,23 @@ export const TemplateFileTree: FC<TemplateFilesTreeProps> = ({
Label,
}) => {
const [contextMenu, setContextMenu] = useState<ContextMenu | undefined>();

const isFolder = (content?: FileTree | string): content is FileTree =>
typeof content === "object";

const buildTreeItems = (
filename: string,
content?: FileTree | string,
parentPath?: string,
): JSX.Element => {
const currentPath = parentPath ? `${parentPath}/${filename}` : filename;
const isFolder = typeof content === "object";
let icon: JSX.Element | null = isFolder ? null : (
// Used to group empty folders in one single label like VSCode does
const shouldGroupFolderLabel =
isFolder(content) &&
Object.keys(content).length === 1 &&
isFolder(Object.keys(content)[0]);

let icon: JSX.Element | null = isFolder(content) ? null : (
<FormatAlignLeftOutlined />
);

Expand All@@ -73,7 +82,11 @@ export const TemplateFileTree: FC<TemplateFilesTreeProps> = ({
key={currentPath}
label={
Label ? (
<Label path={currentPath} filename={filename} isFolder={isFolder} />
<Label
path={currentPath}
filename={filename}
isFolder={isFolder(content)}
/>
) : (
filename
)
Expand DownExpand Up@@ -143,7 +156,7 @@ export const TemplateFileTree: FC<TemplateFilesTreeProps> = ({
} as CSSProperties
}
>
{isFolder &&
{isFolder(content) &&
Object.keys(content)
.sort(sortFileTree(content))
.map((filename) => {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp