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

fix(audit): audit and history UI tweaks #4092

Merged
merged 3 commits into from
Jun 3, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 20 additions & 23 deletions frontend/web/components/FeatureVersion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,28 @@ const FeatureVersion: FC<VersionDiffType> = ({
) : (
<>
{oldUUID === newUUID ? (
<InfoMessage>
Published at{' '}
<strong>
{moment(newVersion.created_at).format('Do MMM YYYY HH:mma')}
</strong>{' '}
</InfoMessage>
<InfoMessage>Versions are the same.</InfoMessage>
) : (
<InfoMessage>
Comparing{' '}
<strong>
{moment(newVersion.created_at).format('Do MMM YYYY HH:mma')}
</strong>{' '}
to{' '}
<strong>
{moment(oldVersion.created_at).format('Do MMM YYYY HH:mma')}
</strong>
</InfoMessage>
)}
<>
<InfoMessage>
Comparing{' '}
<strong>
{moment(newVersion.created_at).format('Do MMM YYYY HH:mma')}
</strong>{' '}
to{' '}
<strong>
{moment(oldVersion.created_at).format('Do MMM YYYY HH:mma')}
</strong>
</InfoMessage>

<DiffFeature
projectId={projectId}
featureId={featureId}
oldState={oldData}
newState={newData}
/>
<DiffFeature
projectId={projectId}
featureId={featureId}
oldState={oldData}
newState={newData}
/>
</>
)}
</>
)}
</div>
Expand Down
11 changes: 11 additions & 0 deletions frontend/web/components/pages/AuditLogItemPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import DiffString from 'components/diff/DiffString'
import DiffEnabled from 'components/diff/DiffEnabled'
import Format from 'common/utils/format'
import { Environment } from 'common/types/responses'
import { Link } from 'react-router-dom';
import Button from 'components/base/forms/Button';
type AuditLogItemPageType = {
match: {
params: {
Expand Down Expand Up @@ -112,6 +114,15 @@ const AuditLogItemPage: FC<AuditLogItemPageType> = ({ match }) => {
</div>
</Panel>
)}
{data.related_object_type === 'EF_VERSION' &&
!!data.project &&
!!data.environment && (
<Link
to={`/project/${data.project.id}/environment/${data.environment.api_key}/history/${data.related_object_uuid}/`}
>
<Button theme='text'>View version</Button>
</Link>
)}
</>
)}
</div>
Expand Down
24 changes: 11 additions & 13 deletions frontend/web/components/pages/FeatureHistoryDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,17 @@ const FeatureHistoryPage: FC<FeatureHistoryPageType> = ({ match, router }) => {
</div>
</TabItem>
)}
{versions?.results?.[0].uuid !== data.uuid && (
<TabItem tabLabel='Compare to Live'>
<div className='mt-4'>
<FeatureVersion
projectId={`${match.params.projectId}`}
featureId={parseInt(featureId)}
environmentId={environmentId}
newUUID={live!.uuid}
oldUUID={data.uuid}
/>
</div>
</TabItem>
)}
<TabItem tabLabel='Compare to Live'>
<div className='mt-4'>
<FeatureVersion
projectId={`${match.params.projectId}`}
featureId={parseInt(featureId)}
environmentId={environmentId}
newUUID={live!.uuid}
oldUUID={data.uuid}
/>
</div>
</TabItem>
</Tabs>
</div>
</Row>
Expand Down
23 changes: 20 additions & 3 deletions frontend/web/components/pages/FeatureHistoryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import FeatureVersion from 'components/FeatureVersion'
import InlineModal from 'components/InlineModal'
import TableFilterItem from 'components/tables/TableFilterItem'
import moment from 'moment'
import { Link } from 'react-router-dom'

const widths = [250, 100]
const widths = [250, 150]
type FeatureHistoryPageType = {
router: RouterChildContext['router']

Expand All @@ -40,6 +41,7 @@ const FeatureHistoryPage: FC<FeatureHistoryPageType> = ({ match, router }) => {
) as any
// @ts-ignore
const environmentId = `${env?.id}`
const environmentApiKey = `${env?.api_key}`
const { data: users } = useGetUsersQuery({
organisationId: AccountStore.getOrganisation().id,
})
Expand Down Expand Up @@ -99,6 +101,9 @@ const FeatureHistoryPage: FC<FeatureHistoryPageType> = ({ match, router }) => {
<div className='table-column' style={{ width: widths[1] }}>
View
</div>
<div className='table-column' style={{ width: widths[1] }}>
Compare
</div>
</Row>
}
renderRow={(v: TFeatureVersion, i: number) => {
Expand All @@ -117,7 +122,19 @@ const FeatureHistoryPage: FC<FeatureHistoryPageType> = ({ match, router }) => {
? `${user.first_name || ''} ${user.last_name || ''} `
: 'System '}
</div>

<div className='table-column' style={{ width: widths[1] }}>
<Link
to={`/project/${match.params.projectId}/environment/${environmentApiKey}/history/${v.uuid}/`}
>
<Button
theme='text'
className='px-0 text-primary'
size='xSmall'
>
View Details
</Button>
</Link>
</div>
<div className='table-column' style={{ width: widths[1] }}>
{i + 1 !== data!.results.length && (
<>
Expand Down Expand Up @@ -152,7 +169,7 @@ const FeatureHistoryPage: FC<FeatureHistoryPageType> = ({ match, router }) => {
theme='text'
size='xSmall'
>
Compare
Quick compare
</Button>
</div>
)}
Expand Down