Skip to content

Commit

Permalink
fix:launchpad checkNetworkPorts (#4724)
Browse files Browse the repository at this point in the history
Signed-off-by: jingyang <3161362058@qq.com>
  • Loading branch information
zjy365 authored May 10, 2024
1 parent daff4ac commit bca8476
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ const AppMainInfo = ({ app = MOCK_APP_DETAIL }: { app: AppDetailType }) => {
</tr>
</thead>
<tbody>
{networks.map((network) => {
{networks.map((network, index) => {
return (
<tr key={network.inline}>
<tr key={network.inline + index}>
<th>
<Flex>
<MyTooltip label={t('Copy')} placement={'bottom-start'}>
Expand Down
15 changes: 11 additions & 4 deletions frontend/providers/applaunchpad/src/pages/app/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ const EditApp = ({ appName, tabType }: { appName?: string; tabType: string }) =>
setDefaultGpuSource(res.gpu);
formHook.reset(adaptEditAppData(res));
setAlready(true);
setYamlList(formData2Yamls(realTimeForm.current));
},
onError(err) {
toast({
Expand Down Expand Up @@ -388,10 +389,16 @@ export async function getServerSideProps(content: any) {
export default EditApp;

function checkNetworkPorts(networks: AppEditType['networks']) {
const ports = networks.map((item) => item.port);
const portSet = new Set(ports);
if (portSet.size !== ports.length) {
return false;
const portProtocolSet = new Set<string>();

for (const network of networks) {
const { port, protocol } = network;
const key = `${port}-${protocol}`;
if (portProtocolSet.has(key)) {
return false;
}
portProtocolSet.add(key);
}

return true;
}
4 changes: 3 additions & 1 deletion frontend/providers/applaunchpad/src/utils/adapt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ export const adaptAppDetail = (configs: DeployKindsType[]): AppDetailType => {
protocol:
(ingress?.metadata?.annotations?.[
'nginx.ingress.kubernetes.io/backend-protocol'
] as AppEditType['networks'][0]['protocol']) || 'HTTP',
] as AppEditType['networks'][0]['protocol']) ||
item?.protocol ||
'HTTP',
openPublicDomain: !!ingress,
...(domain.endsWith(SEALOS_DOMAIN)
? {
Expand Down

0 comments on commit bca8476

Please sign in to comment.