From c90233ff495d7a38a3a2af82e6e7f0a4c0e034b6 Mon Sep 17 00:00:00 2001 From: Vardan Bansal Date: Wed, 30 Aug 2023 14:10:15 +0530 Subject: [PATCH] Added Run pipeline drawer --- web/src/framework/strings/stringTypes.ts | 3 + web/src/i18n/strings.en.yaml | 3 + .../pages/NewPipeline/NewPipeline.module.scss | 4 + .../NewPipeline/NewPipeline.module.scss.d.ts | 1 + web/src/pages/NewPipeline/NewPipeline.tsx | 116 +++++++++++------- .../pages/NewPipeline/NewPipelineModal.tsx | 4 +- 6 files changed, 84 insertions(+), 47 deletions(-) diff --git a/web/src/framework/strings/stringTypes.ts b/web/src/framework/strings/stringTypes.ts index 6c470add8..d3e42e786 100644 --- a/web/src/framework/strings/stringTypes.ts +++ b/web/src/framework/strings/stringTypes.ts @@ -184,6 +184,7 @@ export interface StringsMap { failedToCreateSpace: string failedToDeleteBranch: string failedToDeleteWebhook: string + failedToSavePipeline: string fileDeleted: string fileTooLarge: string files: string @@ -322,6 +323,7 @@ export interface StringsMap { 'pipelines.name': string 'pipelines.newPipelineButton': string 'pipelines.noData': string + 'pipelines.run': string 'pipelines.saveAndRun': string 'pipelines.yamlPath': string 'pr.ableToMerge': string @@ -456,6 +458,7 @@ export interface StringsMap { reviewerNotFound: string reviewers: string role: string + run: string running: string samplePayloadUrl: string save: string diff --git a/web/src/i18n/strings.en.yaml b/web/src/i18n/strings.en.yaml index 94ff817da..21d1c03aa 100644 --- a/web/src/i18n/strings.en.yaml +++ b/web/src/i18n/strings.en.yaml @@ -587,6 +587,7 @@ spaceMemberships: memberAdded: Member added successfully. failedToCreateSpace: Failed to create Space. Please try again. failedToCreatePipeline: Failed to create Pipeline. Please try again. +failedToSavePipeline: Failed to save Pipeline. Please try again. enterName: Enter the name createASpace: Create a space createSpace: Create Space @@ -633,6 +634,7 @@ pipelines: failedToCreatePipeline: Failed to create pipeline saveAndRun: Save and Run editPipeline: Edit pipeline {{pipeline}} + run: Run pipeline executions: noData: There are no executions :( newExecutionButton: New Execution @@ -648,3 +650,4 @@ secrets: value: Secret Value createSecret: Create Secret userUpdateSuccess: 'User updated successfully' +run: Run diff --git a/web/src/pages/NewPipeline/NewPipeline.module.scss b/web/src/pages/NewPipeline/NewPipeline.module.scss index 9036d1937..14732cf6f 100644 --- a/web/src/pages/NewPipeline/NewPipeline.module.scss +++ b/web/src/pages/NewPipeline/NewPipeline.module.scss @@ -23,3 +23,7 @@ .breadcrumb { align-items: center; } + +.drawer { + height: calc(100% - 40px); +} diff --git a/web/src/pages/NewPipeline/NewPipeline.module.scss.d.ts b/web/src/pages/NewPipeline/NewPipeline.module.scss.d.ts index 61a9f2b03..b2aaad19f 100644 --- a/web/src/pages/NewPipeline/NewPipeline.module.scss.d.ts +++ b/web/src/pages/NewPipeline/NewPipeline.module.scss.d.ts @@ -6,5 +6,6 @@ declare const styles: { readonly editorContainer: string readonly header: string readonly breadcrumb: string + readonly drawer: string } export default styles diff --git a/web/src/pages/NewPipeline/NewPipeline.tsx b/web/src/pages/NewPipeline/NewPipeline.tsx index 89dcc9306..7a81dd9f3 100644 --- a/web/src/pages/NewPipeline/NewPipeline.tsx +++ b/web/src/pages/NewPipeline/NewPipeline.tsx @@ -1,7 +1,8 @@ import React, { useState } from 'react' import { useMutate } from 'restful-react' import { Link, useParams } from 'react-router-dom' -import { Container, PageHeader, PageBody, Button, Layout, ButtonVariation, Text } from '@harnessio/uicore' +import { Drawer } from '@blueprintjs/core' +import { Container, PageHeader, PageBody, Button, Layout, ButtonVariation, Text, useToaster } from '@harnessio/uicore' import { Icon } from '@harnessio/icons' import { Color } from '@harnessio/design-system' import type { OpenapiCommitFilesRequest, RepoCommitFilesResponse } from 'services/code' @@ -10,6 +11,7 @@ import { useGetSpaceParam } from 'hooks/useGetSpaceParam' import { SourceCodeEditor } from 'components/SourceCodeEditor/SourceCodeEditor' import { useAppContext } from 'AppContext' import type { CODEProps } from 'RouteDefinitions' +import { getErrorMessage } from 'utils/Utils' import css from './NewPipeline.module.scss' @@ -18,7 +20,9 @@ const NewPipeline = (): JSX.Element => { const { getString } = useStrings() const { pipeline } = useParams() const space = useGetSpaceParam() + const { showError } = useToaster() const [pipelineAsYAML, setPipelineAsYaml] = useState('') + const [showDrawer, setShowDrawer] = useState(false) const { mutate, loading } = useMutate({ verb: 'POST', @@ -26,56 +30,78 @@ const NewPipeline = (): JSX.Element => { }) const handleSaveAndRun = (): void => { - const data: OpenapiCommitFilesRequest = { - actions: [{ action: 'CREATE', path: `sample_${new Date().getTime()}.txt`, payload: pipelineAsYAML }], - branch: 'main', - new_branch: '', - title: `Create pipeline ${pipeline}`, - message: '' - } + try { + const data: OpenapiCommitFilesRequest = { + actions: [{ action: 'CREATE', path: `sample_${new Date().getTime()}.txt`, payload: pipelineAsYAML }], + branch: 'main', + new_branch: '', + title: `Create pipeline ${pipeline}`, + message: '' + } - mutate(data) - .then(response => console.log(response)) - .catch(error => console.log(error)) + mutate(data) + .then(() => setShowDrawer(true)) + .catch(error => { + showError(getErrorMessage(error), 0, 'pipelines.failedToSavePipeline') + }) + } catch (exception) { + showError(getErrorMessage(exception), 0, 'pipelines.failedToCreatePipeline') + } } return ( - - - - {getString('pageTitle.pipelines')} - - {pipeline} + <> + {showDrawer && ( + setShowDrawer(false)}> + + +