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

Make the statistics page buttons consistent with buttons elsewhere in the application #4315

Merged
merged 3 commits into from Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,13 +1,14 @@
import { AttachmentWorkStateProps } from './types';
import { Dialog } from '../Molecules/Dialog';
import { Button } from '../Atoms/Button';
import { wbText } from '../../localization/workbench';
import React from 'react';

import { attachmentsText } from '../../localization/attachments';
import { Progress } from '../Atoms';
import { commonText } from '../../localization/common';
import { wbText } from '../../localization/workbench';
import { formatTime } from '../../utils/utils';
import React from 'react';
import { Progress } from '../Atoms';
import { Button } from '../Atoms/Button';
import { formatNumber } from '../Atoms/Internationalization';
import { Dialog } from '../Molecules/Dialog';
import type { AttachmentWorkStateProps } from './types';

export function ActionState({
workProgress,
Expand Down
Expand Up @@ -4,11 +4,11 @@ import { commonText } from '../../localization/common';
import { wbText } from '../../localization/workbench';
import type { RA } from '../../utils/types';
import { Button } from '../Atoms/Button';
import { loadingBar } from '../Molecules';
import { Dialog } from '../Molecules/Dialog';
import type { AttachmentUploadSpec } from './Import';
import type { PartialUploadableFileSpec } from './types';
import { validateAttachmentFiles } from './utils';
import { loadingBar } from '../Molecules';

export function AttachmentsValidationDialog({
files,
Expand Down
@@ -1,8 +1,12 @@
import { SchemaViewerRow, SchemaViewerValue } from '../SchemaViewer/helpers';
import { RA, RR } from '../../utils/types';
import { LocalizedString } from 'typesafe-i18n';
import React from 'react';
import type { LocalizedString } from 'typesafe-i18n';

import type { RA, RR } from '../../utils/types';
import { Link } from '../Atoms/Link';
import type {
SchemaViewerRow,
SchemaViewerValue,
} from '../SchemaViewer/helpers';

export function GenericSortedDataViewer<
DATA extends SchemaViewerRow<RR<string, SchemaViewerValue>>
Expand Down Expand Up @@ -63,7 +67,8 @@ export function GenericSortedDataViewer<
);
});
const indexValue = row[indexColumn];
const key = typeof indexValue === 'object' ? indexValue[0] : indexValue;
const key =
typeof indexValue === 'object' ? indexValue[0] : indexValue;
const link = getLink?.(row);
return typeof link === 'string' ? (
<Link.Default href={link} key={key as string} role="row">
Expand Down
Expand Up @@ -269,7 +269,7 @@ export function Categories({
{typeof handleAdd === 'function' ? (
<div className="flex gap-2">
<Button.Small
variant={className.secondaryButton}
variant={className.borderedGrayButton}
onClick={(): void =>
handleRemove?.(categoryIndex, undefined)
}
Expand Down
22 changes: 11 additions & 11 deletions specifyweb/frontend/js_src/lib/components/Statistics/index.tsx
Expand Up @@ -529,11 +529,11 @@ function ProtectedStatsPage(): JSX.Element | null {
<DateElement date={pageLastUpdated} />
</span>
)}
<Button.Secondary onClick={(): void => refreshPage()}>
<Button.BorderedGray onClick={(): void => refreshPage()}>
{statsText.refresh()}
</Button.Secondary>
</Button.BorderedGray>
{Object.values(layout).every((layouts) => layouts !== undefined) && (
<Button.Secondary
<Button.BorderedGray
onClick={(): void => {
const date = new Date();
const sourceIndex = activePage.isShared ? 0 : 1;
Expand All @@ -555,12 +555,12 @@ function ProtectedStatsPage(): JSX.Element | null {
}}
>
{statsText.downloadAsTSV()}
</Button.Secondary>
</Button.BorderedGray>
)}
{isEditing ? (
<>
{process.env.NODE_ENV === 'development' && (
<Button.Secondary
<Button.BorderedGray
onClick={(): void => {
cleanThrottledPromises();
handleSharedLayoutChange(undefined);
Expand All @@ -574,10 +574,10 @@ function ProtectedStatsPage(): JSX.Element | null {
}}
>
{`${commonText.reset()} [DEV]`}
</Button.Secondary>
</Button.BorderedGray>
)}

<Button.Secondary
<Button.BorderedGray
onClick={(): void => {
handleSharedLayoutChange(previousCollectionLayout.current);
handlePersonalLayoutChange(previousLayout.current);
Expand All @@ -602,12 +602,12 @@ function ProtectedStatsPage(): JSX.Element | null {
}}
>
{commonText.cancel()}
</Button.Secondary>
</Button.BorderedGray>
<Submit.Save>{commonText.save()}</Submit.Save>
</>
) : (
canEdit && (
<Button.Secondary
<Button.BorderedGray
onClick={(): void => {
setState({
type: 'EditingState',
Expand All @@ -619,7 +619,7 @@ function ProtectedStatsPage(): JSX.Element | null {
}}
>
{commonText.edit()}
</Button.Secondary>
</Button.BorderedGray>
)
)}
</div>
Expand All @@ -643,7 +643,7 @@ function ProtectedStatsPage(): JSX.Element | null {
{isEditing && canEditIndex(index === 0) && (
<div className="flex flex-1">
<Button.Icon
className={`max-w-fit ${className.secondaryButton}`}
className="max-w-fit"
icon="plus"
title={commonText.add()}
onClick={(): void =>
Expand Down
Expand Up @@ -6,6 +6,7 @@

import React from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import type { LocalizedString } from 'typesafe-i18n';

import { useAsyncState } from '../../hooks/useAsyncState';
import { commonText } from '../../localization/common';
Expand All @@ -17,6 +18,7 @@ import { Button } from '../Atoms/Button';
import { className } from '../Atoms/className';
import { icons } from '../Atoms/Icons';
import { Link } from '../Atoms/Link';
import type { AttachmentDataSet } from '../AttachmentsBulkImport/types';
import { LoadingContext } from '../Core/Contexts';
import { getField } from '../DataModel/helpers';
import { schema } from '../DataModel/schema';
Expand All @@ -30,8 +32,6 @@ import { OverlayContext } from '../Router/Router';
import { uniquifyDataSetName } from '../WbImport/helpers';
import type { Dataset, DatasetBrief } from '../WbPlanView/Wrapped';
import { WbDataSetMeta } from '../WorkBench/DataSetMeta';
import { AttachmentDataSet } from '../AttachmentsBulkImport/types';
import { LocalizedString } from 'typesafe-i18n';

const createWorkbenchDataSet = async () =>
createEmptyDataSet<Dataset>(
Expand Down
Expand Up @@ -72,7 +72,7 @@ type DataSetMetaProps = {
export function WbDataSetMeta(
props: Omit<
DataSetMetaProps,
'datasetUrl' | 'onChange' | 'permissionResource' | 'deleteDescription'
'datasetUrl' | 'deleteDescription' | 'onChange' | 'permissionResource'
> & {
readonly onChange: ({
name,
Expand All @@ -88,6 +88,7 @@ export function WbDataSetMeta(
<DataSetMeta
{...props}
datasetUrl="/api/workbench/dataset/"
deleteDescription={wbText.deleteDataSetDescription()}
permissionResource="/workbench/dataset"
onChange={({ needsSaved, name, remarks }) =>
loading(
Expand All @@ -97,7 +98,6 @@ export function WbDataSetMeta(
).then(props.onChange)
)
}
deleteDescription={wbText.deleteDataSetDescription()}
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion specifyweb/frontend/js_src/lib/utils/fieldFormat.ts
Expand Up @@ -97,7 +97,7 @@ export function syncFieldFormat<STRICT extends boolean = false>(
value: boolean | number | string | null | undefined,
// @ts-expect-error
strict: STRICT = false
): string | ReturnType<typeof formatValue<STRICT>> {
): ReturnType<typeof formatValue<STRICT>> | string {
if (value === undefined || value === null) return '';

// Find Pick List Item Title
Expand Down