Commit 991fcce4 authored by Ryo Yamashita's avatar Ryo Yamashita Committed by Yas Naoi
Browse files

Issue #3308490 by Ryo Yamashita, yas: Add a Refresh button in the launch template list view of SPA

parent 3920c70c
Loading
Loading
Loading
Loading
+25 −1
Changes for modules/cloud_dashboard/cloud_dashboard/src/pages/CloudServerTemplatePage.tsx: 25 added lines, 1 removed line.
Original line number Diff line number Diff line
import { ROUTE_URL } from 'constant/other';
import CloudServiceProvider from 'model/CloudServiceProvider';
import LaunchTemplateTable from 'organisms/LaunchTemplateTable';
import SideBar from 'organisms/SideBar';
import { Col, Container, Form, Row } from 'react-bootstrap';
import { Button, Col, Container, Form, Row } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';

const CloudServerTemplatePage = () => {
@@ -10,12 +12,34 @@ const CloudServerTemplatePage = () => {
    cloudContext?: string,
  } = useParams();

  const { t } = useTranslation();

  const refresh = () => {
    const url = params.cloudContext !== undefined
      ? `/clouds/design/server_template/${params.cloudContext}/update`
      : `/clouds/design/${params.cloudServiceProvider}/server_template/update`;

    fetch(url, { method: 'POST' }).then((response) => {
      if (!response.ok) {
        return;
      }
      window.location.href = params.cloudContext !== undefined
        ? `${ROUTE_URL}/${params.cloudServiceProvider}/${params.cloudContext}/server_template`
        : `${ROUTE_URL}/${params.cloudServiceProvider}/server_template`;
    });
  }

  return <>
    <SideBar />
    <Container fluid className="px-0">
      <Row className="mx-0">
        <Col>
          <Form>
            <Form.Group style={{ marginBottom: '2rem' }}>
              <Button onClick={refresh}>
                {t('Refresh')}
              </Button>
            </Form.Group>
            <LaunchTemplateTable cloudContext={{
              cloudServiceProvider: params.cloudServiceProvider as CloudServiceProvider,
              name: params.cloudContext === undefined ? 'ALL' : params.cloudContext,