do not mislead user about being able to edit and clean up time in words

This commit is contained in:
burnettk 2022-11-25 02:53:20 -05:00
parent f22af2a85f
commit 5484f6d5d4
6 changed files with 24 additions and 13 deletions

View File

@ -3,15 +3,15 @@ import { TimeAgo } from '../helpers/timeago';
import { convertSecondsToFormattedDateTime } from '../helpers';
type OwnProps = {
time_in_seconds: number;
timeInSeconds: number;
};
export default function TableCellWithTimeAgoInWords({
time_in_seconds,
timeInSeconds,
}: OwnProps) {
return (
<td title={convertSecondsToFormattedDateTime(time_in_seconds) || '-'}>
{time_in_seconds ? TimeAgo.inWords(time_in_seconds) : '-'}
<td title={convertSecondsToFormattedDateTime(timeInSeconds) || '-'}>
{timeInSeconds ? TimeAgo.inWords(timeInSeconds) : '-'}
</td>
);
}

View File

@ -75,7 +75,7 @@ export default function MyOpenProcesses() {
) || '-'}
</td>
<TableCellWithTimeAgoInWords
time_in_seconds={rowToUse.updated_at_in_seconds}
timeInSeconds={rowToUse.updated_at_in_seconds}
/>
<td>
<Button

View File

@ -75,7 +75,7 @@ export default function TasksWaitingForMe() {
) || '-'}
</td>
<TableCellWithTimeAgoInWords
time_in_seconds={rowToUse.updated_at_in_seconds}
timeInSeconds={rowToUse.updated_at_in_seconds}
/>
<td>
<Button

View File

@ -83,7 +83,7 @@ export default function TasksWaitingForMyGroups() {
) || '-'}
</td>
<TableCellWithTimeAgoInWords
time_in_seconds={rowToUse.updated_at_in_seconds}
timeInSeconds={rowToUse.updated_at_in_seconds}
/>
<td>
<Button

View File

@ -1,5 +1,6 @@
/* eslint-disable no-restricted-syntax */
// https://gist.github.com/caiotarifa/30ae974f2293c761f3139dd194abd9e5
export const TimeAgo = (function () {
export const TimeAgo = (function awesomeFunc() {
const self = {};
// Public Methods
@ -20,9 +21,11 @@ export const TimeAgo = (function () {
years: '%d years',
};
self.inWords = function (timeAgo) {
self.inWords = function inWords(timeAgo) {
const milliseconds = timeAgo * 1000;
const seconds = Math.floor((new Date() - parseInt(milliseconds)) / 1000);
const seconds = Math.floor(
(new Date() - parseInt(milliseconds, 10)) / 1000
);
const separator = this.locales.separator || ' ';
let words = this.locales.prefix + separator;
let interval = 0;
@ -36,6 +39,7 @@ export const TimeAgo = (function () {
let distance = this.locales.seconds;
// eslint-disable-next-line guard-for-in
for (const key in intervals) {
interval = Math.floor(intervals[key]);

View File

@ -7,6 +7,7 @@ import {
TrashCan,
Favorite,
Edit,
View,
ArrowRight,
// @ts-ignore
} from '@carbon/icons-react';
@ -66,7 +67,7 @@ export default function ProcessModelShow() {
[targetUris.processModelShowPath]: ['PUT', 'DELETE'],
[targetUris.processInstanceListPath]: ['GET'],
[targetUris.processInstanceActionPath]: ['POST'],
[targetUris.processModelFileCreatePath]: ['POST', 'GET', 'DELETE'],
[targetUris.processModelFileCreatePath]: ['POST', 'PUT', 'GET', 'DELETE'],
};
const { ability, permissionsLoaded } = usePermissionFetcher(
permissionRequestData
@ -214,12 +215,18 @@ export default function ProcessModelShow() {
isPrimaryBpmnFile: boolean
) => {
const elements = [];
let icon = View;
let actionWord = 'View';
if (ability.can('PUT', targetUris.processModelFileCreatePath)) {
icon = Edit;
actionWord = 'Edit';
}
elements.push(
<Can I="GET" a={targetUris.processModelFileCreatePath} ability={ability}>
<Button
kind="ghost"
renderIcon={Edit}
iconDescription="Edit File"
renderIcon={icon}
iconDescription={`${actionWord} File`}
hasIconOnly
size="lg"
data-qa={`edit-file-${processModelFile.name.replace('.', '-')}`}