mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
refactor(ui): move react components to react codebase [EE-3354] (#8258)
* refactor(ui): move react components to react codebase [EE-3354] * refactor(app): move bocx selector options * refactor(react): spearate portainer components * fix(app): fix imports
This commit is contained in:
parent
f9a09301a8
commit
b98c71f1ab
66 changed files with 312 additions and 294 deletions
|
@ -1,8 +1,3 @@
|
|||
// theme icons
|
||||
import automode from '@/assets/ico/theme/auto.svg?c';
|
||||
import darkmode from '@/assets/ico/theme/darkmode.svg?c';
|
||||
import lightmode from '@/assets/ico/theme/lightmode.svg?c';
|
||||
import highcontrastmode from '@/assets/ico/theme/highcontrastmode.svg?c';
|
||||
// general icons
|
||||
import heartbeatup from '@/assets/ico/heartbeat-up.svg?c';
|
||||
import heartbeatdown from '@/assets/ico/heartbeat-down.svg?c';
|
||||
|
@ -47,10 +42,6 @@ const placeholder = Placeholder;
|
|||
export const SvgIcons = {
|
||||
heartbeatup,
|
||||
heartbeatdown,
|
||||
automode,
|
||||
darkmode,
|
||||
lightmode,
|
||||
highcontrastmode,
|
||||
dataflow,
|
||||
dockericon,
|
||||
git,
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
import moment from 'moment';
|
||||
import 'moment-timezone';
|
||||
|
||||
import { useCurrentEnvironment } from '@/react/hooks/useCurrentEnvironment';
|
||||
|
||||
import { TextTip } from '@@/Tip/TextTip';
|
||||
|
||||
import { withEdition } from '../portainer/feature-flags/withEdition';
|
||||
|
||||
const TimeWindowDisplayWrapper = withEdition(TimeWindowDisplay, 'BE');
|
||||
|
||||
export { TimeWindowDisplayWrapper as TimeWindowDisplay };
|
||||
|
||||
function TimeWindowDisplay() {
|
||||
const currentEnvQuery = useCurrentEnvironment(false);
|
||||
|
||||
if (!currentEnvQuery.data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { ChangeWindow } = currentEnvQuery.data;
|
||||
|
||||
if (!ChangeWindow.Enabled) {
|
||||
return null;
|
||||
}
|
||||
const timezone = moment.tz.guess();
|
||||
const isDST = moment().isDST();
|
||||
const { startTime: startTimeLocal, endTime: endTimeLocal } = utcToTime(
|
||||
{ startTime: ChangeWindow.StartTime, endTime: ChangeWindow.EndTime },
|
||||
timezone
|
||||
);
|
||||
|
||||
const { startTime: startTimeUtc, endTime: endTimeUtc } = parseInterval(
|
||||
ChangeWindow.StartTime,
|
||||
ChangeWindow.EndTime
|
||||
);
|
||||
|
||||
return (
|
||||
<TextTip color="orange">
|
||||
A change window is enabled, automatic updates will not occur outside of{' '}
|
||||
<span className="font-bold">
|
||||
{shortTime(startTimeUtc)} - {shortTime(endTimeUtc)} UTC (
|
||||
{shortTime(startTimeLocal)} -{shortTime(endTimeLocal)}{' '}
|
||||
{isDST ? 'DST' : ''} {timezone})
|
||||
</span>
|
||||
.
|
||||
</TextTip>
|
||||
);
|
||||
}
|
||||
|
||||
function utcToTime(
|
||||
utcTime: { startTime: string; endTime: string },
|
||||
timezone: string
|
||||
) {
|
||||
const startTime = moment
|
||||
.tz(utcTime.startTime, 'HH:mm', 'GMT')
|
||||
.tz(timezone)
|
||||
.format('HH:mm');
|
||||
const endTime = moment
|
||||
.tz(utcTime.endTime, 'HH:mm', 'GMT')
|
||||
.tz(timezone)
|
||||
.format('HH:mm');
|
||||
|
||||
return parseInterval(startTime, endTime);
|
||||
}
|
||||
|
||||
function parseTime(originalTime: string) {
|
||||
const [startHour, startMin] = originalTime.split(':');
|
||||
|
||||
const time = new Date();
|
||||
|
||||
time.setHours(parseInt(startHour, 10));
|
||||
time.setMinutes(parseInt(startMin, 10));
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
function parseInterval(startTime: string, endTime: string) {
|
||||
return {
|
||||
startTime: parseTime(startTime),
|
||||
endTime: parseTime(endTime),
|
||||
};
|
||||
}
|
||||
|
||||
function shortTime(time: Date) {
|
||||
return moment(time).format('h:mm a');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue