Skip to content

Commit

Permalink
Merge pull request #133 from kloudlite/release-v1.0.3
Browse files Browse the repository at this point in the history
Release v1.0.3
  • Loading branch information
abdheshnayak authored Mar 10, 2024
2 parents 97924a6 + 8a21a26 commit 59a8f63
Show file tree
Hide file tree
Showing 73 changed files with 2,375 additions and 1,096 deletions.
4 changes: 2 additions & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tasks:
interactive: true
cmds:
- |
BASE_URL=dev.kloudlite.io
BASE_URL=gcp-production.kloudlite.io
COOKIE_DOMAIN=".kloudlite.io"
GATEWAY_URL="http://gateway.kloudlite.svc.cluster.local"
case {{.app}} in
Expand Down Expand Up @@ -55,7 +55,7 @@ tasks:
esac
REMIX_DEV_ORIGIN="https://{{.app}}$URL_SUFFIX.dev.kloudlite.io"
REMIX_DEV_ORIGIN="https://{{.app}}$URL_SUFFIX.$BASE_URL"
cp -r ./static/common/. ./public/
cp -r ./static/{{.app}}/. ./public/
Expand Down
40 changes: 15 additions & 25 deletions gql-queries-generator/doc/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ query consoleGetAccount($accountName: String!) {
name
annotations
}
targetNamespace
updateTime
contactEmail
displayName
Expand Down Expand Up @@ -300,10 +301,6 @@ query consoleListClusters($search: SearchCluster, $pagination: CursorPaginationI
spec {
messageQueueTopicName
kloudliteRelease
credentialsRef {
namespace
name
}
clusterTokenRef {
key
name
Expand Down Expand Up @@ -398,18 +395,6 @@ query consoleGetCluster($name: String!) {
name
namespace
}
credentialKeys {
keyAccessKey
keyAWSAccountId
keyAWSAssumeRoleExternalID
keyAWSAssumeRoleRoleARN
keyIAMInstanceProfileRole
keySecretKey
}
credentialsRef {
name
namespace
}
kloudliteRelease
messageQueueTopicName
output {
Expand Down Expand Up @@ -480,15 +465,15 @@ query consoleListProviderSecrets($search: SearchProviderSecret, $pagination: Cur
edges {
cursor
node {
aws {
awsAccountId
}
cloudProviderName
createdBy {
userEmail
userId
userName
}
aws {
authMechanism
}
creationTime
displayName
lastUpdatedBy {
Expand Down Expand Up @@ -528,9 +513,6 @@ mutation consoleDeleteProviderSecret($secretName: String!) {

query consoleGetProviderSecret($name: String!) {
infra_getProviderSecret(name: $name) {
aws {
awsAccountId
}
cloudProviderName
createdBy {
userEmail
Expand Down Expand Up @@ -3250,22 +3232,24 @@ query consoleListManagedResources($projectName: String!, $envName: String!, $sea
}
creationTime
displayName
enabled
environmentName
lastUpdatedBy {
userEmail
userId
userName
}
markedForDeletion
metadata {
annotations
creationTimestamp
deletionTimestamp
generation
labels
name
namespace
}
projectName
recordVersion
spec {
resourceName
resourceTemplate {
apiVersion
kind
Expand Down Expand Up @@ -3293,6 +3277,12 @@ query consoleListManagedResources($projectName: String!, $envName: String!, $sea
namespace
}
}
syncedOutputSecretRef {
metadata {
name
namespace
}
}
syncStatus {
action
error
Expand Down
44 changes: 41 additions & 3 deletions lib/client/helpers/socket/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Context = createContext<{
});

export const useSubscribe = <T extends IData>(
msg: ISocketMsg<T>,
msg: ISocketMsg<T> | ISocketMsg<T>[],
dep: never[]
) => {
const {
Expand All @@ -74,8 +74,31 @@ export const useSubscribe = <T extends IData>(

useEffect(() => {
(async () => {
setResp(responses[msg.for]?.[msg.data.id || 'default'] || []);
if (Array.isArray(msg)) {
setResp(resp);

const tr: ISocketResp[] = [];
const terr: ISocketResp[] = [];
const ti: ISocketResp[] = [];

for (let k = 0; k < msg.length; k += 1) {
const m = msg[k];

tr.push(...(responses[m.for]?.[m.data.id || 'default'] || []));
terr.push(...(e[m.for]?.[m.data.id || 'default'] || []));
ti.push(...(i[m.for]?.[m.data.id || 'default'] || []));
}
setResp(tr);
setErrors(terr);
setInfos(ti);

if (tr.length || ti.length) {
setSubscribed(true);
}
return;
}

setResp(responses[msg.for]?.[msg.data.id || 'default'] || []);
setErrors(e[msg.for]?.[msg.data.id || 'default'] || []);
setInfos(i[msg.for]?.[msg.data.id || 'default'] || []);

Expand All @@ -88,10 +111,25 @@ export const useSubscribe = <T extends IData>(
useDebounce(
() => {
console.log('subscribing');
sendMsg({ ...msg, data: { ...msg.data, event: 'subscribe' } });
if (Array.isArray(msg)) {
msg.forEach((m) => {
sendMsg({ ...m, data: { ...m.data, event: 'subscribe' } });
});
} else {
sendMsg({ ...msg, data: { ...msg.data, event: 'subscribe' } });
}

return () => {
console.log('unsubscribing');
if (Array.isArray(msg)) {
msg.forEach((m) => {
clear(m);
setSubscribed(false);
sendMsg({ ...m, data: { ...m.data, event: 'unsubscribe' } });
});
return;
}

clear(msg);
setSubscribed(false);
sendMsg({ ...msg, data: { ...msg.data, event: 'unsubscribe' } });
Expand Down
47 changes: 34 additions & 13 deletions lib/client/helpers/socket/useWatch.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import { useEffect } from 'react';
import { useCallback, useEffect } from 'react';
import { ISocketResp, useSubscribe } from './context';
import { useReload } from '../reloader';

export const useSocketWatch = (
onUpdate: (v: ISocketResp<any>[]) => void,
topic: string
topic: string | string[]
) => {
const { responses, subscribed } = useSubscribe(
{
for: 'resource-update',
data: {
id: topic,
respath: topic,
},
},
Array.isArray(topic)
? topic.map((t) => {
return {
for: 'resource-update',
data: {
id: t,
respath: t,
},
};
})
: {
for: 'resource-update',
data: {
id: topic,
respath: topic,
},
},
[]
);

Expand All @@ -24,12 +34,23 @@ export const useSocketWatch = (
}, [responses]);
};

export const useWatchReload = (topic: string) => {
export const useWatchReload = (topic: string | string[]) => {
const reloadPage = useReload();
const topicMap: {
[key: string]: boolean;
} = useCallback(
() =>
Array.isArray(topic)
? topic.reduce((acc, curr) => {
return { ...acc, [curr]: true };
}, {})
: { [topic]: true },
[topic]
)();

useSocketWatch((rd) => {
console.log(rd);
if (rd.find((v) => v.id === topic)) {
console.log('reloading due to watch event', rd);
if (rd.find((v) => topicMap[v.id])) {
console.log('reloading due to watch event');
reloadPage();
}
}, topic);
Expand Down
4 changes: 2 additions & 2 deletions src/apps/console/components/code-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ICodeView {
const CodeView = ({
data,
copy,
showShellPrompt,
showShellPrompt: _,
language = 'shell',
title,
}: ICodeView) => {
Expand Down Expand Up @@ -55,7 +55,7 @@ const CodeView = ({
}}
className="group/sha cursor-pointer p-lg rounded-md bodyMd flex flex-row gap-xl items-center hljs w-full"
>
<pre className="flex-1">
<pre className="flex-1 overflow-auto">
<code ref={ref}>{data}</code>
</pre>

Expand Down
Loading

0 comments on commit 59a8f63

Please sign in to comment.