Skip to content

Commit

Permalink
Lisa/manual testing bugs (gravitational#189)
Browse files Browse the repository at this point in the history
* Allow searching user list by auth types
* Expand parent when children gets selected before parent
* Add back requestId param for renewSession api route (got lost during merge)
* Update Users storybook to include different write permissions
* Roles: hide edit/delete button depending on permission
* UploadForm style update
* Allow audit log searching for created dates
* Side nav, expand parent if child is selected first
* Css update and update snapshot
* Display view documentation when user can't create app
* Remove bg color for quicklaunch label

Co-authored-by: Alexey Kontsevoy <[email protected]>
  • Loading branch information
Lisa Kim and alex-kovoy authored Nov 12, 2020
1 parent 0b04d99 commit b775d4a
Show file tree
Hide file tree
Showing 27 changed files with 260 additions and 250 deletions.
3 changes: 1 addition & 2 deletions web/packages/design/src/DataTable/StyledTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ export const StyledTable = styled.table(
tbody tr:hover {
background-color: ${darken(props.theme.colors.primary.lighter, 0.14)};
:last-child {
td:first-child {
border-bottom-left-radius: 8px;
}
td:last-child {
border-bottom-right-radius: 8px;
}
Expand Down
4 changes: 2 additions & 2 deletions web/packages/design/src/DataTable/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Table extends React.Component {
}

return (
<tbody>
<tfoot>
<tr>
<td colSpan={children ? children.length : 0}>
<Text
Expand All @@ -87,7 +87,7 @@ class Table extends React.Component {
</Text>
</td>
</tr>
</tbody>
</tfoot>
);
}

Expand Down
1 change: 1 addition & 0 deletions web/packages/shared/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const StyledSelect = styled.div`
.react-select__control {
&:hover {
border-color: transparent;
cursor: pointer;
}
}
Expand Down
12 changes: 12 additions & 0 deletions web/packages/teleport/src/Apps/Apps.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ export const Empty = () => {

ctx.isEnterprise = true;
ctx.storeUser.setState({ acl });
ctx.storeUser.state.acl.tokens.create = true;
ctx.appService.fetchApps = () => Promise.resolve([]);
return render(ctx);
};

export const EmptyReadOnly = () => {
const ctx = new Context();
const acl = makeAcl(sample.acl);

ctx.isEnterprise = true;
ctx.storeUser.setState({ acl });
ctx.storeUser.state.acl.tokens.create = false;
ctx.appService.fetchApps = () => Promise.resolve([]);
return render(ctx);
};
Expand Down
2 changes: 2 additions & 0 deletions web/packages/teleport/src/Apps/Apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function Container() {

export function Apps(props: State) {
const {
clusterId,
isEnterprise,
isAddAppVisible,
showAddApp,
Expand Down Expand Up @@ -66,6 +67,7 @@ export function Apps(props: State) {
{hasApps && <AppList apps={apps} />}
{isEmpty && (
<Empty
clusterId={clusterId}
isEnterprise={isEnterprise}
canCreate={canCreate}
onCreate={showAddApp}
Expand Down
31 changes: 30 additions & 1 deletion web/packages/teleport/src/Apps/Empty/Empty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@ import ButtonAdd from './../ButtonAdd';
import { emptyPng } from './assets';

export default function Empty(props: Props) {
// always show the welcome for enterprise users who have access to create an app
if (!props.canCreate) {
return (
<Box
p="8"
m="0 auto"
width="100%"
maxWidth="600px"
textAlign="center"
color="text.primary"
bg="primary.light"
borderRadius="12px"
{...props}
>
<Text typography="h2" mb="3">
No Applications Found
</Text>
<Text>
There are no applications for the "
<Text as="span" bold>
{props.clusterId}
</Text>
" cluster
</Text>
</Box>
);
}

return (
<Card maxWidth="700px" mx="auto" py={4} as={Flex} alignItems="center">
<Box mx="4">
Expand Down Expand Up @@ -52,8 +80,9 @@ export default function Empty(props: Props) {
);
}

type Props = {
export type Props = {
isEnterprise: boolean;
canCreate: boolean;
onCreate(): void;
clusterId: string;
};
1 change: 1 addition & 0 deletions web/packages/teleport/src/Apps/useApps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function useApps() {
}, [clusterId]);

return {
clusterId,
isEnterprise,
isAddAppVisible,
hideAddApp,
Expand Down
7 changes: 6 additions & 1 deletion web/packages/teleport/src/Audit/EventList/EventList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Event } from 'teleport/services/audit';
import { ActionCell, TimeCell, DescCell } from './EventListCells';
import TypeCell from './EventTypeCell';
import EventDialog from '../EventDialog';
import { displayDateTime } from 'shared/services/loc';

export default function EventList(props: Props) {
const { clusterId, events = [], search = '' } = props;
Expand Down Expand Up @@ -63,7 +64,11 @@ export default function EventList(props: Props) {
const filtered = events.filter(obj =>
isMatch(obj, search, {
searchableProps: searchableProps,
cb: null,
cb: (target, search, prop) => {
if (prop === 'time') {
return displayDateTime(target).includes(search);
}
},
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2173,7 +2173,7 @@ exports[`overflow 1`] = `
<th />
</tr>
</thead>
<tbody>
<tfoot>
<tr>
<td
colspan="4"
Expand All @@ -2191,7 +2191,7 @@ exports[`overflow 1`] = `
</div>
</td>
</tr>
</tbody>
</tfoot>
</table>
</div>
</div>
Expand Down
53 changes: 31 additions & 22 deletions web/packages/teleport/src/AuthConnectors/AuthConnectors.story.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/*
Copyright 2020 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,30 +12,38 @@ limitations under the License.
*/

import React from 'react';
import { Context, ContextProvider } from 'teleport';
import AuthConnectors from './AuthConnectors';
import { AuthConnectors } from './AuthConnectors';

export default {
title: 'Teleport/AuthConnectors',
};

export function Processing() {
const attempt = {
isProcessing: true,
isFailed: false,
isSuccess: false,
message: '',
};
return <AuthConnectors {...sample} attempt={attempt} />;
}

export function Loaded() {
const ctx = new Context();
ctx.resourceService.fetchAuthConnectors = () => Promise.resolve(connectors);
return render(ctx);
return <AuthConnectors {...sample} />;
}

export function Empty() {
const ctx = new Context();
ctx.resourceService.fetchAuthConnectors = () => Promise.resolve([]);
return render(ctx);
return <AuthConnectors {...sample} items={[]} />;
}

export function Failed() {
const ctx = new Context();
ctx.resourceService.fetchAuthConnectors = () =>
Promise.reject(new Error('failed to load'));
return render(ctx);
const attempt = {
isProcessing: false,
isFailed: true,
isSuccess: false,
message: 'some error message',
};
return <AuthConnectors {...sample} attempt={attempt} />;
}

const connectors = [
Expand Down Expand Up @@ -68,10 +73,14 @@ const connectors = [
},
];

function render(ctx: Context) {
return (
<ContextProvider ctx={ctx}>
<AuthConnectors />
</ContextProvider>
);
}
const sample = {
attempt: {
isProcessing: false,
isFailed: false,
isSuccess: true,
message: '',
},
items: connectors,
remove: () => null,
save: () => null,
};
42 changes: 23 additions & 19 deletions web/packages/teleport/src/AuthConnectors/AuthConnectors.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/*
Copyright 2020 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -28,36 +25,43 @@ import EmptyList from './EmptyList';
import ConnectorList from './ConnectorList';
import DeleteConnectorDialog from './DeleteConnectorDialog';
import AddMenu from './AddMenu';
import useAuthConnectors from './useAuthConnectors';
import useAuthConnectors, { State } from './useAuthConnectors';
import templates from './templates';

export default function AuthConnectors() {
const connectors = useAuthConnectors();
const { message, isProcessing, isFailed, isSuccess } = connectors.attempt;
const isEmpty = connectors.items.length === 0;
const resources = useResources(connectors.items, templates);
export default function Container() {
const state = useAuthConnectors();
return <AuthConnectors {...state} />;
}

export function AuthConnectors(props: State) {
const { attempt, items, remove, save } = props;
const { message, isProcessing, isFailed, isSuccess } = attempt;
const isEmpty = items.length === 0;
const resources = useResources(items, templates);

const title =
resources.status === 'creating'
? 'Creating a new auth connector'
: 'Editing auth connector';

function remove() {
return connectors.remove(resources.item);
function handleOnRemove() {
return remove(resources.item);
}

function save(content: string) {
function handleOnSave(content: string) {
const isNew = resources.status === 'creating';
return connectors.save(content, isNew);
return save(content, isNew);
}

return (
<FeatureBox>
<FeatureHeader>
<FeatureHeaderTitle>Auth Connectors</FeatureHeaderTitle>
<Box ml="auto" alignSelf="center" width="240px">
<AddMenu onClick={resources.create} />
</Box>
{isSuccess && (
<Box ml="auto" alignSelf="center" width="240px">
<AddMenu onClick={resources.create} />
</Box>
)}
</FeatureHeader>
{isFailed && <Danger>{message} </Danger>}
{isProcessing && (
Expand All @@ -75,7 +79,7 @@ export default function AuthConnectors() {
{!isEmpty && (
<ConnectorList
flex="1"
items={connectors.items}
items={items}
onEdit={resources.edit}
onDelete={resources.remove}
/>
Expand Down Expand Up @@ -113,7 +117,7 @@ export default function AuthConnectors() {
{(resources.status === 'creating' || resources.status === 'editing') && (
<ResourceEditor
title={title}
onSave={save}
onSave={handleOnSave}
text={resources.item.content}
name={resources.item.name}
isNew={resources.status === 'creating'}
Expand All @@ -124,7 +128,7 @@ export default function AuthConnectors() {
<DeleteConnectorDialog
name={resources.item.name}
onClose={resources.disregard}
onDelete={remove}
onDelete={handleOnRemove}
/>
)}
</FeatureBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ export default function useAuthConnectors() {
remove,
};
}

export type State = ReturnType<typeof useAuthConnectors>;
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ exports[`render DocumentNodes 1`] = `
border: 1px solid;
border-radius: 4px;
border-color: rgba(255,255,255,0.24);
background-color: #111b48;
}
.c11 {
Expand Down Expand Up @@ -393,6 +392,7 @@ exports[`render DocumentNodes 1`] = `
.c7 .react-select__control:hover {
border-color: transparent;
cursor: pointer;
}
.c7 .react-select__control--is-focused {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ export default class UploadForm extends React.Component<PropType> {
ref={this.refDropzone}
onDragOver={e => e.preventDefault()}
onDrop={this.onDrop}
onClick={this.onOpenFilePicker}
>
<a onClick={this.onOpenFilePicker}>{dropZoneText}</a>
{dropZoneText}
</Dropzone>
<Elements.Button disabled={isDldBtnDisabled} onClick={this.onUpload}>
Upload
Expand All @@ -179,4 +180,5 @@ const Dropzone = styled.div`
line-height: 72px;
text-align: center;
text-transform: uppercase;
cursor: pointer;
`;
Loading

0 comments on commit b775d4a

Please sign in to comment.