Skip to content
Merged
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
11 changes: 10 additions & 1 deletion config-ui/src/api/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ export const test = (
payload?: Partial<
Pick<
IConnectionAPI,
'endpoint' | 'authMethod' | 'username' | 'password' | 'token' | 'appId' | 'secretKey' | 'proxy' | 'dbUrl'
| 'endpoint'
| 'authMethod'
| 'username'
| 'password'
| 'token'
| 'appId'
| 'secretKey'
| 'proxy'
| 'dbUrl'
| 'companyId'
>
>,
): Promise<IConnectionTestResult> =>
Expand Down
17 changes: 0 additions & 17 deletions config-ui/src/plugins/components/connection-form/fields/token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@
* limitations under the License.
*
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import { useEffect } from 'react';
import { Input } from 'antd';
Expand Down
2 changes: 2 additions & 0 deletions config-ui/src/plugins/components/connection-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const ConnectionForm = ({ plugin, connectionId, onSuccess }: Props) => {
secretKey: isEqual(connection?.secretKey, values.secretKey) ? undefined : values.secretKey,
proxy: isEqual(connection?.proxy, values.proxy) ? undefined : values.proxy,
dbUrl: isEqual(connection?.dbUrl, values.dbUrl) ? undefined : values.dbUrl,
companyId: isEqual(connection?.companyId, values.companyId) ? undefined : values.companyId,
})
: API.connection.testOld(
plugin,
Expand All @@ -87,6 +88,7 @@ export const ConnectionForm = ({ plugin, connectionId, onSuccess }: Props) => {
'tenantId',
'tenantType',
'dbUrl',
'companyId',
]),
),
{
Expand Down
1 change: 1 addition & 0 deletions config-ui/src/plugins/register/github/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const GitHubConfig: IPluginConfig = {
],
},
dataScope: {
localSearch: true,
title: 'Repositories',
millerColumn: {
columnCount: 2,
Expand Down
17 changes: 15 additions & 2 deletions config-ui/src/plugins/register/tapd/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ExternalLink } from '@/components';
import { DOC_URL } from '@/release';
import { IPluginConfig } from '@/types';

import { DataScope } from './data-scope';
import { CompanyId } from './connection-fields';
import Icon from './assets/icon.svg?react';

export const TAPDConfig: IPluginConfig = {
Expand Down Expand Up @@ -56,6 +56,16 @@ export const TAPDConfig: IPluginConfig = {
label: 'API Token',
placeholder: 'Your API Token',
},
({ initialValues, values, errors, setValues, setErrors }: any) => (
<CompanyId
key="companyId"
initialValue={initialValues.companyId}
value={values.companyId}
error={errors.companyId}
setValue={(value) => setValues({ companyId: value })}
setError={(error) => setErrors({ companyId: error })}
/>
),
'proxy',
{
key: 'rateLimitPerHour',
Expand All @@ -68,7 +78,10 @@ export const TAPDConfig: IPluginConfig = {
],
},
dataScope: {
render: ({ ...props }: any) => <DataScope {...props} />,
title: 'Workspaces',
millerColumn: {
columnCount: 2.5,
},
},
scopeConfig: {
entities: ['TICKET', 'CROSS'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

import { ChangeEvent, useEffect } from 'react';
import { Input } from 'antd';

import { Block } from '@/components';

interface Props {
initialValue: number;
value: number;
error: string;
setValue: (value: number) => void;
setError: (value: string) => void;
}

export const CompanyId = ({ initialValue, value, setValue, setError }: Props) => {
useEffect(() => {
setValue(initialValue);
}, [initialValue]);

useEffect(() => {
let error = '';

if (!value) {
error = 'company id is required';
} else if (!/\d/.test(value.toString())) {
error = 'company id is a number';
}

setError(error);
}, [value]);

const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
const value = +e.target.value;

if (typeof value === 'number' && !isNaN(value)) {
setValue(value);
}
};

return (
<Block title="Company ID" description="" required>
<Input style={{ width: 386 }} placeholder="Company ID" value={value} onChange={handleChange} />
</Block>
);
};
19 changes: 19 additions & 0 deletions config-ui/src/plugins/register/tapd/connection-fields/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

export * from './company-id';
128 changes: 0 additions & 128 deletions config-ui/src/plugins/register/tapd/data-scope.tsx

This file was deleted.

1 change: 0 additions & 1 deletion config-ui/src/plugins/register/tapd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
*/

export * from './config';
export * from './data-scope';
export * from './transformation';
2 changes: 2 additions & 0 deletions config-ui/src/types/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface IConnectionAPI {
secretKey?: string;
dbUrl?: string;
enableGraphql?: boolean;
companyId?: number;
proxy: string;
rateLimitPerHour?: number;
}
Expand Down Expand Up @@ -81,6 +82,7 @@ export interface IConnection {
secretKey?: string;
dbUrl?: string;
enableGraphql?: boolean;
companyId?: number;
proxy: string;
rateLimitPerHour?: number;
}