Skip to content
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

feat(sdf): Add ability to set a module as private when contributing #5614

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions app/web/src/api/sdf/dal/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export interface ModuleContributeRequest {
name: string;
version: string;
schemaVariantId: SchemaVariantId;
isPrivateModule: boolean;
}
45 changes: 33 additions & 12 deletions app/web/src/components/AssetCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,32 @@
size="sm"
title="Contribution sent"
>
<p>
Thanks for contributing! We will review your contribution, and reach out
via email or on our
<a
class="text-action-500"
href="https://discord.com/invite/system-init"
target="_blank"
>Discord Server</a
>
if you have any questions.
</p>
<template v-if="isPrivateModuleContribution">
<p>
This module will be available on every workspace that you log into. If
you have any questions please reach out on our
<a
class="text-action-500"
href="https://discord.com/invite/system-init"
target="_blank"
>Discord Server</a
>
if you have any questions.
</p>
</template>
<template v-else>
<p>
Thanks for contributing! We will review your contribution, and reach
out via email or on our
<a
class="text-action-500"
href="https://discord.com/invite/system-init"
target="_blank"
>Discord Server</a
>
if you have any questions.
</p>
</template>
</Modal>
</div>
</template>
Expand Down Expand Up @@ -159,7 +174,12 @@ const contributeAssetModalRef =
const contributeAssetSuccessModalRef = ref<InstanceType<typeof Modal>>();

const contributeAsset = () => contributeAssetModalRef.value?.open();
const onContributeAsset = () => contributeAssetSuccessModalRef.value?.open();
const onContributeAsset = (isPrivate: boolean) => {
isPrivateModuleContribution.value = isPrivate;
contributeAssetSuccessModalRef.value?.open();
};

const isPrivateModuleContribution = ref(false);

const contributeRequest = computed((): ModuleContributeRequest | null => {
if (asset.value) {
Expand All @@ -168,6 +188,7 @@ const contributeRequest = computed((): ModuleContributeRequest | null => {
name: `${asset.value.schemaName} ${version}`,
version,
schemaVariantId: asset.value.schemaVariantId,
isPrivateModule: false, // This is the default value - we don't want to default to private modules!
};
} else return null;
});
Expand Down
69 changes: 51 additions & 18 deletions app/web/src/components/AssetContributeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,39 @@
v-if="contributeModuleReqStatus.isError"
:requestStatus="contributeModuleReqStatus"
/>
<p>
Everything you contribute will receive a code review, and we will reach
out if we have any questions or concerns. Assuming things look good, we
will then include your asset in a future version of System Initiative!
</p>
<p>
By clicking the 'Contribute to System Initiative' button, you agree to
license any code submitted under the terms of the
<a
class="text-action-500"
href="https://www.apache.org/licenses/LICENSE-2.0"
>Apache License, Version 2.0</a
>, and that you intend for System Initiative, Inc. to distribute it.
</p>
<template
v-if="isPrivateModule && featureFlagsStore.PRIVATE_SCOPED_MODULES"
>
<p>
By clicking the 'Contribute to System Initiative' button, you confirm
this is a private module. System Initiative will not distribute
private modules.
</p>
</template>
<template v-else>
<p>
Everything you contribute will receive a code review, and we will
reach out if we have any questions or concerns. Assuming things look
good, we will then include your asset in a future version of System
Initiative!
</p>
<p>
By clicking the 'Contribute to System Initiative' button, you agree to
license any code submitted under the terms of the
<a
class="text-action-500"
href="https://www.apache.org/licenses/LICENSE-2.0"
>Apache License, Version 2.0</a
>, and that you intend for System Initiative, Inc. to distribute it.
</p>
</template>

<VormInput
v-if="featureFlagsStore.PRIVATE_SCOPED_MODULES"
v-model="isPrivateModule"
type="checkbox"
>This is a private module
</VormInput>
<VButton
:disabled="!enableContributeButton"
:loadingText="_.sample(contributeLoadingTexts)"
Expand All @@ -47,18 +66,25 @@ import {
useModal,
Stack,
ErrorMessage,
VormInput,
} from "@si/vue-lib/design-system";
import * as _ from "lodash-es";
import { useModuleStore } from "@/store/module.store";
import { useFeatureFlagsStore } from "@/store/feature_flags.store";
import { ModuleContributeRequest } from "@/api/sdf/dal/module";

const moduleStore = useModuleStore();
const featureFlagsStore = useFeatureFlagsStore();
const modalRef = ref<InstanceType<typeof Modal>>();
const contributeModuleReqStatus = moduleStore.getRequestStatus("CONTRIBUTE");

const props = defineProps<{ contributeRequest: ModuleContributeRequest }>();

const emits = defineEmits(["contributeSuccess"]);
const emits = defineEmits<{
(e: "contributeSuccess", isPrivate: boolean): void;
}>();

const isPrivateModule = ref(false);

const contributeLoadingTexts = [
"Engaging Photon Torpedos...",
Expand All @@ -84,7 +110,10 @@ const contributeLoadingTexts = [
];

const { open: openModal, close } = useModal(modalRef);
const open = () => openModal();
const open = () => {
isPrivateModule.value = false;
openModal();
};

const isOpen = computed(() => modalRef.value?.isOpen);

Expand All @@ -95,9 +124,13 @@ const enableContributeButton = computed(() => {
});

const contributeAssets = async () => {
const result = await moduleStore.CONTRIBUTE(props.contributeRequest);
const updatedRequest = {
...props.contributeRequest,
isPrivateModule: isPrivateModule.value || false,
};
const result = await moduleStore.CONTRIBUTE(updatedRequest);
if (result.result.success) {
emits("contributeSuccess");
emits("contributeSuccess", updatedRequest.isPrivateModule);
close();
await moduleStore.LOAD_LOCAL_MODULES();
}
Expand Down
1 change: 1 addition & 0 deletions app/web/src/store/feature_flags.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const FLAG_MAPPING = {
DIAGRAM_OPTIMIZATION: "diagram-optimization",
DIAGRAM_OPTIMIZATION_2: "diagram-optimization-2",
AUTOCONNECT: "autoconnect-component-input-sockets",
PRIVATE_SCOPED_MODULES: "private-scoped-modules",
};

const WORKSPACE_FLAG_MAPPING = {
Expand Down
1 change: 1 addition & 0 deletions app/web/src/store/module.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export const useModuleStore = () => {
name: request.name,
version: request.version,
schemaVariantId: request.schemaVariantId,
isPrivateModule: request.isPrivateModule,
},
});
},
Expand Down
Loading