From 47277a68ec8dd2be18877af1e698ed7a4de00ff1 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 13 Sep 2024 18:24:37 +0200 Subject: [PATCH 01/10] Create remove-labels-assignees-on-close.yml --- .../remove-labels-assignees-on-close.yml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/remove-labels-assignees-on-close.yml diff --git a/.github/workflows/remove-labels-assignees-on-close.yml b/.github/workflows/remove-labels-assignees-on-close.yml new file mode 100644 index 000000000..584842290 --- /dev/null +++ b/.github/workflows/remove-labels-assignees-on-close.yml @@ -0,0 +1,38 @@ +name: Remove Labels and Assignees on Issue Close + +on: + issues: + types: [closed] + pull_request: + types: [closed] + +jobs: + remove-labels-and-assignees: + runs-on: ubuntu-latest + steps: + - name: Remove all labels and assignees + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const issue = context.payload.issue || context.payload.pull_request; + const repo = context.repo; + + // Remove all labels + await github.rest.issues.removeAllLabels({ + owner: repo.owner, + repo: repo.name, + issue_number: issue.number + }); + + // Remove all assignees + if (issue.assignees && issue.assignees.length > 0) { + await github.rest.issues.removeAssignees({ + owner: repo.owner, + repo: repo.name, + issue_number: issue.number, + assignees: issue.assignees.map(assignee => assignee.login) + }); + } + + console.log(`Removed all labels and assignees from issue/PR #${issue.number}`); \ No newline at end of file From 7948a0309fbff8a1f3615170ff9a532b22e21706 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Fri, 13 Sep 2024 18:42:38 +0200 Subject: [PATCH 02/10] Feat: remove labels and assignees on issue close --- .../remove-labels-and-assignees-on-close.yml | 57 +++++++++++++++++++ .../remove-labels-assignees-on-close.yml | 38 ------------- 2 files changed, 57 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/remove-labels-and-assignees-on-close.yml delete mode 100644 .github/workflows/remove-labels-assignees-on-close.yml diff --git a/.github/workflows/remove-labels-and-assignees-on-close.yml b/.github/workflows/remove-labels-and-assignees-on-close.yml new file mode 100644 index 000000000..a2291f7f9 --- /dev/null +++ b/.github/workflows/remove-labels-and-assignees-on-close.yml @@ -0,0 +1,57 @@ +name: Remove Labels and Assignees on Issue Close + +on: + issues: + types: [closed] + pull_request: + types: [closed] + +jobs: + remove-labels-and-assignees: + runs-on: ubuntu-latest + steps: + - name: Remove labels and assignees + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issue = context.payload.issue || context.payload.pull_request; + const { owner, repo } = context.repo; + + try { + const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({ + owner, + repo, + issue_number: issue.number + }); + + const labelsToKeep = currentLabels + .filter(label => label.name === '⏱︎ Stale') + .map(label => label.name); + + await github.rest.issues.setLabels({ + owner, + repo, + issue_number: issue.number, + labels: labelsToKeep + }); + } catch (error) { + if (error.status !== 404) { + throw error; + } + } + + if (issue.assignees && issue.assignees.length > 0) { + try { + await github.rest.issues.removeAssignees({ + owner, + repo, + issue_number: issue.number, + assignees: issue.assignees.map(assignee => assignee.login) + }); + } catch (error) { + if (error.status !== 404) { + throw error; + } + } + } diff --git a/.github/workflows/remove-labels-assignees-on-close.yml b/.github/workflows/remove-labels-assignees-on-close.yml deleted file mode 100644 index 584842290..000000000 --- a/.github/workflows/remove-labels-assignees-on-close.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Remove Labels and Assignees on Issue Close - -on: - issues: - types: [closed] - pull_request: - types: [closed] - -jobs: - remove-labels-and-assignees: - runs-on: ubuntu-latest - steps: - - name: Remove all labels and assignees - uses: actions/github-script@v6 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - const issue = context.payload.issue || context.payload.pull_request; - const repo = context.repo; - - // Remove all labels - await github.rest.issues.removeAllLabels({ - owner: repo.owner, - repo: repo.name, - issue_number: issue.number - }); - - // Remove all assignees - if (issue.assignees && issue.assignees.length > 0) { - await github.rest.issues.removeAssignees({ - owner: repo.owner, - repo: repo.name, - issue_number: issue.number, - assignees: issue.assignees.map(assignee => assignee.login) - }); - } - - console.log(`Removed all labels and assignees from issue/PR #${issue.number}`); \ No newline at end of file From 1c6450da24557dbdffd513db3af3a8fae14bd248 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:23:05 +0200 Subject: [PATCH 03/10] Feat: Make sure this action is also triggered on PR issue close --- .../remove-labels-and-assignees-on-close.yml | 87 ++++++++++++------- 1 file changed, 58 insertions(+), 29 deletions(-) diff --git a/.github/workflows/remove-labels-and-assignees-on-close.yml b/.github/workflows/remove-labels-and-assignees-on-close.yml index a2291f7f9..81f7d35f3 100644 --- a/.github/workflows/remove-labels-and-assignees-on-close.yml +++ b/.github/workflows/remove-labels-and-assignees-on-close.yml @@ -5,6 +5,11 @@ on: types: [closed] pull_request: types: [closed] + pull_request_target: + types: [closed] + workflow_run: + workflows: ["*"] + types: [completed] jobs: remove-labels-and-assignees: @@ -15,43 +20,67 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const issue = context.payload.issue || context.payload.pull_request; const { owner, repo } = context.repo; - try { - const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({ - owner, - repo, - issue_number: issue.number - }); - - const labelsToKeep = currentLabels - .filter(label => label.name === '⏱︎ Stale') - .map(label => label.name); - - await github.rest.issues.setLabels({ - owner, - repo, - issue_number: issue.number, - labels: labelsToKeep - }); - } catch (error) { - if (error.status !== 404) { - throw error; - } - } - - if (issue.assignees && issue.assignees.length > 0) { + async function processIssue(issueNumber) { try { - await github.rest.issues.removeAssignees({ + const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({ owner, repo, - issue_number: issue.number, - assignees: issue.assignees.map(assignee => assignee.login) + issue_number: issueNumber }); + + const labelsToKeep = currentLabels + .filter(label => label.name === '⏱︎ Stale') + .map(label => label.name); + + await github.rest.issues.setLabels({ + owner, + repo, + issue_number: issueNumber, + labels: labelsToKeep + }); + + const { data: issue } = await github.rest.issues.get({ + owner, + repo, + issue_number: issueNumber + }); + + if (issue.assignees && issue.assignees.length > 0) { + await github.rest.issues.removeAssignees({ + owner, + repo, + issue_number: issueNumber, + assignees: issue.assignees.map(assignee => assignee.login) + }); + } } catch (error) { if (error.status !== 404) { - throw error; + console.error(`Error processing issue ${issueNumber}:`, error); } } } + + if (context.eventName === 'issues' || context.eventName === 'pull_request' || context.eventName === 'pull_request_target') { + const issue = context.payload.issue || context.payload.pull_request; + await processIssue(issue.number); + } else if (context.eventName === 'workflow_run') { + const { data: closedIssues } = await github.rest.search.issuesAndPullRequests({ + q: `repo:${owner}/${repo} is:issue is:closed closed:${context.payload.workflow_run.updated_at}`, + per_page: 100 + }); + for (const issue of closedIssues.items) { + await processIssue(issue.number); + } + } + + if (context.eventName === 'pull_request' || context.eventName === 'pull_request_target') { + const { data: closedIssues } = await github.rest.search.issuesAndPullRequests({ + q: `repo:${owner}/${repo} is:issue is:closed linked:${context.payload.pull_request.number}`, + per_page: 100 + }); + for (const issue of closedIssues.items) { + await processIssue(issue.number); + } + } From 7037c779e2e1be4be95d72ea4326be45b0d02833 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:13:56 +0200 Subject: [PATCH 04/10] Update remove-labels-and-assignees-on-close.yml --- .../remove-labels-and-assignees-on-close.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/remove-labels-and-assignees-on-close.yml b/.github/workflows/remove-labels-and-assignees-on-close.yml index 81f7d35f3..04d62623c 100644 --- a/.github/workflows/remove-labels-and-assignees-on-close.yml +++ b/.github/workflows/remove-labels-and-assignees-on-close.yml @@ -7,9 +7,6 @@ on: types: [closed] pull_request_target: types: [closed] - workflow_run: - workflows: ["*"] - types: [completed] jobs: remove-labels-and-assignees: @@ -65,14 +62,6 @@ jobs: if (context.eventName === 'issues' || context.eventName === 'pull_request' || context.eventName === 'pull_request_target') { const issue = context.payload.issue || context.payload.pull_request; await processIssue(issue.number); - } else if (context.eventName === 'workflow_run') { - const { data: closedIssues } = await github.rest.search.issuesAndPullRequests({ - q: `repo:${owner}/${repo} is:issue is:closed closed:${context.payload.workflow_run.updated_at}`, - per_page: 100 - }); - for (const issue of closedIssues.items) { - await processIssue(issue.number); - } } if (context.eventName === 'pull_request' || context.eventName === 'pull_request_target') { From 428c40aab5fe87c1ae17d9547e1161c9a4136957 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 17 Sep 2024 12:54:23 +0200 Subject: [PATCH 05/10] chore: Update version numbers to 4.0.0-beta.339 --- config/sentry.php | 2 +- config/version.php | 2 +- other/nightly/versions.json | 4 ++-- versions.json | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index e112bf260..bc1a242c3 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.338', + 'release' => '4.0.0-beta.339', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 16bc6b80e..c67609376 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Tue, 17 Sep 2024 16:28:28 +0200 Subject: [PATCH 06/10] refactor: Add authorization check in ExecuteContainerCommand mount method --- app/Livewire/Project/Shared/ExecuteContainerCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Project/Shared/ExecuteContainerCommand.php b/app/Livewire/Project/Shared/ExecuteContainerCommand.php index 79f32ab8b..d95443621 100644 --- a/app/Livewire/Project/Shared/ExecuteContainerCommand.php +++ b/app/Livewire/Project/Shared/ExecuteContainerCommand.php @@ -33,6 +33,9 @@ class ExecuteContainerCommand extends Component public function mount() { + if (! auth()->user()->isAdmin()) { + abort(403); + } $this->parameters = get_route_parameters(); $this->containers = collect(); $this->servers = collect(); @@ -130,7 +133,6 @@ class ExecuteContainerCommand extends Component { try { $container_name = data_get($this->container, 'container.Names'); - ray($this->container); if (is_null($container_name)) { throw new \RuntimeException('Container not found.'); } From 07ed726c88c6da5069a47f597e23bc5d3f8e0c03 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 17 Sep 2024 16:48:30 +0200 Subject: [PATCH 07/10] refactor: Remove unnecessary code in Terminal.php --- app/Livewire/Project/Shared/Terminal.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/Livewire/Project/Shared/Terminal.php b/app/Livewire/Project/Shared/Terminal.php index 7c23c291d..802e65a30 100644 --- a/app/Livewire/Project/Shared/Terminal.php +++ b/app/Livewire/Project/Shared/Terminal.php @@ -14,13 +14,6 @@ class Terminal extends Component $server = Server::ownedByCurrentTeam()->whereUuid($serverUuid)->firstOrFail(); - // if (auth()->user()) { - // $teams = auth()->user()->teams->pluck('id'); - // if (! $teams->contains($server->team_id) && ! $teams->contains(0)) { - // throw new \Exception('User is not part of the team that owns this server'); - // } - // } - if ($isContainer) { $status = getContainerStatus($server, $identifier); if ($status !== 'running') { From 595a2414b133d66922e279abf87e5e2cb5a0e69c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 17 Sep 2024 16:48:58 +0200 Subject: [PATCH 08/10] fix: if you exit a container manually, it should close the underlying tty as well --- resources/views/livewire/project/shared/terminal.blade.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/resources/views/livewire/project/shared/terminal.blade.php b/resources/views/livewire/project/shared/terminal.blade.php index 31887120d..3c485c286 100644 --- a/resources/views/livewire/project/shared/terminal.blade.php +++ b/resources/views/livewire/project/shared/terminal.blade.php @@ -118,9 +118,8 @@ socket.send(JSON.stringify({ message: data })); - // Type CTRL + D or exit in the terminal - if (data === '\x04' || (data === '\r' && stripAnsiCommands(commandBuffer).trim() === 'exit')) { + if (data === '\x04' || (data === '\r' && stripAnsiCommands(commandBuffer).trim().includes('exit'))) { checkIfProcessIsRunningAndKillIt(); setTimeout(() => { $data.terminalActive = false; @@ -215,8 +214,8 @@ term.resize(termWidth, termHeight); socket.send(JSON.stringify({ resize: { - cols: 600, - rows: 600 + cols: termWidth, + rows: termHeight } })); } From e937d30545c4a16dd4e6a5c57e9f7d624a864aa2 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 17 Sep 2024 17:15:34 +0200 Subject: [PATCH 09/10] fix: move terminal to separate view on services --- app/Livewire/Project/Service/Navbar.php | 2 ++ .../livewire/project/service/configuration.blade.php | 7 ------- .../views/livewire/project/service/navbar.blade.php | 12 ++++++++---- .../shared/execute-container-command.blade.php | 2 +- routes/web.php | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php index 674182df5..e6bb6d9bf 100644 --- a/app/Livewire/Project/Service/Navbar.php +++ b/app/Livewire/Project/Service/Navbar.php @@ -20,6 +20,8 @@ class Navbar extends Component public $isDeploymentProgress = false; + public $title = 'Configuration'; + public function mount() { if (str($this->service->status())->contains('running') && is_null($this->service->config_hash)) { diff --git a/resources/views/livewire/project/service/configuration.blade.php b/resources/views/livewire/project/service/configuration.blade.php index c5ac0412f..4b692f9a9 100644 --- a/resources/views/livewire/project/service/configuration.blade.php +++ b/resources/views/livewire/project/service/configuration.blade.php @@ -23,10 +23,6 @@ @click.prevent="activeTab = 'scheduled-tasks'; window.location.hash = 'scheduled-tasks'" href="#">Scheduled Tasks - Terminal -
- -
diff --git a/resources/views/livewire/project/service/navbar.blade.php b/resources/views/livewire/project/service/navbar.blade.php index 125f9121a..8193fba57 100644 --- a/resources/views/livewire/project/service/navbar.blade.php +++ b/resources/views/livewire/project/service/navbar.blade.php @@ -6,17 +6,21 @@ -

Configuration

+

{{ $title }}