diff --git a/app/web/src/api/sdf/dal/module.ts b/app/web/src/api/sdf/dal/module.ts new file mode 100644 index 0000000000..dd3db35349 --- /dev/null +++ b/app/web/src/api/sdf/dal/module.ts @@ -0,0 +1,21 @@ +import { SchemaId, SchemaVariantId } from "./schema"; + +export type ModuleId = string; + +export interface LatestModule { + id: ModuleId; + name: string; + description: string; + ownerUserId: string; + ownerDisplayName: string; + metadata: object; + latestHash: string; + latestHashCreatedAt: IsoDateString; + schemaId: SchemaId; +} + +export interface ModuleContributeRequest { + name: string; + version: string; + schemaVariantId: SchemaVariantId; +} diff --git a/app/web/src/api/sdf/dal/schema.ts b/app/web/src/api/sdf/dal/schema.ts index 31d2f96784..ccfdacb029 100644 --- a/app/web/src/api/sdf/dal/schema.ts +++ b/app/web/src/api/sdf/dal/schema.ts @@ -70,19 +70,6 @@ export interface SchemaVariant { canContribute: boolean; } -export type ModuleId = string; -export interface Module { - id: ModuleId; - name: string; - description: string; - ownerUserId: string; - ownerDisplayName: string; - metadata: object; - latestHash: string; - latestHashCreatedAt: IsoDateString; - schemaId: SchemaId; -} - export const outputSocketsAndPropsFor = (schemaVariant: SchemaVariant) => { const socketOptions = schemaVariant.outputSockets.map((socket) => ({ label: `Output Socket: ${socket.name}`, diff --git a/app/web/src/components/AssetCard.vue b/app/web/src/components/AssetCard.vue index f9380bbd9b..68d17e7d9b 100644 --- a/app/web/src/components/AssetCard.vue +++ b/app/web/src/components/AssetCard.vue @@ -32,11 +32,13 @@ + + + +

+ Thanks for contributing! We will review your contribution, and reach out + via email or on our + Discord Server + if you have any questions. +

+
@@ -102,14 +124,23 @@ import { computed, PropType, ref } from "vue"; import tinycolor from "tinycolor2"; import clsx from "clsx"; -import { useTheme, Stack, Icon, ErrorMessage } from "@si/vue-lib/design-system"; +import { + useTheme, + Modal, + Stack, + Icon, + ErrorMessage, +} from "@si/vue-lib/design-system"; import { useRouter } from "vue-router"; +import { format as dateFormat } from "date-fns"; import { useAssetStore } from "@/store/asset.store"; import { SchemaVariantId, SchemaVariant } from "@/api/sdf/dal/schema"; import { getAssetIcon } from "@/store/components.store"; import { useModuleStore } from "@/store/module.store"; +import { ModuleContributeRequest } from "@/api/sdf/dal/module"; import IconButton from "./IconButton.vue"; import EditingPill from "./EditingPill.vue"; +import AssetContributeModal from "./AssetContributeModal.vue"; const props = defineProps({ titleCard: { type: Boolean }, @@ -121,6 +152,24 @@ const moduleStore = useModuleStore(); const router = useRouter(); const { theme } = useTheme(); +const contributeAssetModalRef = + ref>(); +const contributeAssetSuccessModalRef = ref>(); + +const contributeAsset = () => contributeAssetModalRef.value?.open(); +const onContributeAsset = () => contributeAssetSuccessModalRef.value?.open(); + +const contributeRequest = computed((): ModuleContributeRequest => { + if (asset.value) { + const version = dateFormat(Date.now(), "yyyyMMddkkmmss"); + return { + name: `${asset.value.schemaName} ${version}`, + version, + schemaVariantId: asset.value.schemaVariantId, + }; + } else throw new Error("cannot contribute: no asset selected"); +}); + const editingVersionDoesNotExist = computed( () => assetStore.unlockedVariantIdForId[asset.value?.schemaVariantId ?? ""] === @@ -139,7 +188,7 @@ const asset = computed( ); const canUpdate = computed( - () => !!assetStore.upgradeableModules[props.assetId], + () => !!moduleStore.upgradeableModules[props.assetId], ); const updateAsset = () => { @@ -148,7 +197,7 @@ const updateAsset = () => { throw new Error("cannot update asset: no asset selected"); } - const module = assetStore.upgradeableModules[schemaVariantId]; + const module = moduleStore.upgradeableModules[schemaVariantId]; if (!module) { throw new Error("cannot update asset: no upgradeable module for asset"); } diff --git a/app/web/src/components/AssetContributeModal.vue b/app/web/src/components/AssetContributeModal.vue new file mode 100644 index 0000000000..3489d81507 --- /dev/null +++ b/app/web/src/components/AssetContributeModal.vue @@ -0,0 +1,105 @@ + + + diff --git a/app/web/src/components/AssetListItem.vue b/app/web/src/components/AssetListItem.vue index 6bb7dd17b3..1fa4eed894 100644 --- a/app/web/src/components/AssetListItem.vue +++ b/app/web/src/components/AssetListItem.vue @@ -54,6 +54,7 @@ import { TreeNode, Icon } from "@si/vue-lib/design-system"; import clsx from "clsx"; import { SchemaVariant } from "@/api/sdf/dal/schema"; import { useAssetStore, schemaVariantDisplayName } from "@/store/asset.store"; +import { useModuleStore } from "@/store/module.store"; import EditingPill from "./EditingPill.vue"; const props = defineProps({ @@ -62,10 +63,12 @@ const props = defineProps({ }); const assetStore = useAssetStore(); +const moduleStore = useModuleStore(); + const { selectedSchemaVariants: selectedAssets } = storeToRefs(assetStore); const canUpdate = computed( - () => !!assetStore.upgradeableModules[props.a.schemaVariantId], + () => !!moduleStore.upgradeableModules[props.a.schemaVariantId], ); const onClick = (e: MouseEvent) => { diff --git a/app/web/src/components/AssetListPanel.vue b/app/web/src/components/AssetListPanel.vue index e94c1f5538..312cb4ed5e 100644 --- a/app/web/src/components/AssetListPanel.vue +++ b/app/web/src/components/AssetListPanel.vue @@ -3,7 +3,7 @@
- - - +

Thanks for contributing! We will review your contribution, and reach out via email or on our @@ -155,7 +138,6 @@ import { getAssetIcon } from "@/store/components.store"; import { useModuleStore } from "@/store/module.store"; import AssetNameModal from "./AssetNameModal.vue"; import AssetListItem from "./AssetListItem.vue"; -import ModuleExportModal from "./modules/ModuleExportModal.vue"; import SidebarSubpanelTitle from "./SidebarSubpanelTitle.vue"; import IconButton from "./IconButton.vue"; @@ -169,35 +151,11 @@ const createAssetReqStatus = assetStore.getRequestStatus("CREATE_VARIANT"); const loadAssetsReqStatus = assetStore.getRequestStatus( "LOAD_SCHEMA_VARIANT_LIST", ); -const loadModulesReqStatus = assetStore.getRequestStatus("LOAD_MODULES"); +const syncModulesReqStatus = moduleStore.getRequestStatus("SYNC"); -const contributeAssetModalRef = ref>(); -const exportSuccessModalRef = ref>(); +const contributeAssetSuccessModalRef = ref>(); const newAssetModalRef = ref>(); -const contributeLoadingTexts = [ - "Engaging Photon Torpedos...", - "Reticulating Splines...", - "Revolutionizing DevOps...", - "Calibrating Hyperspace Matrix...", - "Syncing Neural Circuitry...", - "Optimizing Tachyon Weave...", - "Tuning Fractal Harmonics...", - "Reshuffling Multiverse Threads...", - "Harmonizing Subspace Arrays...", - "Modulating Cybernetic Matrices...", - "Configuring Exo-Geometric Arrays...", - "Initializing Flux Capacitors...", - "Balancing Subatomic Resonance...", - "Fine-tuning Quantum Entanglement...", - "Matrixing Hyperdimensional Grids...", - "Coalescing Esoteric Code...", - "Syncopating Quantum Flux...", - "Reformatting Reality Lattice...", - "Fine-tuning Temporal Flux...", - "Syncing Cosmic Harmonics...", -]; - const searchRef = ref>(); const searchString = ref(""); @@ -205,11 +163,8 @@ const onSearch = (search: string) => { searchString.value = search.trim().toLocaleLowerCase(); }; -const canContribute = computed(() => - assetList.value.some((a) => a.canContribute), -); const canUpdate = computed( - () => Object.keys(assetStore.upgradeableModules).length > 0, + () => Object.keys(moduleStore.upgradeableModules).length !== 0, ); const categorizedAssets = computed(() => @@ -263,7 +218,7 @@ const categoryColor = (category: string) => { return "#000"; }; -const loadModules = async () => assetStore.LOAD_MODULES(); +const syncModules = async () => moduleStore.SYNC(); const newAsset = async (newAssetName: string) => { const result = await assetStore.CREATE_VARIANT(newAssetName); @@ -277,7 +232,7 @@ const newAsset = async (newAssetName: string) => { }; const updateAllAssets = () => { - Object.values(assetStore.upgradeableModules).forEach((module) => { + Object.values(moduleStore.upgradeableModules).forEach((module) => { moduleStore.INSTALL_REMOTE_MODULE(module.id); }); router.replace({ @@ -285,13 +240,10 @@ const updateAllAssets = () => { }); }; -const contributeAsset = () => contributeAssetModalRef.value?.open(); -const onExport = () => exportSuccessModalRef.value?.open(); - const filters = computed(() => [ assetList.value.filter((a) => a.canContribute), assetList.value.filter( - (a) => !!assetStore.upgradeableModules[a.schemaVariantId], + (a) => !!moduleStore.upgradeableModules[a.schemaVariantId], ), assetList.value.filter((a) => !a.isLocked), ]); diff --git a/app/web/src/components/CustomizeTabs.vue b/app/web/src/components/CustomizeTabs.vue index 21421dd3e6..643f6b38eb 100644 --- a/app/web/src/components/CustomizeTabs.vue +++ b/app/web/src/components/CustomizeTabs.vue @@ -11,7 +11,8 @@ @@ -31,11 +32,13 @@ import { PropType, ref } from "vue"; import { TabGroup, TabGroupItem, PillCounter } from "@si/vue-lib/design-system"; import { useFeatureFlagsStore } from "@/store/feature_flags.store"; import { useAssetStore } from "@/store/asset.store"; +import { useModuleStore } from "@/store/module.store"; const router = useRouter(); const route = useRoute(); const featureFlagsStore = useFeatureFlagsStore(); const assetStore = useAssetStore(); +const moduleStore = useModuleStore(); const group = ref>(); diff --git a/app/web/src/components/InstallAsset.vue b/app/web/src/components/InstallAsset.vue index 64772e8dfb..92321e5185 100644 --- a/app/web/src/components/InstallAsset.vue +++ b/app/web/src/components/InstallAsset.vue @@ -88,8 +88,8 @@ import { Icon, } from "@si/vue-lib/design-system"; import { useModuleStore, ModuleSpec } from "@/store/module.store"; -import { ModuleId } from "@/api/sdf/dal/schema"; import { nilId } from "@/utils/nilId"; +import { ModuleId } from "@/api/sdf/dal/module"; import TruncateWithTooltip from "./TruncateWithTooltip.vue"; import CodeEditor from "./CodeEditor.vue"; diff --git a/app/web/src/components/InstallAssetsPanel.vue b/app/web/src/components/InstallAssetsPanel.vue index 7957b25da0..be603ca1d4 100644 --- a/app/web/src/components/InstallAssetsPanel.vue +++ b/app/web/src/components/InstallAssetsPanel.vue @@ -1,8 +1,8 @@