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

inventree / InvenTree / 8604739077

08 Apr 2024 06:10PM CUT coverage: 91.825%. First build
8604739077

Pull #6978

github

web-flow
Merge 410171001 into 4adce85ef
Pull Request #6978: Bump docker/setup-buildx-action from 3.2.0 to 3.3.0

221 of 649 branches covered (34.05%)

Branch coverage included in aggregate %.

33252 of 35804 relevant lines covered (92.87%)

1.63 hits per line

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

8.11
/src/frontend/src/components/modals/AboutInvenTreeModal.tsx
1
import { Trans } from '@lingui/macro';
2
import {
3
  Anchor,
4
  Badge,
5
  Button,
6
  Divider,
7
  Group,
8
  Space,
9
  Stack,
10
  Table,
11
  Text,
12
  Title
13
} from '@mantine/core';
14
import { ContextModalProps } from '@mantine/modals';
15
import { useQuery } from '@tanstack/react-query';
16

17
import { api } from '../../App';
18
import { ApiEndpoints } from '../../enums/ApiEndpoints';
19
import { apiUrl, useServerApiState } from '../../states/ApiState';
20
import { useLocalState } from '../../states/LocalState';
21
import { useUserState } from '../../states/UserState';
22
import { CopyButton } from '../items/CopyButton';
23

24
type AboutLookupRef = {
25
  ref: string;
26
  title: JSX.Element;
27
  link?: string;
28
  copy?: boolean;
29
};
30

31
export function AboutInvenTreeModal({
3✔
32
  context,
33
  id
34
}: ContextModalProps<{
35
  modalBody: string;
36
}>) {
×
37
  const [user] = useUserState((state) => [state.user]);
×
38
  const { host } = useLocalState.getState();
×
39
  const [server] = useServerApiState((state) => [state.server]);
×
40

41
  if (user?.is_staff != true)
×
42
    return (
×
43
      <Text>
44
        <Trans>This information is only available for staff users</Trans>
45
      </Text>
46
    );
47

48
  const { isLoading, data } = useQuery({
3✔
49
    queryKey: ['version'],
50
    queryFn: () => api.get(apiUrl(ApiEndpoints.version)).then((res) => res.data)
×
51
  });
52

53
  function fillTable(
54
    lookup: AboutLookupRef[],
55
    data: any,
56
    alwaysLink: boolean = false
×
57
  ) {
58
    return lookup.map((map: AboutLookupRef, idx) => (
×
59
      <tr key={idx}>
×
60
        <td>{map.title}</td>
61
        <td>
62
          <Group position="apart" spacing="xs">
63
            {alwaysLink ? (
×
64
              <Anchor href={data[map.ref]} target="_blank">
65
                {data[map.ref]}
66
              </Anchor>
67
            ) : map.link ? (
×
68
              <Anchor href={map.link} target="_blank">
69
                {data[map.ref]}
70
              </Anchor>
71
            ) : (
72
              data[map.ref]
73
            )}
74
            {map.copy && <CopyButton value={data[map.ref]} />}
×
75
          </Group>
76
        </td>
77
      </tr>
78
    ));
79
  }
80
  /* renderer */
81
  if (isLoading) return <Trans>Loading</Trans>;
×
82

83
  const copyval = `InvenTree-Version: ${data.version.server}\nDjango Version: ${
×
84
    data.version.django
85
  }\n${
86
    data.version.commit_hash &&
×
87
    `Commit Hash: ${data.version.commit_hash}\nCommit Date: ${data.version.commit_date}\nCommit Branch: ${data.version.commit_branch}\n`
88
  }Database: ${server.database}\nDebug-Mode: ${
89
    server.debug_mode ? 'True' : 'False'
×
90
  }\nDeployed using Docker: ${
91
    server.docker_mode ? 'True' : 'False'
×
92
  }\nPlatform: ${server.platform}\nInstaller: ${server.installer}\n${
93
    server.target && `Target: ${server.target}\n`
×
94
  }Active plugins: ${JSON.stringify(server.active_plugins)}`;
95
  return (
×
96
    <Stack>
97
      <Divider />
98
      <Title order={5}>
99
        <Trans>Version Information</Trans>
100
      </Title>
101
      <Group>
102
        <Text>
103
          <Trans>Your InvenTree version status is</Trans>
104
        </Text>
105
        {data.dev ? (
×
106
          <Badge color="blue">
107
            <Trans>Development Version</Trans>
108
          </Badge>
109
        ) : data.up_to_date ? (
×
110
          <Badge color="green">
111
            <Trans>Up to Date</Trans>
112
          </Badge>
113
        ) : (
114
          <Badge color="teal">
115
            <Trans>Update Available</Trans>
116
          </Badge>
117
        )}
118
      </Group>
119
      <Table>
120
        <tbody>
121
          {fillTable(
122
            [
123
              {
124
                ref: 'server',
125
                title: <Trans>InvenTree Version</Trans>,
126
                link: 'https://github.com/inventree/InvenTree/releases',
127
                copy: true
128
              },
129
              {
130
                ref: 'commit_hash',
131
                title: <Trans>Commit Hash</Trans>,
132
                copy: true
133
              },
134
              {
135
                ref: 'commit_date',
136
                title: <Trans>Commit Date</Trans>,
137
                copy: true
138
              },
139
              {
140
                ref: 'commit_branch',
141
                title: <Trans>Commit Branch</Trans>,
142
                copy: true
143
              },
144
              {
145
                ref: 'api',
146
                title: <Trans>API Version</Trans>,
147
                link: `${host}api-doc/`
148
              },
149
              { ref: 'python', title: <Trans>Python Version</Trans> },
150
              {
151
                ref: 'django',
152
                title: <Trans>Django Version</Trans>,
153
                link: 'https://www.djangoproject.com/',
154
                copy: true
155
              }
156
            ],
157
            data.version
158
          )}
159
        </tbody>
160
      </Table>
161
      <Title order={5}>
162
        <Trans>Links</Trans>
163
      </Title>
164
      <Table>
165
        <tbody>
166
          {fillTable(
167
            [
168
              { ref: 'doc', title: <Trans>InvenTree Documentation</Trans> },
169
              { ref: 'code', title: <Trans>View Code on GitHub</Trans> },
170
              { ref: 'credit', title: <Trans>Credits</Trans> },
171
              { ref: 'app', title: <Trans>Mobile App</Trans> },
172
              { ref: 'bug', title: <Trans>Submit Bug Report</Trans> }
173
            ],
174
            data.links,
175
            true
176
          )}
177
        </tbody>
178
      </Table>
179
      <Divider />
180
      <Group position="apart">
181
        <CopyButton
182
          value={copyval}
183
          label={<Trans>Copy version information</Trans>}
184
        />
185
        <Space />
186
        <Button
187
          color="red"
188
          onClick={() => {
189
            context.closeModal(id);
×
190
          }}
191
        >
192
          <Trans>Dismiss</Trans>
193
        </Button>
194
      </Group>
195
    </Stack>
196
  );
197
}
3✔
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