@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
178 lines (176 loc) • 7.12 kB
JavaScript
/*
* Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as published by
* the Free Software Foundation.
*
* 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
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as published by
* the Free Software Foundation.
*
* 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Table from '@mui/material/Table';
import TableHead from '@mui/material/TableHead';
import GlobalAppGridRow from '../../GlobalAppGridRow';
import GlobalAppGridCell from '../../GlobalAppGridCell';
import Typography from '@mui/material/Typography';
import { FormattedMessage } from 'react-intl';
import TableBody from '@mui/material/TableBody';
import TableContainer from '@mui/material/TableContainer';
import React from 'react';
import ArrowDownwardRoundedIcon from '@mui/icons-material/ArrowDownwardRounded';
import ArrowUpwardRoundedIcon from '@mui/icons-material/ArrowUpwardRounded';
import DeleteRoundedIcon from '@mui/icons-material/DeleteRounded';
import IconButton from '@mui/material/IconButton';
import Tooltip from '@mui/material/Tooltip';
import ConfirmDropdown from '../../ConfirmDropdown';
export function RepoGridUI(props) {
const { repositories, disableActions, onDeleteRemote, onPullClick, onPushClick } = props;
return React.createElement(
TableContainer,
null,
React.createElement(
Table,
null,
React.createElement(RepositoriesGridTableHead, null),
React.createElement(
TableBody,
null,
repositories === null || repositories === void 0
? void 0
: repositories.map((repository) =>
React.createElement(
GlobalAppGridRow,
{ key: repository.name, className: 'hoverDisabled' },
React.createElement(GlobalAppGridCell, { align: 'left' }, repository.name),
React.createElement(GlobalAppGridCell, { align: 'left' }, repository.url),
React.createElement(GlobalAppGridCell, { align: 'left' }, repository.fetch),
React.createElement(GlobalAppGridCell, { align: 'left' }, repository.pushUrl),
React.createElement(
GlobalAppGridCell,
{ align: 'right' },
React.createElement(
Tooltip,
{ title: React.createElement(FormattedMessage, { id: 'words.pull', defaultMessage: 'Pull' }) },
React.createElement(
'span',
null,
React.createElement(
IconButton,
{
onClick: () => onPullClick(repository.name, repository.branches),
disabled: disableActions,
size: 'large'
},
React.createElement(ArrowDownwardRoundedIcon, null)
)
)
),
React.createElement(
Tooltip,
{ title: React.createElement(FormattedMessage, { id: 'words.push', defaultMessage: 'Push' }) },
React.createElement(
'span',
null,
React.createElement(
IconButton,
{
onClick: () => onPushClick(repository.name, repository.branches),
disabled: disableActions,
size: 'large'
},
React.createElement(ArrowUpwardRoundedIcon, null)
)
)
),
React.createElement(ConfirmDropdown, {
cancelText: React.createElement(FormattedMessage, { id: 'words.no', defaultMessage: 'No' }),
confirmText: React.createElement(FormattedMessage, { id: 'words.yes', defaultMessage: 'Yes' }),
confirmHelperText: React.createElement(FormattedMessage, {
id: 'repositories.deleteConfirmation',
defaultMessage: 'Delete remote repository?'
}),
iconTooltip: React.createElement(FormattedMessage, {
id: 'words.delete',
defaultMessage: 'Delete'
}),
icon: DeleteRoundedIcon,
onConfirm: () => {
onDeleteRemote(repository.name);
},
disabled: disableActions
})
)
)
)
)
)
);
}
export function RepositoriesGridTableHead() {
return React.createElement(
TableHead,
null,
React.createElement(
GlobalAppGridRow,
{ className: 'hoverDisabled' },
React.createElement(
GlobalAppGridCell,
null,
React.createElement(
Typography,
{ variant: 'subtitle2' },
React.createElement(FormattedMessage, { id: 'words.name', defaultMessage: 'Name' })
)
),
React.createElement(
GlobalAppGridCell,
null,
React.createElement(
Typography,
{ variant: 'subtitle2' },
React.createElement(FormattedMessage, { id: 'words.url', defaultMessage: 'Url' })
)
),
React.createElement(
GlobalAppGridCell,
null,
React.createElement(
Typography,
{ variant: 'subtitle2' },
React.createElement(FormattedMessage, { id: 'words.fetch', defaultMessage: 'Fetch' })
)
),
React.createElement(
GlobalAppGridCell,
null,
React.createElement(
Typography,
{ variant: 'subtitle2' },
React.createElement(FormattedMessage, { id: 'repositories.pushUrl', defaultMessage: 'Push URL' })
)
),
React.createElement(GlobalAppGridCell, null)
)
);
}
export default RepoGridUI;