Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement/artesca 10858 empty state #735

Merged
merged 27 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a04be86
update table
JeanMarcMilletScality Mar 5, 2024
8844d16
change warning for core-ui empty state
JeanMarcMilletScality Mar 5, 2024
06f74ea
update table
JeanMarcMilletScality Mar 5, 2024
f2c4425
update empty state, use empty state from core-ui
JeanMarcMilletScality Mar 5, 2024
21e06c0
fix Empty state of workflow
JeanMarcMilletScality Mar 5, 2024
7476703
fix ts error, different names were used for the same value
JeanMarcMilletScality Mar 6, 2024
b18f9a2
update emptyState
JeanMarcMilletScality Mar 6, 2024
41385c5
use Icon with wrapper instead of custom icon
JeanMarcMilletScality Mar 6, 2024
b59ce75
update table and emptystate with new Core-Ui versions, change some cu…
JeanMarcMilletScality Mar 7, 2024
257e4bf
change style, remove some padding
JeanMarcMilletScality Mar 8, 2024
87f8afe
remove the errorTable label prop, as it is not use anymore
JeanMarcMilletScality Mar 8, 2024
ba60a1f
update tests affected by the update of table or emptystate
JeanMarcMilletScality Mar 8, 2024
643f498
update and cleaning of ui elements
JeanMarcMilletScality Mar 18, 2024
ed0448f
update packages
JeanMarcMilletScality Mar 18, 2024
f88c623
change flex for width in table to avoid table going over right panel
JeanMarcMilletScality Mar 19, 2024
208a2c0
allow editor to switch theme with ui
JeanMarcMilletScality Mar 20, 2024
82bbc6f
add overflow-x property to avoid flashing table, probably due to over…
JeanMarcMilletScality Mar 20, 2024
16bdd4c
add padding to give space for caret in table
JeanMarcMilletScality Mar 20, 2024
6539653
change table proportion for better display
JeanMarcMilletScality Mar 20, 2024
fcbe27f
improve table displays, resolve issues on smaller screen
JeanMarcMilletScality Mar 21, 2024
547bb2f
center no account warning
JeanMarcMilletScality Mar 21, 2024
58095cc
fix typo in test
JeanMarcMilletScality Mar 25, 2024
aef3176
update listedResource with singular and plural
JeanMarcMilletScality Jun 6, 2024
b017b52
upadate packages
JeanMarcMilletScality Jun 6, 2024
002705c
add missing leading slash
JeanMarcMilletScality Jun 6, 2024
832b025
update core ui
JeanMarcMilletScality Jun 6, 2024
501942e
remove history after Core ui empty state update
JeanMarcMilletScality Jun 6, 2024
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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@hapi/joi-date": "^2.0.1",
"@hookform/resolvers": "^2.8.8",
"@monaco-editor/react": "^4.4.5",
"@scality/core-ui": "0.122.0",
"@scality/core-ui": "0.124.0",
"@scality/module-federation": "github:scality/module-federation#1.1.0",
"@types/react-table": "^7.7.10",
"@types/react-virtualized": "^9.21.20",
Expand Down
37 changes: 21 additions & 16 deletions src/react/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { AppContainer, ErrorPage401, Icon, Sidebar } from '@scality/core-ui';
import {
AppContainer,
EmptyState,
ErrorPage401,
Icon,
Loader,
Sidebar,
} from '@scality/core-ui';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import {
Expand Down Expand Up @@ -32,11 +39,9 @@ import EndpointCreate from './endpoint/EndpointCreate';
import Endpoints from './endpoint/Endpoints';
import LocationEditor from './locations/LocationEditor';
import { Locations } from './locations/Locations';
import { EmptyStateContainer } from './ui-elements/Container';
import Loader from './ui-elements/Loader';
import ReauthDialog from './ui-elements/ReauthDialog';
import VeeamSteppers from './ui-elements/Veeam/VeeamSteps';
import { Warning } from './ui-elements/Warning';

import { useAuthGroups } from './utils/hooks';

export const RemoveTrailingSlash = ({ ...rest }) => {
Expand All @@ -58,7 +63,7 @@ export const RemoveTrailingSlash = ({ ...rest }) => {

const RedirectToAccount = () => {
// To be replace later by react-query or context
const history = useHistory();

const { account: selectedAccount } = useCurrentAccount();
const { pathname, search } = useLocation();

Expand All @@ -68,17 +73,17 @@ const RedirectToAccount = () => {
<Redirect to={`/accounts/${selectedAccount.Name}${pathname}${search}`} />
);
} else if (isStorageManager) {
const description = pathname === '/workflows' ? 'workflows' : 'data';
const description =
pathname === '/workflows'
? { singular: 'Workflow', plural: 'Workflows' }
: { singular: 'Bucket', plural: 'Buckets' };
return (
<EmptyStateContainer>
<Warning
centered={true}
icon={<Icon name="Account" size="5x" />}
title={`Before browsing your ${description}, create your first account.`}
btnTitle="Create Account"
btnAction={() => history.push('/create-account')}
/>
</EmptyStateContainer>
<EmptyState
icon={pathname === '/workflows' ? 'Workflow' : 'Bucket'}
link="/create-account"
listedResource={description}
resourceToCreate="Account"
></EmptyState>
);
} else {
return <ErrorPage401 />;
Expand Down Expand Up @@ -139,7 +144,7 @@ function PrivateRoutes() {

if (!isClientsLoaded) {
return (
<Loader>
<Loader centered>
<div>Loading clients</div>
</Loader>
);
Expand Down
88 changes: 40 additions & 48 deletions src/react/account/AccountList.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
import React, { useMemo } from 'react';
import { useHistory } from 'react-router-dom';
import styled from 'styled-components';
import { spacing } from '@scality/core-ui/dist/style/theme';
import { Button } from '@scality/core-ui/dist/components/buttonv2/Buttonv2.component';
import { Table } from '@scality/core-ui/dist/components/tablev2/Tablev2.component';
import {
ConstrainedText,
FormattedDateTime,
Icon,
Link,
Stack,
FormattedDateTime,
} from '@scality/core-ui';
import { Account } from '../next-architecture/domain/entities/account';
import { Button, Table } from '@scality/core-ui/dist/next';
import React, { useMemo } from 'react';
import { useHistory } from 'react-router-dom';
import { CellProps, CoreUIColumn } from 'react-table';
import { Account } from '../next-architecture/domain/entities/account';

import { VEEAM_FEATURE } from '../../js/config';
import {
useCurrentAccount,
useSetAssumedRole,
} from '../DataServiceRoleProvider';
import { useAuthGroups } from '../utils/hooks';
import { getDataUsedColumn } from '../next-architecture/ui/metrics/DataUsedColumn';
import { useMetricsAdapter } from '../next-architecture/ui/MetricsAdapterProvider';
import { useAccountLatestUsedCapacity } from '../next-architecture/domain/business/accounts';
import { useConfig } from '../next-architecture/ui/ConfigProvider';
import { VEEAM_FEATURE } from '../../js/config';

const TableAction = styled.div`
display: flex;
justify-content: space-between;
margin-bottom: ${spacing.sp16};
`;
import { useMetricsAdapter } from '../next-architecture/ui/MetricsAdapterProvider';
import { getDataUsedColumn } from '../next-architecture/ui/metrics/DataUsedColumn';
import { TableHeaderWrapper } from '../ui-elements/Table';
import { useAuthGroups } from '../utils/hooks';

function useAutoAssumeRoleUponAccountDeletion({
accounts,
Expand Down Expand Up @@ -118,7 +111,6 @@ function AccountList({ accounts }: { accounts: Account[] }) {
return (
<div
style={{
padding: `${spacing.sp16}`,
display: 'flex',
flexDirection: 'column',
flex: 1,
Expand All @@ -128,40 +120,40 @@ function AccountList({ accounts }: { accounts: Account[] }) {
columns={columns}
data={accounts}
defaultSortingKey={'creationDate'}
entityName={{
en: {
singular: 'account',
plural: 'accounts',
},
}}
>
<TableAction>
<Table.SearchWithQueryParams
displayedName={{
singular: 'account',
plural: 'accounts',
}}
/>
{isStorageManager ? (
<Stack>
{features.includes(VEEAM_FEATURE) && (
<TableHeaderWrapper
search={<Table.SearchWithQueryParams />}
actions={
isStorageManager && (
<Stack>
{features.includes(VEEAM_FEATURE) && (
<Button
label="Start Configuration for Veeam"
variant="secondary"
onClick={() => history.push('/veeam/configuration')}
type="button"
/>
)}
<Button
label="Start Configuration for Veeam"
variant="secondary"
onClick={() => history.push('/veeam/configuration')}
type="button"
/>
)}
<Button
icon={<Icon name="Create-add" />}
label="Create Account"
variant="primary"
onClick={() => history.push('/create-account')}
type="submit"
></Button>
</Stack>
) : (
''
)}
</TableAction>
icon={<Icon name="Create-add" />}
label="Create Account"
variant="primary"
onClick={() => history.push('/create-account')}
type="submit"
></Button>
</Stack>
)
}
/>
<Table.SingleSelectableContent
rowHeight="h40"
separationLineVariant="backgroundLevel1"
backgroundVariant="backgroundLevel3"
/>
</Table>
</div>
Expand Down
64 changes: 27 additions & 37 deletions src/react/account/AccountLocations.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Icon, Loader, Stack } from '@scality/core-ui';
import { Loader, Stack } from '@scality/core-ui';
import { Table } from '@scality/core-ui/dist/next';
import { useMemo } from 'react';
import { CellProps, CoreUIColumn } from 'react-table';
Expand All @@ -9,10 +9,9 @@ import { useMetricsAdapter } from '../next-architecture/ui/MetricsAdapterProvide
import { getDataUsedColumn } from '../next-architecture/ui/metrics/DataUsedColumn';
import { ColdStorageIcon } from '../ui-elements/ColdStorageIcon';
import { HelpLocationTargetBucket } from '../ui-elements/Help';
import { Search } from '../ui-elements/Table';
import { Warning } from '../ui-elements/Warning';

import { getLocationType } from '../utils/storageOptions';
import { CenterredSecondaryText } from './iamAttachment/AttachmentTable';
import { TableHeaderWrapper } from '../ui-elements/Table';

export function AccountLocations() {
const metricsAdapter = useMetricsAdapter();
Expand All @@ -34,23 +33,28 @@ export function AccountLocations() {
(location: Location) => {
return location;
},
{ flex: '0.2' },
{ flex: '0.5' },
);
const columns: CoreUIColumn<Location>[] = [
{
Header: 'Location Name',
accessor: 'name',
cellStyle: {
textAlign: 'left',
minWidth: '20rem',
minWidth: '10rem',
flex: '1',
width: 'unset',
},
},
{
Header: 'Location Type',
accessor: 'type',
cellStyle: {
textAlign: 'left',
minWidth: '24rem',
minWidth: '10rem',
flex: '1',

width: 'unset',
},
Cell(value: CellProps<Location>) {
const rowValues = value.row.original;
Expand All @@ -75,7 +79,7 @@ export function AccountLocations() {
accessor: 'details.bucketName',
cellStyle: {
textAlign: 'left',
flex: '0.3',
flex: '0.5',
},
},
dataUsedColumn,
Expand All @@ -84,54 +88,40 @@ export function AccountLocations() {
return columns;
}, [locations]);

if (locations.status === 'loading' || locations.status === 'unknown') {
if (locations.status === 'unknown') {
return (
<Stack>
<Loader size="huge" />
<div>Loading locations...</div>
</Stack>
);
}
if (locations.status === 'error') {
return (
<Warning
icon={<Icon name="Times-circle" size="2x" />}
title="Unable to load locations."
/>
);
}

return (
<Table columns={columns} data={data} defaultSortingKey={'name'}>
<Search>
<Table.SearchWithQueryParams
displayedName={{
singular: 'location',
plural: 'locations',
}}
queryParams={SEARCH_QUERY_PARAM}
/>
</Search>
<Table
columns={columns}
data={data}
defaultSortingKey={'name'}
entityName={{ en: { singular: 'location', plural: 'locations' } }}
status={locations.status}
>
<TableHeaderWrapper
search={
<Table.SearchWithQueryParams queryParams={SEARCH_QUERY_PARAM} />
}
/>

<Table.SingleSelectableContent
id="singleTable"
rowHeight="h40"
separationLineVariant="backgroundLevel1"
backgroundVariant="backgroundLevel3"
//@ts-expect-error fix this when you are working on it
customItemKey={(index: number, data: Array<Location>) =>
data[index].name
}
//@ts-expect-error fix this when you are working on it
key={(index: number, data: Array<Location>) => data[index].name}
>
{(Rows) =>
data.length === 0 ? (
<CenterredSecondaryText>No Locations</CenterredSecondaryText>
) : (
<>{Rows}</>
)
}
</Table.SingleSelectableContent>
></Table.SingleSelectableContent>
</Table>
);
}
Loading
Loading