Skip to content

Commit 97dd535

Browse files
authored
Display imported gateways in project settings UI (#3893)
1 parent 417000b commit 97dd535

8 files changed

Lines changed: 21 additions & 4 deletions

File tree

frontend/src/locale/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
"empty_message_text": "No gateways to display.",
138138

139139
"edit": {
140+
"name": "Name",
140141
"backend": "Backend",
141142
"backend_description": "Select a backend",
142143
"region": "Region",

frontend/src/pages/Project/Details/Settings/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ export const ProjectSettings: React.FC = () => {
460460
: {})}
461461
/>
462462

463-
<GatewaysTable gateways={gatewaysData} />
463+
<GatewaysTable gateways={gatewaysData} projectName={paramProjectName} />
464464

465465
<ProjectMembers
466466
onChange={debouncedMembersHandler}

frontend/src/pages/Project/Gateways/Table/hooks/useColumnsDefinitions.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,25 @@ import styles from '../styles.module.scss';
88

99
type hookArgs = {
1010
loading?: boolean;
11+
projectName: string;
1112
onDeleteClick?: (gateway: IGateway) => void;
1213
onEditClick?: (gateway: IGateway) => void;
1314
};
1415

15-
export const useColumnsDefinitions = ({ loading, onDeleteClick, onEditClick }: hookArgs) => {
16+
export const useColumnsDefinitions = ({ loading, projectName, onDeleteClick, onEditClick }: hookArgs) => {
1617
const { t } = useTranslation();
1718

1819
const columns = useMemo(() => {
1920
return [
21+
{
22+
id: 'name',
23+
header: t('gateway.edit.name'),
24+
cell: (gateway: IGateway) =>
25+
gateway.project_name && gateway.project_name !== projectName
26+
? `${gateway.project_name}/${gateway.name}`
27+
: gateway.name,
28+
},
29+
2030
{
2131
id: 'type',
2232
header: t('gateway.edit.backend'),
@@ -76,7 +86,7 @@ export const useColumnsDefinitions = ({ loading, onDeleteClick, onEditClick }: h
7686
),
7787
},
7888
];
79-
}, [loading, onEditClick, onDeleteClick]);
89+
}, [loading, projectName, onEditClick, onDeleteClick]);
8090

8191
return { columns } as const;
8292
};

frontend/src/pages/Project/Gateways/Table/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useColumnsDefinitions } from './hooks';
1010

1111
import { IProps } from './types';
1212

13-
export const GatewaysTable: React.FC<IProps> = ({ gateways, addItem, deleteItem, editItem, isDisabledDelete }) => {
13+
export const GatewaysTable: React.FC<IProps> = ({ gateways, projectName, addItem, deleteItem, editItem, isDisabledDelete }) => {
1414
const { t } = useTranslation();
1515
const [openHelpPanel] = useHelpPanel();
1616

@@ -41,6 +41,7 @@ export const GatewaysTable: React.FC<IProps> = ({ gateways, addItem, deleteItem,
4141
};
4242

4343
const { columns } = useColumnsDefinitions({
44+
projectName,
4445
...(editItem ? { onEditClick: (gateway) => editItem(gateway) } : {}),
4546
...(deleteItem ? { onDeleteClick: (gateway) => deleteItem([gateway]) } : {}),
4647
});

frontend/src/pages/Project/Gateways/Table/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export interface IProps {
22
gateways: IGateway[];
3+
projectName: string;
34
addItem?: () => void;
45
deleteItem?: (gateways: readonly IGateway[] | IGateway[]) => void;
56
editItem?: (gateways: IGateway) => void;

frontend/src/pages/Project/Gateways/hooks/useGatewaysTable.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export const useGatewaysTable = (projectName: IProject['project_name']) => {
88
const { data, isLoading } = useGetProjectGatewaysQuery({ projectName });
99
const [deleteGatewayRequest, { isLoading: isDeleting }] = useDeleteProjectGatewayMutation();
1010

11+
// NOTE: editing and deletion are disabled as of 0.20.21.
12+
// If enabling, ensure that imported gateways cannot be edited or deleted.
1113
const editGateway = (gateway: IGateway) => {
1214
navigate(ROUTES.PROJECT.GATEWAY.EDIT.FORMAT(projectName, gateway.name));
1315
};

frontend/src/services/gateway.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const gatewayApi = createApi({
1717
query: ({ projectName }) => ({
1818
url: API.PROJECT_GATEWAYS.LIST(projectName),
1919
method: 'POST',
20+
body: { include_imported: true },
2021
}),
2122

2223
providesTags: (result) =>

frontend/src/types/gateway.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
declare interface IGateway {
22
backend: string,
33
name: string,
4+
project_name?: string,
45
ip_address: string,
56
instance_id: string,
67
region:string

0 commit comments

Comments
 (0)