Skip to content

Commit 83a5918

Browse files
authored
Merge pull request #108 from dockersamples/106-open-files-from-links
Prettier updates
2 parents 9e0c5a4 + d8fdf4c commit 83a5918

File tree

7 files changed

+57
-58
lines changed

7 files changed

+57
-58
lines changed

components/interface/client/src/WorkshopContext.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,4 @@ export const useSaveFileCommand = () => {
196196

197197
export const useOpenFile = () => {
198198
return useContext(WorkshopContext).openFile;
199-
}
199+
};

components/interface/client/src/components/WorkshopPanel/markdown/FileLink.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useOpenFile } from "../../../WorkshopContext";
33
export function FileLink({ path, line, children }) {
44
const openFile = useOpenFile();
55

6-
const lineAsNumber = (line) ? parseInt(line, 10) : undefined;
6+
const lineAsNumber = line ? parseInt(line, 10) : undefined;
77

88
return (
99
<a

dd-extension/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@ To develop the extension, run the following steps:
88

99
1. Install the NPM dependencies:
1010

11-
```console
12-
npm install
13-
```
11+
```console
12+
npm install
13+
```
1414

1515
2. Start the app:
1616

17-
```console
18-
npm run dev
19-
```
17+
```console
18+
npm run dev
19+
```
2020

2121
3. If you don't have the extension installed yet, install it:
2222

23-
```console
24-
docker extension install dockersamples/labspace-extension
25-
```
23+
```console
24+
docker extension install dockersamples/labspace-extension
25+
```
2626

2727
4. Enable debug mode for the extension (to get the Chrome developer tools):
2828

29-
```console
30-
docker extension dev debug dockersamples/labspace-extension
31-
```
29+
```console
30+
docker extension dev debug dockersamples/labspace-extension
31+
```
3232

3333
5. Set the UI source for the extension to be your development environment:
3434

35-
```console
36-
docker extension dev ui-source dockersamples/labspace-extension http://localhost:5173
37-
```
35+
```console
36+
docker extension dev ui-source dockersamples/labspace-extension http://localhost:5173
37+
```
3838

3939
6. Open the extension in Docker Desktop. It will now be using the Vite reload server for the UI, allowing you to make changes and see them reflected immediately.
4040

@@ -46,4 +46,4 @@ Once the extension is installed, deep links can be used to launch a Labspace.
4646
http://open.docker.com/dashboard/extension-tab?extensionId=dockersamples/labspace-extension&location=PUBLISHED_LABSPACE_URL&title=TITLE
4747
```
4848

49-
[Click here](http://open.docker.com/dashboard/extension-tab?extensionId=dockersamples/labspace-extension&location=dockersamples/labspace-container-supported-development&title=Demo) to launch a sample Labspace
49+
[Click here](http://open.docker.com/dashboard/extension-tab?extensionId=dockersamples/labspace-extension&location=dockersamples/labspace-container-supported-development&title=Demo) to launch a sample Labspace

dd-extension/src/DockerContext.jsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function DockerContextProvider({ children }) {
2424
? JSON.parse(localStorage.getItem("custom-labspaces"))
2525
: [],
2626
);
27-
27+
2828
const [hasLabspace, setHasLabspace] = useState(false);
2929
const [runningLabspace, setRunningLabspace] = useState(null);
3030
const [startingLabspace, setStartingLabspace] = useState(null);
@@ -41,7 +41,7 @@ export function DockerContextProvider({ children }) {
4141
.then((res) => res.text())
4242
.then((text) => parse(text))
4343
.then((data) => data.labspaces || []),
44-
)
44+
),
4545
).then((results) => {
4646
setLabspaces(results.flat());
4747
});
@@ -102,23 +102,15 @@ export function DockerContextProvider({ children }) {
102102

103103
ddClient.docker.cli.exec(
104104
"compose",
105-
[
106-
"-f",
107-
`oci://${location}`,
108-
"-p",
109-
"labspace",
110-
"up",
111-
"-d",
112-
"-y",
113-
],
105+
["-f", `oci://${location}`, "-p", "labspace", "up", "-d", "-y"],
114106
{
115107
stream: {
116108
onOutput(data) {
117109
const newData = data.stdout ? data.stdout : data.stderr;
118110
let result;
119111
newData.split("\n").forEach((line) => {
120112
if (line.trim() === "") return;
121-
113+
122114
result = logProcessor.processLine(line.trim());
123115
});
124116
setLaunchLog(result);
@@ -145,13 +137,18 @@ export function DockerContextProvider({ children }) {
145137

146138
const removeLabspace = useCallback(
147139
(publishedRepo) => {
148-
setAdditionalLabspaces((labs) => labs.filter((l) => l.publishedRepo !== publishedRepo));
140+
setAdditionalLabspaces((labs) =>
141+
labs.filter((l) => l.publishedRepo !== publishedRepo),
142+
);
149143
},
150144
[setAdditionalLabspaces],
151145
);
152146

153147
useEffect(() => {
154-
localStorage.setItem("custom-labspaces", JSON.stringify(additionalLabspaces));
148+
localStorage.setItem(
149+
"custom-labspaces",
150+
JSON.stringify(additionalLabspaces),
151+
);
155152
}, [additionalLabspaces]);
156153

157154
if (!labspaces) {
@@ -160,7 +157,7 @@ export function DockerContextProvider({ children }) {
160157
<Spinner />
161158
<p>Loading...</p>
162159
</div>
163-
)
160+
);
164161
}
165162

166163
return (
@@ -176,7 +173,9 @@ export function DockerContextProvider({ children }) {
176173
startingLabspace,
177174
launchLog,
178175

179-
highlightedLabspaces: labspaces.filter(l => l.highlighted).slice(0, 3),
176+
highlightedLabspaces: labspaces
177+
.filter((l) => l.highlighted)
178+
.slice(0, 3),
180179
labspaces: additionalLabspaces,
181180
addLabspace,
182181
removeLabspace,

dd-extension/src/Home.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ export function Home() {
101101
{labspaces.map((labspace) => (
102102
<tr key={labspace.title}>
103103
<td className="align-middle">{labspace.title}</td>
104-
<td className="align-middle">
105-
{labspace.publishedRepo}
106-
</td>
104+
<td className="align-middle">{labspace.publishedRepo}</td>
107105
<td className="text-end">
108106
<Button
109107
variant="primary"
@@ -138,7 +136,11 @@ export function Home() {
138136

139137
<UrlHandlingModal
140138
onLaunchConfirmation={(title, location) => {
141-
if ([...highlightedLabspaces, ...labspaces].find((l) => l.location === location) === undefined)
139+
if (
140+
[...highlightedLabspaces, ...labspaces].find(
141+
(l) => l.location === location,
142+
) === undefined
143+
)
142144
addLabspace(title, location);
143145
startLabspace(location);
144146
}}

dd-extension/src/components/LabspaceCard.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ export function LabspaceCard({ labspace, onLaunch, starting, running }) {
99
<Card.Text>{labspace.description}</Card.Text>
1010
</Card.Body>
1111
<Card.Footer className="d-flex align-items-center justify-content-between">
12-
<div>
13-
Created by { labspace.author }
14-
</div>
12+
<div>Created by {labspace.author}</div>
1513
<Button onClick={onLaunch} disabled={starting || running}>
1614
{starting ? "Starting..." : "Launch"}
1715
</Button>

dd-extension/src/logProcessor.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ export class LogProcessor {
1414

1515
processLine(line) {
1616
const downloadMatch = line.match(this.downloadPattern);
17-
17+
1818
if (downloadMatch) {
19-
const identifier = downloadMatch[1].trim();
19+
const identifier = downloadMatch[1].trim();
2020

21-
if (this.identifierToLineMapping.has(identifier)) {
22-
this.lines[this.identifierToLineMapping.get(identifier)] = line;
23-
} else {
24-
this.identifierToLineMapping.set(identifier, this.lines.length);
25-
this.lines.push(line);
26-
}
21+
if (this.identifierToLineMapping.has(identifier)) {
22+
this.lines[this.identifierToLineMapping.get(identifier)] = line;
23+
} else {
24+
this.identifierToLineMapping.set(identifier, this.lines.length);
25+
this.lines.push(line);
26+
}
2727
} else if (this.resourceCreationPattern.test(line)) {
28-
const identifier = line.match(this.resourceCreationPattern)[2];
29-
if (this.identifierToLineMapping.has(identifier)) {
30-
this.lines[this.identifierToLineMapping.get(identifier)] = line;
31-
} else {
32-
this.identifierToLineMapping.set(identifier, this.lines.length);
33-
this.lines.push(line);
34-
}
35-
} else {
28+
const identifier = line.match(this.resourceCreationPattern)[2];
29+
if (this.identifierToLineMapping.has(identifier)) {
30+
this.lines[this.identifierToLineMapping.get(identifier)] = line;
31+
} else {
32+
this.identifierToLineMapping.set(identifier, this.lines.length);
3633
this.lines.push(line);
34+
}
35+
} else {
36+
this.lines.push(line);
3737
}
3838

3939
return this.lines.join("\n");
4040
}
41-
}
41+
}

0 commit comments

Comments
 (0)