Skip to content

Fix classes release#681

Merged
themaherkhalil merged 2 commits intodevfrom
fix-classes-release
Mar 8, 2025
Merged

Fix classes release#681
themaherkhalil merged 2 commits intodevfrom
fix-classes-release

Conversation

@themaherkhalil
Copy link
Copy Markdown
Contributor

No description provided.

@themaherkhalil themaherkhalil requested a review from a team as a code owner March 8, 2025 02:54
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2025

@CodiumAI-Agent /describe

@QodoAI-Agent
Copy link
Copy Markdown

Title

Fix classes release


PR Type

  • Bug fix

Description

  • Updated CLI deploy commands with named project parameter.

  • Ensured consistent release flag usage in queries.

  • Fixed string command formatting in AppSettings component.


Changes walkthrough 📝

Relevant files
Bug fix
deploy.ts
Update CLI deploy command strings for proper release.       

packages/cli/src/commands/deploy.ts

  • Updated ReloadInsightClasses call to use project parameter.
  • Modified PublishProject query with project assignment.
  • +2/-2     
    AppSettings.tsx
    Fix AppSettings query strings for release handling.           

    packages/client/src/components/app/AppSettings.tsx

  • Revised portal detail queries formatting.
  • Updated ReloadInsightClasses and PublishProject query strings.
  • Standardized release flag and project parameter across functions.
  • +9/-11   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link
    Copy Markdown

    github-actions bot commented Mar 8, 2025

    @CodiumAI-Agent /review

    @github-actions
    Copy link
    Copy Markdown

    github-actions bot commented Mar 8, 2025

    @CodiumAI-Agent /improve

    @QodoAI-Agent
    Copy link
    Copy Markdown

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Consistency

    The new queries now include named parameters (e.g. project and release) which differ from the previous format. Ensure that the updated command string format is consistently applied throughout the codebase.

                `ReloadInsightClasses(project='${Env.APP}', release=true);`,
            );
    
            return true;
        },
    },
    {
        title: 'Publishing App',
        task: async (context) => {
            // Publish the app
            const { pixelReturn } = await insight.actions.run<[string]>(
                `PublishProject(project='${Env.APP}', release=true);`,
    Input Sanitization

    Dynamic insertion of variables (like ${id}) into command strings can pose injection risks if the input is not properly sanitized. Verify that these values are validated before use.

            ? `AdminGetProjectPortalDetails('${id}');`
            : `GetProjectPortalDetails('${id}');`,
    );
    
    useEffect(() => {
        if (getPortalDetails.status !== 'SUCCESS') {
            return;
        }
    
        // Set Details for Portal
        setPortalDetails({
            ...getPortalDetails.data,
        });
    
        // Get the portal reactors if we have a portal
        if (getPortalDetails.data.project_has_portal) {
            getPortalReactors();
        }
    }, [getPortalDetails.status, getPortalDetails.data]);
    
    /** LOADING */
    if (getPortalDetails.status !== 'SUCCESS') {
        return (
            <LoadingScreen.Trigger description="Getting app portal details" />
        );
    }
    
    /**
     * @name getPortalReactors
     */
    const getPortalReactors = () => {
        const pixelString = adminMode
            ? `AdminGetProjectAvailableReactors(project=['${id}']);`
            : `GetProjectAvailableReactors(project=['${id}']);`;
    
        monolithStore
            .runQuery(pixelString)
            .then((response) => {
                let output = undefined;
                let type = undefined;
    
                output = response.pixelReturn[0].output;
                type = response.pixelReturn[0].operationType[0];
    
                if (type.indexOf('ERROR') > -1) {
                    notification.add({
                        color: 'error',
                        message: output,
                    });
    
                    return;
                }
    
                setPortalReactors({
                    ...portalReactors,
                    reactors: output,
                });
            })
            .catch((error) => {
                notification.add({
                    color: 'error',
                    message: error,
                });
            });
    };
    
    /**
     * @name recompileReactors
     */
    const recompileReactors = ({ release }) => {
        let pixelString;
        if (release == null) {
            pixelString = `ReloadInsightClasses(project='${id}');`;
        } else {
            pixelString = `ReloadInsightClasses(project='${id}', release=true);`;
        }
    
        monolithStore
            .runQuery(pixelString)
            .then((response) => {
                let output = undefined;
                let type = undefined;
    
                output = response.pixelReturn[0].output;
                type = response.pixelReturn[0].operationType[0];
    
                if (type.indexOf('ERROR') > -1) {
                    notification.add({
                        color: 'error',
                        message: output,
                    });
                    return;
                }
    
                if (release == null) {
                    notification.add({
                        color: 'success',
                        message: 'Successfully recompiled',
                    });
                } else {
                    notification.add({
                        color: 'success',
                        message: 'Successfully redeployed',
                    });
                }
            })
            .catch((error) => {
                notification.add({
                    color: 'error',
                    message: error,
                });
            });
    };
    
    /**
     * @name publish
     * @desc Publishes Portal
     */
    const publish = () => {
        const pixelString = `PublishProject(project='${id}', release=true);`;
    
        monolithStore
            .runQuery(pixelString)
            .then((response) => {
                let output = undefined;
                let type = undefined;
    
                output = response.pixelReturn[0].output;
                type = response.pixelReturn[0].operationType[0];
    
                if (type.indexOf('ERROR') > -1) {
                    notification.add({
                        color: 'error',
                        message: output,
                    });
    
                    return;
                }
    
                setPortalDetails({
                    ...portalDetails,
                    project_portal_url: output,
                });
    
                notification.add({
                    color: 'success',
                    message: 'Successfully published',
                });
            })
            .catch((error) => {
                notification.add({
                    color: 'error',
                    message: error,
                });
            });
    };
    
    /**
     * @name enablePublishing
     */
    const enablePublishing = () => {
        monolithStore
            .setProjectPortal(admin, id, !portalDetails.project_has_portal)
            .then((resp) => {
                if (resp.data) {
                    setPortalDetails({
                        ...portalDetails,
                        project_has_portal: !portalDetails.project_has_portal,
                    });
    
                    notification.add({
                        color: 'success',
                        message: `Successfully ${
                            !portalDetails.project_has_portal
                                ? 'enabled'
                                : 'disabled'
                        } portal`,
                    });
                } else {
                    notification.add({
                        color: 'error',
                        message: `Unsuccessfully ${
                            !portalDetails.project_has_portal
                                ? 'disabled'
                                : 'enabled'
                        } portal`,
                    });
                }
            })
            .catch((error) => {
                notification.add({
                    color: 'error',
                    message: error,
                });
            });
    };
    
    /**
     * @name editApp
     */
    const editApp = handleSubmit(async (data: EditAppForm) => {
        // turn on loading
        setIsLoading(true);
    
        try {
            const path = 'version/assets/';
    
            // unzip the file in the new app
            await monolithStore.runQuery(
                `DeleteAsset(filePath=["${path}"], space=["${id}"]);`,
            );
    
            // upload the file
            const upload = await monolithStore.uploadFile(
                [data.PROJECT_UPLOAD],
                configStore.store.insightID,
                id,
                path,
            );
    
            // upnzip the file in the new app
            await monolithStore.runQuery(
                `UnzipFile(filePath=["${`${path}${upload[0].fileName}`}"], space=["${id}"]);`,
            );
    
            // Load the insight classes
            await monolithStore.runQuery(
                `ReloadInsightClasses(project='${id}', release=true);`,
            );
    
            // set the app portal
            await monolithStore.setProjectPortal(false, id, true, 'public');
    
            // Publish the app the insight classes
            await monolithStore.runQuery(
                `PublishProject(project='${id}', release=true);`,
            );

    @QodoAI-Agent
    Copy link
    Copy Markdown

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @themaherkhalil themaherkhalil merged commit 6a2be82 into dev Mar 8, 2025
    4 checks passed
    @themaherkhalil themaherkhalil deleted the fix-classes-release branch March 8, 2025 03:11
    @github-actions
    Copy link
    Copy Markdown

    github-actions bot commented Mar 8, 2025

    @CodiumAI-Agent /update_changelog

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants