Skip to content

Commit

Permalink
Migrating components away from createReactClass. (#20818)
Browse files Browse the repository at this point in the history
* Preparing `SupportSources` for migration.

* Preparing `CloudWatchApp` for migration.

* Preparing `FormGroup` for migration.

* Preparing components for migration.

* Preparing prop types in components for migration.

* Preparing `MessageTableEntry` for Migration.

* Migrating `propTypes` to types.

* Removing unused sympols/imports.

* Fixing up props for `FormGroup`.

* Fixing up props for `Panel`.

* Fixing up `ColorPreview` component.

* Improving `children` type for `Panel`.

* Fixing up type for `EventsPage`.

* Fixing up `IndexerFailuresPage`.

* Fixing up typing for `Input`.

* Fixing up typing for `ValidatedInput`.

* Fixing up `QueryInput`.

* Removing unused import.

* Fixing up types of `Select`.

* Fixing up `HighlightingRule`.

* Fixing up `SidecarStatusPage`.

* Fixing up `LUTDataAdaptersPage`.

* Adding common props to shared component.

* Fixing up `GrokPatterns`.

* Fixing up `DataTieringVisualisation`.

* Explicitly type contexts as `any`, need to be fixed later.

* Removing duplicate props.

* Fixing minor typing issues.

* Fixing minor typing issues contd.

* Fixing minor typing issues. (Part III)

* Fixing minor typing issues. (Part IV)

* Fixing minor typing issues. (Part V)

* Fixing up bindings.

* Fixing minor typing issues. (Part VI)

* Migrating `ConfigurationListContainer`.

* Fixing up formatting etc.

* Adding back license headers.

* Fixing up missing type, adding todo.

* Fixing up typing.

* Avoid prop being passed through.

* Reenacting original behavior in a type-safe way.

* Migrating `ImportExtractorsPage`.

* Migrating `TimeUnit`.

* Migrating `JSONExtractorConfiguration`.

* Migrating `InputThroughput`.

* Migrating `LoggerOverview` to use `useQuery`.

* Migrating `LogLevelMetricsOverview`.

* Migrating `LogLevelDropdown`, removing `LoggersStore`.

* Migrating `LogLevelMetrics`.

* Migrating `NodeLoggers`.

* Removing usage of HOCs from `LogLevelDropdown`.

* Migrating `TimesList`.

* Migrating `ShowNodePage`.

* Migrating `ProcessBufferDumpPage`.

* Migrating `JournalState`.

* Migrating `JvmHeapUsage`.

* Migrating `MetricsMapper`.

* Migrating `CachesContainer`.

* Migrating `DataAdaptersContainer`.

* Improving types.

* Migrating `CollectorIndicator`.

* Migrating `JournalDetails`.

* Migrating `SimulationTrace`.

* Migrating `CollectorRow`.

* Migrating `SidecarStatus`.

* Migrating `SidecarListContainer`.

* Migrating `NodeThroughput`.

* Migrating `EditExtractorsPage`.

* Migrating `ExtractorsPage`.

* Migrating `SimulationChanges`.

* Migrating `CollectorsAdministrationContainer` & `CollectorsAdministrationFilters`.

* Migrating `ShowContentPackPage`.

* Adding license header.

* Migrating `OutputsComponent`.

* Improving types.

* Migrating `ThreatIntelPluginConfig`.

* Migrating `SubstringExtractorConfiguration`.

* Migrating `EditContentPackPage`.

* Migrating `PipelineDetailsPage`.

* Migrating `TimeUnitInput`.

* Adding license header.

* Fixing up formatting.
  • Loading branch information
dennisoelkers authored Oct 31, 2024
1 parent 01e025f commit dc0b6a5
Show file tree
Hide file tree
Showing 108 changed files with 3,802 additions and 4,075 deletions.
66 changes: 0 additions & 66 deletions graylog2-web-interface/src/components/common/TimeUnit.jsx

This file was deleted.

53 changes: 53 additions & 0 deletions graylog2-web-interface/src/components/common/TimeUnit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import * as React from 'react';

import type { TimeUnit as TimeUnitString } from './types';

/**
* Component that renders a time value given in a certain unit.
* It can also use 0 as never if `zeroIsNever` is set.
*/
type Props = {
value: number,
unit: TimeUnitString,
zeroIsNever?: boolean,
}

const UNITS = {
NANOSECONDS: 'nanoseconds',
MICROSECONDS: 'microseconds',
MILLISECONDS: 'milliseconds',
SECONDS: 'seconds',
MINUTES: 'minutes',
HOURS: 'hours',
DAYS: 'days',
};

const TimeUnit = ({ value, unit, zeroIsNever = true }: Props) => {
if (value === 0 && zeroIsNever) {
return <span>Never</span>;
}

return (
<span>
{value}&nbsp;{UNITS[unit]}
</span>
);
};

export default TimeUnit;
Loading

0 comments on commit dc0b6a5

Please sign in to comment.