-
Notifications
You must be signed in to change notification settings - Fork 940
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add artifacts drawer to code tab (#6550)
* add artifacts drawer to code tab * hide top level nodes by default * clean up * lint fix * artifacts tree loading * make dependency drawer scrollable * make artifact node open in new tab by default * remove unused styles * clean up * memoize + change line height Co-authored-by: Luv Kapur <[email protected]>
- Loading branch information
Showing
47 changed files
with
307 additions
and
729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,11 @@ | |
} | ||
} | ||
|
||
.openDrawer { | ||
flex: 1; | ||
height: 100%; | ||
} | ||
|
||
.codeDrawerContent { | ||
overflow-y: auto; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
scopes/component/ui/component-artifacts/artifacts-tree/artifact-file-node-clicked.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ArtifactFile } from '@teambit/component.ui.artifacts.models.component-artifacts-model'; | ||
|
||
export const fileNodeClicked = | ||
(files: (ArtifactFile & { id: string })[], opts: 'download' | 'new tab') => (e, node) => { | ||
const { id } = node; | ||
const artifactFile = files.find((file) => file.id === id); | ||
|
||
if (artifactFile?.downloadUrl) { | ||
fetch(artifactFile.downloadUrl, { method: 'GET' }) | ||
.then((res) => res.blob()) | ||
.then((blob) => { | ||
// create blob link to download | ||
const url = window.URL.createObjectURL(new Blob([blob])); | ||
const link = document.createElement('a'); | ||
link.href = url; | ||
if (opts === 'download') link.setAttribute('download', artifactFile.path); | ||
if (opts === 'new tab') link.setAttribute('target', '_blank'); | ||
// append to html page | ||
document.body.appendChild(link); | ||
// force download | ||
link.click(); | ||
// clean up and remove the link | ||
link.parentNode?.removeChild(link); | ||
}) | ||
.catch(() => {}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.