Skip to content

Commit

Permalink
[Backport release-1.6] Fix: guides the user to enable the vale-workfl…
Browse files Browse the repository at this point in the history
…ow addon (#627)

* Fix: guides the user to enable the vale-workflow addon

Signed-off-by: barnettZQG <[email protected]>
(cherry picked from commit c4245e6)

* Fix: component state property never read

Signed-off-by: barnettZQG <[email protected]>
(cherry picked from commit 35fccb0)

Co-authored-by: barnettZQG <[email protected]>
  • Loading branch information
github-actions[bot] and barnettZQG authored Oct 29, 2022
1 parent 2d49a97 commit fa4cbc0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 25 deletions.
15 changes: 4 additions & 11 deletions src/layout/TopBar/components/EditPlatFormUserDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component, Fragment } from 'react';
import { Grid, Form, Input, Field, Button, Message, Icon, Dialog } from '@b-design/ui';
import { Grid, Form, Input, Field, Message, Icon, Dialog } from '@b-design/ui';
import { updateUser } from '../../../../api/users';
import type { LoginUserInfo } from '../../../../interface/user';
import { checkUserPassword } from '../../../../utils/common';
Expand Down Expand Up @@ -63,15 +63,6 @@ class EditPlatFormUserDialog extends Component<Props, State> {
return i18n.t('Reset the password and email for the administrator account');
}

showClickButtons = () => {
const { isLoading } = this.state;
return [
<Button type="primary" onClick={this.onUpdateUser} loading={isLoading}>
{i18n.t('Update')}
</Button>,
];
};

handleClickLook = () => {
this.setState({
isLookPassword: !this.state.isLookPassword,
Expand All @@ -80,6 +71,7 @@ class EditPlatFormUserDialog extends Component<Props, State> {

render() {
const init = this.field.init;
const { isLoading } = this.state;
const { Row, Col } = Grid;
const FormItem = Form.Item;
const formItemLayout = {
Expand All @@ -95,12 +87,13 @@ class EditPlatFormUserDialog extends Component<Props, State> {
<Dialog
visible={true}
title={this.showTitle()}
className={'commonDialog'}
style={{ width: '600px' }}
onOk={this.onUpdateUser}
locale={locale().Dialog}
footerActions={['ok']}
>
<Form {...formItemLayout} field={this.field}>
<Form loading={isLoading} {...formItemLayout} field={this.field}>
<Row>
<Col span={24} style={{ padding: '0 8px' }}>
<FormItem label={<Translation>Password</Translation>} required>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CreatePipeline extends React.Component<PipelineProps, State> {
reader.readAsText(fileSelect);
reader.onload = () => {
this.field.setValues({
config: reader.result?.toString() || '',
steps: reader.result?.toString() || '',
});
};
return {
Expand Down
11 changes: 11 additions & 0 deletions src/pages/PipelineListPage/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,14 @@
}
}
}

.addon-notice {
display: flex;
align-content: center;
justify-content: center;
padding: 200px var(--spacing-8);
font-size: var(--font-size-large);
a {
margin: 0 var(--spacing-2);
}
}
39 changes: 26 additions & 13 deletions src/pages/PipelineListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ import CreatePipeline from './components/CreatePipeline';
import { beautifyTime, momentDate } from '../../utils/common';
import ClonePipeline from './components/PipelineClone';
import RunStatusIcon from '../PipelineRunPage/components/RunStatusIcon';
import type { AddonBaseStatus } from '../../interface/addon';

type Props = {
targets?: [];
envs?: [];
history: any;
userInfo?: LoginUserInfo;
dispatch: Dispatch<any>;
enabledAddons?: AddonBaseStatus[];
};

export type ShowMode = 'table' | 'card' | string | null;
Expand All @@ -48,7 +50,7 @@ type State = {
};

@connect((store: any) => {
return { ...store.user };
return { ...store.user, ...store.addons };
})
class PipelineListPage extends Component<Props, State> {
constructor(props: Props) {
Expand Down Expand Up @@ -342,6 +344,8 @@ class PipelineListPage extends Component<Props, State> {
showNewPipeline,
showClonePipeline,
} = this.state;
const { enabledAddons } = this.props;
const addonEnabled = enabledAddons?.filter((addon) => addon.name == 'vela-workflow').length;
return (
<div>
<Title
Expand All @@ -352,14 +356,16 @@ class PipelineListPage extends Component<Props, State> {
request={{ resource: 'project:?/pipeline:*', action: 'create' }}
project={'?'}
>
<Button
type="primary"
onClick={() => {
this.setState({ showNewPipeline: true });
}}
>
<Translation>New Pipeline</Translation>
</Button>
<If condition={addonEnabled}>
<Button
type="primary"
onClick={() => {
this.setState({ showNewPipeline: true });
}}
>
<Translation>New Pipeline</Translation>
</Button>
</If>
</Permission>,
]}
/>
Expand All @@ -377,10 +383,17 @@ class PipelineListPage extends Component<Props, State> {
this.getPipelines(params);
}}
/>

<Loading style={{ width: '100%' }} visible={isLoading}>
{this.renderPipelineTable()}
</Loading>
<If condition={addonEnabled}>
<Loading style={{ width: '100%' }} visible={isLoading}>
{this.renderPipelineTable()}
</Loading>
</If>
<If condition={!addonEnabled}>
<div className="addon-notice">
Please enable the <Link to="/addons/vela-workflow">vela-workflow</Link> Addon that
powers Pipeline.
</div>
</If>

<If condition={showRunPipeline}>
{pipeline && (
Expand Down

0 comments on commit fa4cbc0

Please sign in to comment.