Skip to content

feat(site): Show main.tf file first on template files page #6854

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

Merged
merged 2 commits into from
Mar 30, 2023

Conversation

BrunoQuaresma
Copy link
Collaborator

Closes #6730

Screen.Recording.2023-03-28.at.15.33.16.mov

@BrunoQuaresma BrunoQuaresma requested a review from a team March 28, 2023 18:35
@BrunoQuaresma BrunoQuaresma self-assigned this Mar 28, 2023
@BrunoQuaresma BrunoQuaresma requested review from Kira-Pilot and removed request for a team March 28, 2023 18:35
Comment on lines +54 to +55
const tab = useTab("file", "")
const isLoaded = tab.value !== ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can consolidate useTab and useFileTab into one hook. Does it make sense to have useTab return its own isLoading variable? Something like:

export const useTab = (tabKey = "file", defaultValue = ""): UseTabResult => {
    return {
        isLoading: value !== "",
        ....
    }
}

// in TemplateFilesPage component

const tab = useTab()

useEffect(() => {
    if (templateFiles && !tab.isLoading) {
      const terraformFileIndex = Object.keys(templateFiles).indexOf("main.tf")
      tab.set(terraformFileIndex !== -1 ? terraformFileIndex.toString() : "0")
    }
}, [tab, templateFiles])

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since useTab is getting used from other components I would not touch that. The isLoading, for now, is a specific thing from this page so that is the reason I created the useFileTab to handle this specific logic. If at some point we see this logic is something inherited for most of the tabs we have, I would consolidate them but not now tho.

@BrunoQuaresma BrunoQuaresma enabled auto-merge (squash) March 29, 2023 19:12
@BrunoQuaresma BrunoQuaresma disabled auto-merge March 29, 2023 19:12
@BrunoQuaresma BrunoQuaresma enabled auto-merge (squash) March 29, 2023 19:12
@BrunoQuaresma BrunoQuaresma merged commit d8762c6 into main Mar 30, 2023
@BrunoQuaresma BrunoQuaresma deleted the bq/make-main-tf-default branch March 30, 2023 11:33
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In template Source Code tab, make main.tf the default
2 participants