• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / d-installer / 4512499803

pending completion
4512499803

Pull #501

github

Unknown Committer
Unknown Commit Message
Pull Request #501: [web] Add DASD UI - first version

462 of 863 branches covered (53.53%)

Branch coverage included in aggregate %.

64 of 235 new or added lines in 9 files covered. (27.23%)

14 existing lines in 1 file now uncovered.

4668 of 6129 relevant lines covered (76.16%)

10.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.63
/web/src/components/storage/ProposalPage.jsx
1
/*
2
 * Copyright (c) [2022-2023] SUSE LLC
3
 *
4
 * All Rights Reserved.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it
7
 * under the terms of version 2 of the GNU General Public License as published
8
 * by the Free Software Foundation.
9
 *
10
 * This program is distributed in the hope that it will be useful, but WITHOUT
11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13
 * more details.
14
 *
15
 * You should have received a copy of the GNU General Public License along
16
 * with this program; if not, contact SUSE LLC.
17
 *
18
 * To contact SUSE LLC about this file by physical or electronic mail, you may
19
 * find current contact information at www.suse.com.
20
 */
21

22
import React, { useCallback, useReducer, useEffect, useState } from "react";
23
import { Alert } from "@patternfly/react-core";
24
import { Link } from "react-router-dom";
25

26
import { useInstallerClient } from "~/context/installer";
27
import { useCancellablePromise } from "~/utils";
28
import { Icon } from "~/components/layout";
29
import { Page, PageOptions, SectionSkeleton } from "~/components/core";
30
import {
31
  ProposalTargetSection,
32
  ProposalSettingsSection,
33
  ProposalActionsSection
34
} from "~/components/storage";
35

36
const initialState = {
14✔
37
  loading: false,
38
  proposal: undefined,
39
  errors: []
40
};
41

42
const reducer = (state, action) => {
14✔
43
  switch (action.type) {
15!
44
    case "UPDATE_LOADING" : {
45
      const { loading } = action.payload;
10✔
46
      return { ...state, loading };
10✔
47
    }
48

49
    case "UPDATE_PROPOSAL": {
50
      const { proposal, errors } = action.payload;
5✔
51
      return { ...state, proposal, errors };
5✔
52
    }
53

54
    default: {
55
      return state;
×
56
    }
57
  }
58
};
59

60
export default function ProposalPage() {
61
  const { storage: client } = useInstallerClient();
10✔
62
  const { cancellablePromise } = useCancellablePromise();
10✔
63
  const [state, dispatch] = useReducer(reducer, initialState);
10✔
64

65
  const loadProposal = useCallback(async (hooks = {}) => {
10✔
66
    dispatch({ type: "UPDATE_LOADING", payload: { loading: true } });
5✔
67

68
    if (hooks.before !== undefined) await cancellablePromise(hooks.before());
5✔
69
    const proposal = await cancellablePromise(client.proposal.getData());
5✔
70
    const errors = await cancellablePromise(client.getValidationErrors());
5✔
71

72
    dispatch({ type: "UPDATE_PROPOSAL", payload: { proposal, errors } });
5✔
73
    dispatch({ type: "UPDATE_LOADING", payload: { loading: false } });
5✔
74
  }, [client, cancellablePromise]);
75

76
  useEffect(() => {
10✔
77
    const probeAndLoad = async () => {
4✔
78
      await loadProposal({ before: () => client.probe() });
×
79
    };
80

81
    const load = async () => {
4✔
82
      const isDeprecated = await cancellablePromise(client.isDeprecated());
4✔
83
      isDeprecated ? probeAndLoad() : loadProposal();
4!
84
    };
85

86
    load().catch(console.error);
4✔
87

88
    return client.onDeprecate(() => probeAndLoad());
4✔
89
  }, [client, cancellablePromise, loadProposal]);
90

91
  const calculateProposal = async (settings) => {
10✔
92
    const calculate = async () => {
1✔
93
      await client.proposal.calculate({ ...state.proposal.result, ...settings });
1✔
94
    };
95

96
    loadProposal({ before: calculate }).catch(console.error);
1✔
97
  };
98

99
  const PageContent = () => {
10✔
100
    if (state.loading || state.proposal?.result === undefined) return <SectionSkeleton lines={3} />;
10✔
101

102
    return (
4✔
103
      <>
104
        <Alert
105
          isInline
106
          customIcon={<Icon name="info" size="16" />}
107
          title="Devices will not be modified until installation starts."
108
        />
109
        <ProposalTargetSection
110
          proposal={state.proposal}
111
          calculateProposal={calculateProposal}
112
        />
113
        <ProposalSettingsSection
114
          proposal={state.proposal}
115
          calculateProposal={calculateProposal}
116
        />
117
        <ProposalActionsSection
118
          proposal={state.proposal}
119
          errors={state.errors}
120
        />
121
      </>
122
    );
123
  };
124

125
  const DASDLink = () => {
10✔
NEW
126
    const [show, setShow] = useState(false);
×
127

NEW
128
    useEffect(() => {
×
NEW
129
      client.dasd.isSupported().then(setShow);
×
130
    }, []);
131

NEW
132
    if (!show) return null;
×
133

NEW
134
    return (
×
135
      <Link to="/storage/dasd">
136
        <Icon name="settings" size="24" />
137
        Configure DASD
138
      </Link>
139
    );
140
  };
141

142
  return (
10✔
143
    <Page title="Storage" icon="hard_drive" actionLabel="Back" actionVariant="secondary">
144
      <PageContent />
145
      <PageOptions title="Storage">
146
        <DASDLink />
147
        <Link to="/storage/iscsi">
148
          <Icon name="settings" size="24" />
149
          Configure iSCSI
150
        </Link>
151
      </PageOptions>
152
    </Page>
153
  );
154
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc