diff --git a/modules/desktop/src/components/essential-workshops/essential-workshops.svelte b/modules/desktop/src/components/essential-workshops/essential-workshops.svelte index 3ac28a4..ae293d9 100644 --- a/modules/desktop/src/components/essential-workshops/essential-workshops.svelte +++ b/modules/desktop/src/components/essential-workshops/essential-workshops.svelte @@ -17,7 +17,7 @@ {#if courses.length} - + {:else}
diff --git a/modules/desktop/src/components/installed-packages/installed-packages.svelte b/modules/desktop/src/components/installed-packages/installed-packages.svelte deleted file mode 100644 index 191ddc0..0000000 --- a/modules/desktop/src/components/installed-packages/installed-packages.svelte +++ /dev/null @@ -1,39 +0,0 @@ - - -`} ctaLink="#" /> - -
    - {#if packages.length > 0} - {#each packages as pkg} -
    - { - console.log('do something with:', pkg.full_name); - }} - /> -
    - {/each} - {:else} - {#each Array(12) as _} -
    - -
    - {/each} - {/if} -
diff --git a/modules/desktop/src/components/news/news.svelte b/modules/desktop/src/components/news/news.svelte index 468541f..55658e4 100644 --- a/modules/desktop/src/components/news/news.svelte +++ b/modules/desktop/src/components/news/news.svelte @@ -12,7 +12,7 @@ postsStore.subscribeByTag('news', (posts) => (news = posts)); -`} ctaLink="/" /> + {#if news.length} {:else} diff --git a/modules/desktop/src/components/package-banner/package-banner.svelte b/modules/desktop/src/components/package-banner/package-banner.svelte index 8e15c66..ad9a5cf 100644 --- a/modules/desktop/src/components/package-banner/package-banner.svelte +++ b/modules/desktop/src/components/package-banner/package-banner.svelte @@ -1,6 +1,7 @@ - -
-
{$t("home.resources")}
- -
- - - -
-
- -{#if posts.length} - -{:else} -
- -
-{/if} - - - \ No newline at end of file diff --git a/modules/desktop/src/components/search-packages/search-packages.svelte b/modules/desktop/src/components/search-packages/search-packages.svelte deleted file mode 100644 index 6169cbe..0000000 --- a/modules/desktop/src/components/search-packages/search-packages.svelte +++ /dev/null @@ -1,93 +0,0 @@ - - -
-
-
- -
-
-
- -
-
-
-
    - {#if packages.length > 0} - {#each packages as pkg} -
    - { - try { - pkg.state = PackageStates.INSTALLING; - await installPackage(pkg); - pkg.state = PackageStates.INSTALLED; - } catch (error) { - console.error(error); - } - }} - /> -
    - {/each} - {:else} - {#each Array(12) as _} -
    - -
    - {/each} - {/if} -
-
diff --git a/modules/desktop/src/components/tea-update/tea-update.svelte b/modules/desktop/src/components/tea-update/tea-update.svelte deleted file mode 100644 index a3510fd..0000000 --- a/modules/desktop/src/components/tea-update/tea-update.svelte +++ /dev/null @@ -1,101 +0,0 @@ - - -{#if updateState === 'not_installed'} - -{/if} - -{#if updateState === 'update_required'} - -{/if} - - diff --git a/modules/desktop/src/components/top-packages/top-packages.svelte b/modules/desktop/src/components/top-packages/top-packages.svelte deleted file mode 100644 index 46bba47..0000000 --- a/modules/desktop/src/components/top-packages/top-packages.svelte +++ /dev/null @@ -1,33 +0,0 @@ - - - - \ No newline at end of file diff --git a/modules/desktop/src/components/top-scripts/top-scripts.svelte b/modules/desktop/src/components/top-scripts/top-scripts.svelte deleted file mode 100644 index 9e6aa95..0000000 --- a/modules/desktop/src/components/top-scripts/top-scripts.svelte +++ /dev/null @@ -1,51 +0,0 @@ - - - - - { - console.log(script) - }} -/> \ No newline at end of file diff --git a/modules/desktop/src/libs/stores/pkgs.ts b/modules/desktop/src/libs/stores/pkgs.ts index 041d77a..9ed73ae 100644 --- a/modules/desktop/src/libs/stores/pkgs.ts +++ b/modules/desktop/src/libs/stores/pkgs.ts @@ -5,29 +5,17 @@ import Fuse from "fuse.js"; import { getPackage, getDistPackages, - openTerminal, getInstalledPackages, installPackage, getPackageBottles } from "@native"; import { getReadme, getContributors, getRepoAsPackage } from "$libs/github"; -import { notificationStore } from "../stores"; -import { NotificationType } from "@tea/ui/types"; import type { Package } from "@tea/ui/types"; import { trackInstall, trackInstallFailed } from "$libs/analytics"; const log = window.require("electron-log"); -const installTea = async () => { - log.info("installing tea..."); - try { - openTerminal(`sh <(curl https://tea.xyz)`); - } catch (error) { - log.error("install failed", error); - } -}; - export default function initPackagesStore() { let initialized = false; const syncProgress = writable(0); // TODO: maybe use this in the UI someday @@ -49,8 +37,8 @@ export default function initPackagesStore() { }); }; - const syncPackageData = async (guiPkg: Partial) => { - if (guiPkg.synced) return; + const syncPackageData = async (guiPkg: Partial | undefined) => { + if (!guiPkg || guiPkg.synced) return; const pkg = await getPackage(guiPkg.full_name!); // ATM: pkg only bottles and github:string const readmeMd = `# ${guiPkg.full_name} # @@ -87,16 +75,6 @@ To read more about this package go to [${guiPkg.homepage}](${guiPkg.homepage}). const isUpToDate = teaPkg.version === installedPkg?.installed_versions[0]; log.info("check if Tea-CLI is up to date:", isUpToDate); - //TODO: Is there where we handle the case of tea not being installed at all? - if (!isUpToDate) { - notificationStore.add({ - message: "install cli", - i18n_key: "package.update-tea-cli", - type: NotificationType.ACTION_BANNER, - callback: installTea, - callback_label: "UPDATE" - }); - } }; const init = async function () { @@ -202,7 +180,8 @@ To read more about this package go to [${guiPkg.homepage}](${guiPkg.homepage}). fetchPackageBottles, updatePackage, init, - installPkg + installPkg, + syncPackageData }; } diff --git a/modules/desktop/src/libs/translations/translations.json b/modules/desktop/src/libs/translations/translations.json index 9be479f..0fee33b 100644 --- a/modules/desktop/src/libs/translations/translations.json +++ b/modules/desktop/src/libs/translations/translations.json @@ -3,39 +3,9 @@ "lang": { "en": "English" }, - "cli": { - "install": "install tea" - }, "store-search-placeholder": "type to search", - "search": "search", - "home": { - "all-packages": "All packages", - "discover-title": "DISCOVER", - "asset-title": "ASSET TYPE", - "tutorials-title": "TUTORIALS", - "os-news-title": "OPEN-SOURCE NEWS", - "resources": "Resources" - }, "package": { "update-all": "UPDATE ALL", - "top-list-title": "Top packages this week", - "browse-cta": "Browse packages", - "what-title": "What are packages?", - "short-description": "Collections of files aggregated to form larger frameworks & functions. Think Python or Node.js.", - "foundation-essentials-title": "FOUNDATION ESSENTIALS", - "view-all-cta": "View all packages", - "install-label": "install", - "installed-label": "installed", - "installing-label": "installing", - "reinstall-label": "re-install", - "needs-update-label": "update", - "my-installs-title": "my installs", - "check-for-updates": "check for updates", - "details": "details", - "install-tea-label": "Install tea cli", - "update-tea-label": "Update now", - "install-tea-cli": "This app requires our command-line interface", - "update-tea-cli": "An update is available for tea cli", "cta-AVAILABLE": "INSTALL", "cta-INSTALLED": "INSTALLED", "cta-INSTALLING": "INSTALLING", @@ -43,19 +13,6 @@ "cta-NEEDS_UPDATE": "UPDATE", "cta-UPDATING": "UPDATING" }, - "script": { - "top-list-title": "Top scripts this week", - "view-all-cta": "View all scripts", - "use-label": "use", - "browse-cta": "Browse scripts", - "what-title": "What are scripts?", - "short-description": "Invisible applications that chain packages together in order to perform cool actions on your computer." - }, - "post": { - "workshops-title": "workshops to get started", - "article-more-cta": "Read more articles", - "read-more-cta": "read more" - }, "footer": { "quick-links-title": "quick links", "about-tea-store": "about the tea store", @@ -79,7 +36,15 @@ "home": "home", "all": "All", "articles": "Articles", - "workshops": "Workshops" + "workshops": "Workshops", + "details": "details", + "versions": "versions", + "metadata": "Metadata", + "homepage": "Homepage", + "documentation": "Documentation", + "github-repository": "Github Repository", + "contributors": "Contributors", + "view-on-github": "View on github" }, "notification": { "gui-downloading": "A new tea gui({{version}}) is being downloaded. Please don't close the app.", @@ -99,6 +64,7 @@ }, "tags": { "all": "all", + "installed": "installed", "updates_available": "Updates available", "recently_updated": "Recently updated", "new_packages": "New packages", diff --git a/modules/desktop/src/routes/cli/+page.svelte b/modules/desktop/src/routes/cli/+page.svelte deleted file mode 100644 index 1f96cec..0000000 --- a/modules/desktop/src/routes/cli/+page.svelte +++ /dev/null @@ -1,22 +0,0 @@ - - -
- {$t('cli.install')} - -
- -
- -
- -
-
diff --git a/modules/desktop/src/routes/packages/+page.svelte b/modules/desktop/src/routes/packages/+page.svelte index 785d596..b2d05fe 100644 --- a/modules/desktop/src/routes/packages/+page.svelte +++ b/modules/desktop/src/routes/packages/+page.svelte @@ -1,10 +1,8 @@
Packages -
diff --git a/modules/desktop/src/routes/packages/[slug]/+page.svelte b/modules/desktop/src/routes/packages/[slug]/+page.svelte index 6f100c7..7d4a69f 100644 --- a/modules/desktop/src/routes/packages/[slug]/+page.svelte +++ b/modules/desktop/src/routes/packages/[slug]/+page.svelte @@ -5,7 +5,6 @@ import { page } from '$app/stores'; // import PageHeader from '$components/page-header/page-header.svelte'; import PackageBanner from '$components/package-banner/package-banner.svelte'; - import type { Bottle } from '@tea/ui/types'; // import SuggestedPackages from '$components/suggested-packages/suggested-packages.svelte'; import Tabs from '@tea/ui/tabs/tabs.svelte'; import type { Tab } from '@tea/ui/types'; @@ -13,57 +12,45 @@ import PackageMetas from '@tea/ui/package-metas/package-metas.svelte'; import Markdown from '@tea/ui/markdown/markdown.svelte'; // import PackageSnippets from '@tea/ui/package-snippets/package-snippets.svelte'; - import type { GUIPackage } from '$libs/types'; import Preloader from '@tea/ui/Preloader/Preloader.svelte'; /** @type {import('./$types').PageData} */ export let data: { slug:string, content:string, title:string }; import { packagesStore } from '$libs/stores'; + import { onMount } from 'svelte'; - let pkg: GUIPackage; + const { packages } = packagesStore; + + $: pkg = $packages.find((p) => p.slug === data?.slug); // let reviews: Review[]; - let bottles: Bottle[] = []; - let versions: string[] = []; - let readme: string; + $: bottles = pkg?.bottles || []; + $: versions = [...new Set(bottles.map((b) => b.version))]; + $: readme = pkg?.readme_md || ''; - let tabs: Tab[] = []; - - packagesStore.subscribeToPackage(data?.slug, (p) => { - pkg = p; - - if (!bottles.length && pkg.bottles) { - const newVersion = pkg.bottles.map((b) => b.version); - versions = [...new Set(newVersion)]; - bottles.push(...pkg.bottles); - tabs = [ - ...tabs, - { - label: `versions (${versions.length || 0})`, - component: Bottles, - props: { - bottles - } - } - ]; + $: tabs = [ + readme !== '' && { + label: $t("common.details"), + component: Markdown, + props: { pkg, source: readme } + }, + bottles?.length && { + label: `${$t("common.versions")} (${versions.length || 0})`, + component: Bottles, + props: { + bottles + } } + ].filter((t) => t && t?.label) as unknown as Tab[]; - if (!readme && pkg.readme_md) { - readme = pkg.readme_md; - tabs = [ - { - label: 'details', - component: Markdown, - props: { pkg, source: readme } - }, - ...tabs, - ]; - } - }); const url = $page.url; const tab = url.searchParams.get("tab"); + + onMount(() => { + packagesStore.syncPackageData(pkg); + })
{$t("common.home")} @@ -72,7 +59,7 @@ {$t(`tags.${tab}`) || "all"} > {/if} - {pkg.full_name} + {pkg?.full_name}
{#if pkg}
@@ -82,7 +69,7 @@
- +
{#if pkg} diff --git a/modules/desktop/src/routes/profile/+page.svelte b/modules/desktop/src/routes/profile/+page.svelte deleted file mode 100644 index b4d2c88..0000000 --- a/modules/desktop/src/routes/profile/+page.svelte +++ /dev/null @@ -1,28 +0,0 @@ - - -
- PROFILE -
- -
- -
-
- -
-
- -
-
- -
- -
-
diff --git a/modules/ui/src/package-metas/package-metas.svelte b/modules/ui/src/package-metas/package-metas.svelte index 357a03e..be6ed85 100644 --- a/modules/ui/src/package-metas/package-metas.svelte +++ b/modules/ui/src/package-metas/package-metas.svelte @@ -1,5 +1,6 @@
-

Metadata

+

{$t("common.metadata")}

    {#if pkg?.bottles}
  • @@ -47,7 +48,7 @@
  • {/if}
-

Homepage

+

{$t("common.homepage")}

  • shellOpenExternal(pkg.homepage)}> @@ -55,7 +56,7 @@
{#if pkg.documentation_url} -

Documentation

+

{$t("common.documentation")}

  • shellOpenExternal(pkg.documentation_url)}> @@ -64,7 +65,7 @@
{/if} {#if pkg.github} -

Github Repository

+

{$t("common.github-repository")}

  • shellOpenExternal(`https://github.com/${pkg.github}`)}> @@ -73,7 +74,7 @@
{/if} {#if pkg.contributors?.length} -

Contributors

+

{$t("common.contributors")}

    {#each pkg.contributors as contributor} diff --git a/modules/ui/src/tabs/tabs.svelte b/modules/ui/src/tabs/tabs.svelte index 4eb4f39..f02fad2 100644 --- a/modules/ui/src/tabs/tabs.svelte +++ b/modules/ui/src/tabs/tabs.svelte @@ -9,12 +9,19 @@ import Button from "../button/button.svelte"; export let tabs: Tab[] = []; + export let defaultTab: string; let active: string; + let dirty = false; + afterUpdate(() => { if (tabs.length && !active) { - active = tabs[0].label; + if (!defaultTab) { + active = tabs[0].label; + } else if (!dirty) { + active = defaultTab; + } } }); @@ -23,8 +30,13 @@ {#each tabs as tab}
    -
    {/each}