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
1 change: 1 addition & 0 deletions frontend/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"empty_message_text": "No gateways to display.",

"edit": {
"name": "Name",
"backend": "Backend",
"backend_description": "Select a backend",
"region": "Region",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Project/Details/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ export const ProjectSettings: React.FC = () => {
: {})}
/>

<GatewaysTable gateways={gatewaysData} />
<GatewaysTable gateways={gatewaysData} projectName={paramProjectName} />

<ProjectMembers
onChange={debouncedMembersHandler}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@ import styles from '../styles.module.scss';

type hookArgs = {
loading?: boolean;
projectName: string;
onDeleteClick?: (gateway: IGateway) => void;
onEditClick?: (gateway: IGateway) => void;
};

export const useColumnsDefinitions = ({ loading, onDeleteClick, onEditClick }: hookArgs) => {
export const useColumnsDefinitions = ({ loading, projectName, onDeleteClick, onEditClick }: hookArgs) => {
const { t } = useTranslation();

const columns = useMemo(() => {
return [
{
id: 'name',
header: t('gateway.edit.name'),
cell: (gateway: IGateway) =>
gateway.project_name && gateway.project_name !== projectName
? `${gateway.project_name}/${gateway.name}`
: gateway.name,
},

{
id: 'type',
header: t('gateway.edit.backend'),
Expand Down Expand Up @@ -76,7 +86,7 @@ export const useColumnsDefinitions = ({ loading, onDeleteClick, onEditClick }: h
),
},
];
}, [loading, onEditClick, onDeleteClick]);
}, [loading, projectName, onEditClick, onDeleteClick]);

return { columns } as const;
};
3 changes: 2 additions & 1 deletion frontend/src/pages/Project/Gateways/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useColumnsDefinitions } from './hooks';

import { IProps } from './types';

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

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

const { columns } = useColumnsDefinitions({
projectName,
...(editItem ? { onEditClick: (gateway) => editItem(gateway) } : {}),
...(deleteItem ? { onDeleteClick: (gateway) => deleteItem([gateway]) } : {}),
});
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/Project/Gateways/Table/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface IProps {
gateways: IGateway[];
projectName: string;
addItem?: () => void;
deleteItem?: (gateways: readonly IGateway[] | IGateway[]) => void;
editItem?: (gateways: IGateway) => void;
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/pages/Project/Gateways/hooks/useGatewaysTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const useGatewaysTable = (projectName: IProject['project_name']) => {
const { data, isLoading } = useGetProjectGatewaysQuery({ projectName });
const [deleteGatewayRequest, { isLoading: isDeleting }] = useDeleteProjectGatewayMutation();

// NOTE: editing and deletion are disabled as of 0.20.21.
// If enabling, ensure that imported gateways cannot be edited or deleted.
const editGateway = (gateway: IGateway) => {
navigate(ROUTES.PROJECT.GATEWAY.EDIT.FORMAT(projectName, gateway.name));
};
Expand Down
1 change: 1 addition & 0 deletions frontend/src/services/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const gatewayApi = createApi({
query: ({ projectName }) => ({
url: API.PROJECT_GATEWAYS.LIST(projectName),
method: 'POST',
body: { include_imported: true },
}),

providesTags: (result) =>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/gateway.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
declare interface IGateway {
backend: string,
name: string,
project_name?: string,
ip_address: string,
instance_id: string,
region:string
Expand Down
Loading