Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9b7d4c0
Expose tsh client in `AppContext`
gzdunek Dec 1, 2023
95984dc
Change `unifiedResourcePreferences` to accept `Attempt`
gzdunek Dec 1, 2023
0e45b63
Add `unifiedResourcePreferencesFallback` and `updateUnifiedResourcesP…
gzdunek Dec 5, 2023
4ab9d92
Add `UnifiedResourcePreferences` to workspace state, so it can be use…
gzdunek Dec 5, 2023
c27203a
Add support for user preferences in Connect
gzdunek Dec 5, 2023
5a5f812
Add more `UnifiedResources` stories
gzdunek Dec 7, 2023
380b213
Add descriptions to error messages
gzdunek Dec 7, 2023
97017c5
Simplify errors rendering
gzdunek Dec 7, 2023
44b39a2
Use smaller margins in `DocumentCluster`
gzdunek Dec 7, 2023
79fa022
Parse unified resource preferences read from disk in zod
gzdunek Dec 7, 2023
25da530
Fix DELETE IN comments
gzdunek Dec 8, 2023
6283788
Move `unifiedResourcePreferencesSchema` outside the function
gzdunek Dec 8, 2023
9b5f7e4
Remove `workspacesService.useState()`
gzdunek Dec 8, 2023
a55d932
Show skeleton when `unifiedResourcePreferencesAttempt` is processing
gzdunek Dec 8, 2023
1e467bf
Run Prettier
gzdunek Dec 8, 2023
5099bc3
Import `renderHook` from correct package
gzdunek Dec 8, 2023
386e7cc
Add `retryWithRelogin`
gzdunek Dec 8, 2023
c857b96
Revert sync `unifiedResourcePreferences`
gzdunek Dec 8, 2023
763be7a
Refactor `useUserPreferences`
gzdunek Dec 8, 2023
7ced963
Rename `userPreferences.test.tsx` to `useUserPreferences.ts`
gzdunek Dec 8, 2023
51759c8
Do not show 'pinning not supported' and 'no results' errors at the sa…
gzdunek Dec 8, 2023
a218613
Check for `''` too when calculating `isProcessing`
gzdunek Dec 8, 2023
45664d9
Small fixes
gzdunek Dec 8, 2023
df5b44e
Remove an unneeded story
gzdunek Dec 8, 2023
40d0a2f
Fix tests and lint
gzdunek Dec 8, 2023
b9677e9
Improve handling errors when initial request is superseded, notify ab…
gzdunek Dec 12, 2023
fe8dffd
Improve comments
gzdunek Dec 12, 2023
ed1c7dd
Revert `unifiedResourcePreferences` to be required (as it was origina…
gzdunek Dec 12, 2023
bb79d9b
Improve condition for initial fetch
gzdunek Dec 12, 2023
258f0db
Test if the stale response is discarded
gzdunek Dec 12, 2023
a88f902
Support `labelsViewMode`
gzdunek Dec 12, 2023
d2a42c8
Remove `width` from expand/collapse button, so it looks good independ…
gzdunek Dec 12, 2023
27a877a
Run prettier
gzdunek Dec 12, 2023
e3a17ef
Expand comment regarding updating cluster prefs
ravicious Dec 12, 2023
bd76f15
Improve test names
gzdunek Dec 12, 2023
86e051d
Fix grammar
gzdunek Dec 12, 2023
2b92b0d
Add a comment about storing preferences in the document
gzdunek Dec 12, 2023
e792ae5
Run prettier
gzdunek Dec 13, 2023
70a5d6a
Fix license
gzdunek Dec 13, 2023
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
22 changes: 12 additions & 10 deletions lib/teleterm/apiserver/handler/handler_user_preferences.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Copyright 2023 Gravitational, Inc
// Teleport
// Copyright (C) 2023 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
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// http://www.apache.org/licenses/LICENSE-2.0
// 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 Affero General Public License for more details.
//
// 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.
// See the License for the specific language governing permissions and
// limitations under the License.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package handler

Expand Down
22 changes: 12 additions & 10 deletions lib/teleterm/services/userpreferences/userpreferences.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Copyright 2023 Gravitational, Inc
// Teleport
// Copyright (C) 2023 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
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// http://www.apache.org/licenses/LICENSE-2.0
// 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 Affero General Public License for more details.
//
// 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.
// See the License for the specific language governing permissions and
// limitations under the License.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package userpreferences

Expand Down
22 changes: 12 additions & 10 deletions lib/teleterm/services/userpreferences/userpreferences_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Copyright 2023 Gravitational, Inc
// Teleport
// Copyright (C) 2023 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
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// http://www.apache.org/licenses/LICENSE-2.0
// 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 Affero General Public License for more details.
//
// 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.
// See the License for the specific language governing permissions and
// limitations under the License.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package userpreferences

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export function FilterPanel({
padding-left: ${props => props.theme.space[2]}px;
padding-right: ${props => props.theme.space[2]}px;
height: 22px;
width: 128px;
`}
onClick={() => setExpandAllLabels(!expandAllLabels)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ import {
LabelsViewMode,
} from 'shared/services/unifiedResourcePreferences';

import { UnifiedResources, useUnifiedResourcesFetch } from './UnifiedResources';
import { makeErrorAttempt, makeProcessingAttempt } from 'shared/hooks/useAsync';

import {
SharedUnifiedResource,
UnifiedResourcesPinning,
UnifiedResourcesQueryParams,
} from './types';
UnifiedResources,
useUnifiedResourcesFetch,
UnifiedResourcesProps,
} from './UnifiedResources';
import { SharedUnifiedResource, UnifiedResourcesQueryParams } from './types';

export default {
title: 'Shared/UnifiedResources',
Expand Down Expand Up @@ -77,14 +79,13 @@ const story = ({
updateClusterPinnedResources: async () => undefined,
},
params,
...props
}: {
fetchFunc: (
params: UrlResourcesParams,
signal: AbortSignal
) => Promise<ResourcesResponse<SharedUnifiedResource['resource']>>;
pinning?: UnifiedResourcesPinning;
params?: Partial<UnifiedResourcesQueryParams>;
}) => {
} & Omit<Partial<UnifiedResourcesProps>, 'fetchResources'>) => {
const mergedParams: UnifiedResourcesQueryParams = {
...{
sort: {
Expand Down Expand Up @@ -141,6 +142,7 @@ const story = ({
ActionButton: <ButtonBorder size="small">Connect</ButtonBorder>,
},
}))}
{...props}
/>
);
};
Expand Down Expand Up @@ -182,13 +184,13 @@ export const LoadingAfterScrolling = story({
},
});

export const Errored = story({
export const Failed = story({
fetchFunc: async () => {
throw new Error('Failed to fetch');
},
});

export const ErroredAfterScrolling = story({
export const FailedAfterScrolling = story({
fetchFunc: async params => {
if (params.startKey === 'next-key') {
throw new Error('Failed to fetch');
Expand All @@ -197,6 +199,22 @@ export const ErroredAfterScrolling = story({
},
});

export const FailedToLoadPreferences = story({
fetchFunc: async () => ({
agents: allResources,
}),
unifiedResourcePreferencesAttempt: makeErrorAttempt(
new Error('Network error')
),
});

export const LoadingPreferences = story({
fetchFunc: async () => ({
agents: allResources,
}),
unifiedResourcePreferencesAttempt: makeProcessingAttempt(),
});

export const PinningNotSupported = story({
fetchFunc: async () => {
return { agents: allResources, startKey: 'next-key' };
Expand Down
Loading